diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-08-04 14:26:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-04 14:26:10 +0000 |
commit | 15635e68bb65d5ce6963ce0c820719a06ca794cd (patch) | |
tree | a1b2dfdc3aa8c82367b4a71ae5cb3c633bd35292 /gcc/rust/hir/rust-ast-lower-base.h | |
parent | 7bdd8599b99a80b5930945bb87d1abffba8ee157 (diff) | |
parent | c4077cc2a8c9ade9bd9b61804d756fcfc2cc9931 (diff) | |
download | gcc-15635e68bb65d5ce6963ce0c820719a06ca794cd.zip gcc-15635e68bb65d5ce6963ce0c820719a06ca794cd.tar.gz gcc-15635e68bb65d5ce6963ce0c820719a06ca794cd.tar.bz2 |
Merge #605
605: Merge both module classes in one r=philberty a=CohenArthur
This PR merges both kinds of Modules (formerly `ModuleBodied` and `ModuleNoBody`) as one class with an enum. This is the [behavior used by rustc](https://github.com/rust-lang/rust/blob/2939249f294dd54a9ce78a8ee1f2922a44e7fb7c/compiler/rustc_ast/src/ast.rs#L2274), where both variants are kept in an enum with one holding a vector of items.
This change is important for multiple file parsing: An external mod (`mod foo; // defined in foo.rs or foo/mod.rs`) will see its items expanded during expansion, which occurs after parsing. This means that the previous directive will be "replaced" by `mod foo { <items> }` at the AST level. In order to achieve this, we need to be able to modify a previously parsed instance of an AST element.
In rustc, this is done [here](https://github.com/rust-lang/rust/blob/2939249f294dd54a9ce78a8ee1f2922a44e7fb7c/compiler/rustc_expand/src/expand.rs#L1427), where `mod_kind` was previously `ModKind::Unloaded` and becomes `ModKind::Loaded(parsed_items, ...)`.
Co-authored-by: CohenArthur <arthur.cohen@epita.fr>
Diffstat (limited to 'gcc/rust/hir/rust-ast-lower-base.h')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-base.h | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-base.h b/gcc/rust/hir/rust-ast-lower-base.h index 742cb1d..7ef5938 100644 --- a/gcc/rust/hir/rust-ast-lower-base.h +++ b/gcc/rust/hir/rust-ast-lower-base.h @@ -146,8 +146,7 @@ public: virtual void visit (AST::LifetimeWhereClauseItem &item) {} virtual void visit (AST::TypeBoundWhereClauseItem &item) {} virtual void visit (AST::Method &method) {} - virtual void visit (AST::ModuleBodied &module) {} - virtual void visit (AST::ModuleNoBody &module) {} + virtual void visit (AST::Module &module) {} virtual void visit (AST::ExternCrate &crate) {} // virtual void visit(UseTree& use_tree) {} virtual void visit (AST::UseTreeGlob &use_tree) {} |