aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorJakub Dupak <dev@jakubdupak.com>2022-10-15 21:30:40 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2023-02-21 12:36:36 +0100
commite535b7b3e385edbc4cb830328f11fa5492df5d77 (patch)
tree4bd3a2934a0d0988dc3fd0452221fd5416a0d432 /gcc/rust
parent2f16df1b443329694d1daf3e02987841a0857ede (diff)
downloadgcc-e535b7b3e385edbc4cb830328f11fa5492df5d77.zip
gcc-e535b7b3e385edbc4cb830328f11fa5492df5d77.tar.gz
gcc-e535b7b3e385edbc4cb830328f11fa5492df5d77.tar.bz2
gccrs: ast: Module: unloaded module and inner attributes
gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Properly handle unloaded modules. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Diffstat (limited to 'gcc/rust')
-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