aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir/rust-hir-dump.cc
diff options
context:
space:
mode:
authorMarc Poulhiès <dkm@kataplop.net>2023-08-10 23:06:32 +0200
committerPhilip Herron <philip.herron@embecosm.com>2023-08-12 17:22:19 +0000
commit086b7f9c9ae653a5f847cbe2edd3c46874c62d20 (patch)
tree17b9b85b44c91280b3bef2f560b6e65aaebba5f6 /gcc/rust/hir/rust-hir-dump.cc
parentc10d668b5076a38a7f1b2b13c948be68dcf57ea1 (diff)
downloadgcc-086b7f9c9ae653a5f847cbe2edd3c46874c62d20.zip
gcc-086b7f9c9ae653a5f847cbe2edd3c46874c62d20.tar.gz
gcc-086b7f9c9ae653a5f847cbe2edd3c46874c62d20.tar.bz2
gccrs: Cleanup HIR dump
visit_field() correctly handles empty unique_ptr<> and displays "none". gcc/rust/ChangeLog: * hir/rust-hir-dump.cc (Dump::visit): Remove useless if/else already handled by visit_field. Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Diffstat (limited to 'gcc/rust/hir/rust-hir-dump.cc')
-rw-r--r--gcc/rust/hir/rust-hir-dump.cc47
1 files changed, 10 insertions, 37 deletions
diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc
index fb6029f..5f585b7 100644
--- a/gcc/rust/hir/rust-hir-dump.cc
+++ b/gcc/rust/hir/rust-hir-dump.cc
@@ -35,7 +35,7 @@ namespace HIR {
// field: ...
// ]
//
-// When a field is a collection of other HIR object:
+// When a field is a collection of other HIR objects:
// field {
// SomeHIRNode [ ... ]
// SomeOtherHIRNode [ ... ]
@@ -1214,19 +1214,13 @@ Dump::visit (ClosureExpr &e)
auto oa = param.get_outer_attrs ();
do_outer_attrs (oa);
visit_field ("pattern", param.get_pattern ());
- if (param.has_type_given ())
- visit_field ("type", param.get_type ());
- else
- put_field ("type", "none");
+ visit_field ("type", param.get_type ());
end ("ClosureParam");
}
end_field ("params");
}
- if (e.has_return_type ())
- visit_field ("return_type", *e.get_return_type ());
- else
- put_field ("return_type", "none");
+ visit_field ("return_type", e.get_return_type ());
visit_field ("expr", e.get_expr ());
end ("ClosureExpr");
@@ -1241,10 +1235,7 @@ Dump::visit (BlockExpr &e)
visit_collection ("statements", e.get_statements ());
- if (e.has_expr ())
- visit_field ("expr", e.get_final_expr ());
- else
- put_field ("expr", "none");
+ visit_field ("expr", e.get_final_expr ());
end ("BlockExpr");
}
@@ -1273,10 +1264,7 @@ Dump::visit (BreakExpr &e)
else
put_field ("label", "none");
- if (e.has_break_expr ())
- visit_field ("break_expr ", e.get_expr ());
- else
- put_field ("break_expr ", "none");
+ visit_field ("break_expr ", e.get_expr ());
end ("BreakExpr");
}
@@ -1346,10 +1334,7 @@ Dump::visit (ReturnExpr &e)
begin ("ReturnExpr");
do_mappings (e.get_mappings ());
- if (e.has_return_expr ())
- visit_field ("return_expr", e.get_expr ());
- else
- put_field ("return_expr", "none");
+ visit_field ("return_expr", e.get_expr ());
end ("ReturnExpr");
}
@@ -1496,10 +1481,7 @@ Dump::visit (TypeParam &e)
visit_collection ("type_param_bounds", e.get_type_param_bounds ());
- if (e.has_type ())
- visit_field ("type", e.get_type ());
- else
- put_field ("type", "none");
+ visit_field ("type", e.get_type ());
end ("TypeParam");
}
@@ -1665,10 +1647,7 @@ Dump::visit (Function &e)
put_field ("function_params", "empty");
}
- if (e.has_function_return_type ())
- visit_field ("return_type", *e.get_return_type ());
- else
- put_field ("return_type", "none");
+ visit_field ("return_type", e.get_return_type ());
if (!e.has_where_clause ())
put_field ("where_clause", "none");
@@ -1901,10 +1880,7 @@ Dump::visit (TraitItemFunc &e)
do_traitfunctiondecl (e.get_decl ());
- if (e.has_definition ())
- visit_field ("block_expr", e.get_block_expr ());
- else
- put_field ("block_expr", "none");
+ visit_field ("block_expr", e.get_block_expr ());
end ("TraitItemFunc");
}
@@ -2019,10 +1995,7 @@ Dump::visit (ExternalFunctionItem &e)
put_field ("has_variadics", std::to_string (e.is_variadic ()));
- if (e.has_return_type ())
- visit_field ("return_type", e.get_return_type ());
- else
- put_field ("return_type", "none");
+ visit_field ("return_type", e.get_return_type ());
end ("ExternalFunctionItem");
}