aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-10-17 10:04:40 +0000
committerGitHub <noreply@github.com>2022-10-17 10:04:40 +0000
commit381e061438836b7ca360c7741e9a13ec6d643b1d (patch)
tree643c028567cc166ccfe6f2b6f2dc746afb67af71
parenta14da50ebe674b8444c578454cd7914327f90755 (diff)
parentb2add3214565a70403402e80e11352f8a1e3681a (diff)
downloadgcc-381e061438836b7ca360c7741e9a13ec6d643b1d.zip
gcc-381e061438836b7ca360c7741e9a13ec6d643b1d.tar.gz
gcc-381e061438836b7ca360c7741e9a13ec6d643b1d.tar.bz2
Merge #1597
1597: ast: Module: unloaded module and inner attributes r=CohenArthur a=jdupak Adds support for unloaded modules and dumps also inner attributes. Resolves issue found in #1548. Co-authored-by: Jakub Dupak <dev@jakubdupak.com>
-rw-r--r--gcc/rust/ast/rust-ast-dump.cc41
1 files changed, 32 insertions, 9 deletions
diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc
index 1e7a235..a12c392 100644
--- a/gcc/rust/ast/rust-ast-dump.cc
+++ b/gcc/rust/ast/rust-ast-dump.cc
@@ -810,21 +810,44 @@ Dump::visit (Method &method)
void
Dump::visit (Module &module)
{
- emit_visibility (module.get_visibility ());
- stream << "mod " << module.get_name () << " {\n";
+ // Syntax:
+ // mod IDENTIFIER ;
+ // | mod IDENTIFIER {
+ // InnerAttribute*
+ // Item*
+ // }
- indentation.increment ();
+ emit_visibility (module.get_visibility ());
+ stream << "mod " << module.get_name ();
- for (auto &item : module.get_items ())
+ if (module.get_kind () == Module::UNLOADED)
{
- stream << indentation;
- item->accept_vis (*this);
- stream << '\n';
+ stream << ";\n";
}
+ else /* Module::LOADED */
+ {
+ stream << " {\n";
- indentation.decrement ();
+ indentation.increment ();
- stream << indentation << "}\n";
+ for (auto &item : module.get_inner_attrs ())
+ {
+ stream << indentation;
+ emit_attrib (item);
+ stream << '\n';
+ }
+
+ for (auto &item : module.get_items ())
+ {
+ stream << indentation;
+ item->accept_vis (*this);
+ stream << '\n';
+ }
+
+ indentation.decrement ();
+
+ stream << indentation << "}\n";
+ }
}
void