[gccrs,COMMIT] Limit globbing visitor
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_simplebootstrap_build--master-aarch64-bootstrap |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_simplebootstrap_build--master-arm-bootstrap |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_gcc_check--master-arm |
success
|
Test passed
|
Commit Message
From: Owen Avery <powerboat9.gamer@gmail.com>
The globbing visitor would previously descend into some kinds of rust
item, instead of registering them as glob imports or ignoring them. This
would cause items nested in those items to be glob imported, despite
them not being top level items inside the glob container.
gcc/rust/ChangeLog:
* resolve/rust-finalize-imports-2.0.cc (GlobbingVisitor::visit):
Add overrides for more items.
* resolve/rust-finalize-imports-2.0.h (GlobbingVisitor::visit):
Likewise.
gcc/testsuite/ChangeLog:
* rust/compile/name_resolution27.rs: New test.
Reported-by: Arthur Cohen <arthur.cohen@embecosm.com>
Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github: https://github.com/Rust-GCC/gccrs/commit/cd9103fd3fe8d3726d5b4c30d30c7da265f53da3
The commit has NOT been mentioned in any issue.
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4569
gcc/rust/resolve/rust-finalize-imports-2.0.cc | 22 +++++++++++++++++++
gcc/rust/resolve/rust-finalize-imports-2.0.h | 4 ++++
.../rust/compile/name_resolution27.rs | 20 +++++++++++++++++
3 files changed, 46 insertions(+)
create mode 100644 gcc/testsuite/rust/compile/name_resolution27.rs
base-commit: b203e0fff0613f5577891ea77ead2b42c9d81e43
@@ -142,6 +142,28 @@ GlobbingVisitor::visit (AST::ConstantItem &const_item)
Namespace::Values);
}
+void
+GlobbingVisitor::visit (AST::TypeAlias &type)
+{
+ ctx.insert_globbed (type.get_new_type_name (), type.get_node_id (),
+ Namespace::Types);
+}
+
+void
+GlobbingVisitor::visit (AST::Trait &trait)
+{
+ ctx.insert_globbed (trait.get_identifier (), trait.get_node_id (),
+ Namespace::Types);
+}
+
+void
+GlobbingVisitor::visit (AST::InherentImpl &impl)
+{}
+
+void
+GlobbingVisitor::visit (AST::TraitImpl &impl)
+{}
+
void
GlobbingVisitor::visit (AST::ExternCrate &crate)
{}
@@ -48,6 +48,10 @@ public:
void visit (AST::Enum &enum_item) override;
void visit (AST::Union &union_item) override;
void visit (AST::ConstantItem &const_item) override;
+ void visit (AST::TypeAlias &type) override;
+ void visit (AST::Trait &trait) override;
+ void visit (AST::InherentImpl &impl) override;
+ void visit (AST::TraitImpl &impl) override;
void visit (AST::ExternCrate &crate) override;
void visit (AST::UseDeclaration &use) override;
new file mode 100644
@@ -0,0 +1,20 @@
+#![feature(no_core)]
+#![no_core]
+
+mod a {
+ trait A {
+ fn foo();
+ }
+
+ struct B;
+
+ impl A for B {
+ fn foo() {}
+ }
+}
+
+use a::*;
+
+pub fn bar() {
+ foo() // { dg-error "Cannot find path" }
+}