diff options
Diffstat (limited to 'gcc/rust/hir/rust-hir-dump.cc')
-rw-r--r-- | gcc/rust/hir/rust-hir-dump.cc | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc index 798179d..cb32f68 100644 --- a/gcc/rust/hir/rust-hir-dump.cc +++ b/gcc/rust/hir/rust-hir-dump.cc @@ -315,6 +315,14 @@ Dump::do_functionparam (FunctionParam &e) void Dump::do_pathpattern (PathPattern &e) { + if (e.get_path_kind () == PathPattern::Kind::LangItem) + { + put_field ("segments", "#[lang = \"" + + LangItem::ToString (e.get_lang_item ()) + + "\"]"); + return; + } + std::string str = ""; for (const auto &segment : e.get_segments ()) @@ -388,7 +396,10 @@ void Dump::do_typepathsegment (TypePathSegment &e) { do_mappings (e.get_mappings ()); - put_field ("ident_segment", e.get_ident_segment ().as_string ()); + if (e.is_lang_item ()) + put_field ("ident_segment", LangItem::PrettyString (e.get_lang_item ())); + else + put_field ("ident_segment", e.get_ident_segment ().as_string ()); } void @@ -402,9 +413,12 @@ void Dump::do_qualifiedpathtype (QualifiedPathType &e) { do_mappings (e.get_mappings ()); - visit_field ("type", e.get_type ()); + if (e.has_type ()) + visit_field ("type", e.get_type ()); + else + put_field ("type", "none"); - if (e.has_as_clause ()) + if (e.has_trait ()) visit_field ("trait", e.get_trait ()); } @@ -524,13 +538,16 @@ Dump::do_traitfunctiondecl (TraitFunctionDecl &e) if (e.has_return_type ()) visit_field ("return_type", e.get_return_type ()); + else + put_field ("return_type", "none"); if (e.has_where_clause ()) put_field ("where_clause", e.get_where_clause ().as_string ()); else put_field ("where_clause", "none"); - put_field ("self", e.get_self ().as_string ()); + if (e.is_method ()) + put_field ("self", e.get_self_unchecked ().as_string ()); end ("TraitFunctionDecl"); } @@ -1267,7 +1284,9 @@ Dump::visit (BlockExpr &e) do_expr (e); do_inner_attrs (e); put_field ("tail_reachable", std::to_string (e.is_tail_reachable ())); - put_field ("label", e.get_label ().as_string ()); + + if (e.has_label ()) + put_field ("label", e.get_label ().as_string ()); visit_collection ("statements", e.get_statements ()); @@ -1303,6 +1322,8 @@ Dump::visit (BreakExpr &e) if (e.has_break_expr ()) visit_field ("break_expr ", e.get_expr ()); + else + put_field ("break_expr", "none"); end ("BreakExpr"); } @@ -1489,6 +1510,10 @@ Dump::visit (InlineAsm &e) {} void +Dump::visit (LlvmInlineAsm &e) +{} + +void Dump::visit (TypeParam &e) { begin ("TypeParam"); @@ -1675,7 +1700,8 @@ Dump::visit (Function &e) put_field ("where clause", e.get_where_clause ().as_string ()); visit_field ("function_body", e.get_definition ()); - put_field ("self", e.get_self_param ().as_string ()); + if (e.is_method ()) + put_field ("self", e.get_self_param_unchecked ().as_string ()); end ("Function"); } @@ -1914,7 +1940,9 @@ Dump::visit (TraitItemConst &e) put_field ("name", e.get_name ().as_string ()); visit_field ("type", e.get_type ()); - visit_field ("expr", e.get_expr ()); + if (e.has_expr ()) + visit_field ("expr", e.get_expr ()); + end ("TraitItemConst"); } @@ -2330,15 +2358,6 @@ Dump::visit (ParenthesisedType &e) } void -Dump::visit (ImplTraitTypeOneBound &e) -{ - begin ("ImplTraitTypeOneBound"); - do_type (e); - visit_field ("trait_bound", e.get_trait_bound ()); - end ("ImplTraitTypeOneBound"); -} - -void Dump::visit (TupleType &e) { begin ("TupleType"); @@ -2429,7 +2448,9 @@ Dump::visit (BareFunctionType &e) end_field ("params"); } - visit_field ("return_type", e.get_return_type ()); + if (e.has_return_type ()) + visit_field ("return_type", e.get_return_type ()); + put_field ("is_variadic", std::to_string (e.get_is_variadic ())); end ("BareFunctionType"); } |