From: Owen Avery <[email protected]>
Functions shouldn't be usable as named node links.
gcc/rust/ChangeLog:
* resolve/rust-default-resolver.cc
(DefaultResolver::visit (Function)): Don't pass a path parameter
to function NameResolutionContext::scoped.
gcc/testsuite/ChangeLog:
* rust/compile/mod_fn_conflict.rs: New test.
Signed-off-by: Owen Avery <[email protected]>
---
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/8af846035ccfbd54b9bf0e3952e601685631cd43
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/4807
gcc/rust/resolve/rust-default-resolver.cc | 3 +--
gcc/testsuite/rust/compile/mod_fn_conflict.rs | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/rust/compile/mod_fn_conflict.rs
diff --git a/gcc/rust/resolve/rust-default-resolver.cc
b/gcc/rust/resolve/rust-default-resolver.cc
index 7a54c6ee1..ac2b7b196 100644
--- a/gcc/rust/resolve/rust-default-resolver.cc
+++ b/gcc/rust/resolve/rust-default-resolver.cc
@@ -91,8 +91,7 @@ DefaultResolver::visit (AST::Function &function)
std::move (def_fn_1));
};
- ctx.scoped (Rib::Kind::Function, function.get_node_id (), def_fn_2,
- function.get_function_name ());
+ ctx.scoped (Rib::Kind::Function, function.get_node_id (), def_fn_2);
}
void
diff --git a/gcc/testsuite/rust/compile/mod_fn_conflict.rs
b/gcc/testsuite/rust/compile/mod_fn_conflict.rs
new file mode 100644
index 000000000..b184e696b
--- /dev/null
+++ b/gcc/testsuite/rust/compile/mod_fn_conflict.rs
@@ -0,0 +1,19 @@
+// TODO: allow(unused) should be disabling "function is never used" warnings
+// { dg-additional-options "-w" }
+#![no_core]
+#![feature(no_core)]
+
+mod a {
+ pub mod b {
+ pub struct X;
+ }
+}
+
+use a::*;
+
+#[allow(unused)]
+fn b() {}
+
+trait Y {}
+
+impl Y for b::X {}
base-commit: 9e6f1072efcf73d741471025b2ae74666af5eb4b
--
2.55.0