diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-04-10 15:31:29 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-04-12 22:39:45 +0100 |
commit | 85f587410612c8d2ec65dd23063a849d13005957 (patch) | |
tree | becd4a2fe59042dc35cbaae862403105b5ead1df /gcc/rust/resolve/rust-ast-verify-assignee.h | |
parent | 5fe4984806be69154e2a48be58965eb67a4be300 (diff) | |
download | gcc-85f587410612c8d2ec65dd23063a849d13005957.zip gcc-85f587410612c8d2ec65dd23063a849d13005957.tar.gz gcc-85f587410612c8d2ec65dd23063a849d13005957.tar.bz2 |
Add Canonical paths to name resolution
In order to support name resolution and checks for duplicate definitions
of names we need canonical paths for all DefId items such as inherent impl
items and normal items.
Consider:
struct Foo<T>(T);
impl Foo<f32> {
fn name()...
}
impl Foo<i32> {
fn name()...
}
Each of the impl blocks have a name function but these are seperate due to
the concrete impl of the Parameter type passed in.
The caveat here is that to call this Function name the programmer must be
explicit in which implentation they wish to call such as:
let a = Foo::<f32>::name();
This lets the Path probe lookup the apropriate impl block. The problem here
is that rust also allows for the compiler to infer the impl you wish such
as:
let a = Foo::name();
This should fail since there are multiple candidates possible for this
Path. Unless there might have only been one name function in which case
it would have worked.
This does not support looking for any inherent impl items overlapping such
as: rustc_typeck/src/coherence/inherent_impls_overlap.rs - see #353
Fixes #355 #335 #325
Diffstat (limited to 'gcc/rust/resolve/rust-ast-verify-assignee.h')
-rw-r--r-- | gcc/rust/resolve/rust-ast-verify-assignee.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/rust/resolve/rust-ast-verify-assignee.h b/gcc/rust/resolve/rust-ast-verify-assignee.h index b607fbe..13b6c91 100644 --- a/gcc/rust/resolve/rust-ast-verify-assignee.h +++ b/gcc/rust/resolve/rust-ast-verify-assignee.h @@ -57,7 +57,8 @@ public: void visit (AST::IdentifierExpr &expr) override { - if (!resolver->get_name_scope ().lookup (expr.as_string (), &resolved_node)) + if (!resolver->get_name_scope ().lookup (CanonicalPath (expr.as_string ()), + &resolved_node)) return; ok = true; |