mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
fix(resolve): update shadowed_glob
more precision
This commit is contained in:
parent
4bd4e2ea82
commit
f7330eb752
@ -338,7 +338,21 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
|
||||
} else {
|
||||
resolution.binding = Some(nonglob_binding);
|
||||
}
|
||||
resolution.shadowed_glob = Some(glob_binding);
|
||||
|
||||
if let Some(old_binding) = resolution.shadowed_glob {
|
||||
assert!(old_binding.is_glob_import());
|
||||
if glob_binding.res() != old_binding.res() {
|
||||
resolution.shadowed_glob = Some(this.ambiguity(
|
||||
AmbiguityKind::GlobVsGlob,
|
||||
old_binding,
|
||||
glob_binding,
|
||||
));
|
||||
} else if !old_binding.vis.is_at_least(binding.vis, this.tcx) {
|
||||
resolution.shadowed_glob = Some(glob_binding);
|
||||
}
|
||||
} else {
|
||||
resolution.shadowed_glob = Some(glob_binding);
|
||||
}
|
||||
}
|
||||
(false, false) => {
|
||||
return Err(old_binding);
|
||||
|
@ -4,17 +4,19 @@ error[E0659]: `V` is ambiguous
|
||||
LL | use V;
|
||||
| ^ ambiguous name
|
||||
|
|
||||
= note: ambiguous because of multiple potential import sources
|
||||
= note: ambiguous because of multiple glob imports of a name in the same module
|
||||
note: `V` could refer to the variant imported here
|
||||
--> $DIR/issue-105069.rs:1:5
|
||||
|
|
||||
LL | use self::A::*;
|
||||
| ^^^^^^^^^^
|
||||
= help: consider adding an explicit import of `V` to disambiguate
|
||||
note: `V` could also refer to the variant imported here
|
||||
--> $DIR/issue-105069.rs:3:5
|
||||
|
|
||||
LL | use self::B::*;
|
||||
| ^^^^^^^^^^
|
||||
= help: consider adding an explicit import of `V` to disambiguate
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
14
tests/ui/resolve/issue-109153.rs
Normal file
14
tests/ui/resolve/issue-109153.rs
Normal file
@ -0,0 +1,14 @@
|
||||
use foo::*;
|
||||
|
||||
mod foo {
|
||||
pub mod bar {
|
||||
pub mod bar {
|
||||
pub mod bar {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use bar::bar; //~ ERROR `bar` is ambiguous
|
||||
use bar::*;
|
||||
|
||||
fn main() { }
|
23
tests/ui/resolve/issue-109153.stderr
Normal file
23
tests/ui/resolve/issue-109153.stderr
Normal file
@ -0,0 +1,23 @@
|
||||
error[E0659]: `bar` is ambiguous
|
||||
--> $DIR/issue-109153.rs:11:5
|
||||
|
|
||||
LL | use bar::bar;
|
||||
| ^^^ ambiguous name
|
||||
|
|
||||
= note: ambiguous because of multiple glob imports of a name in the same module
|
||||
note: `bar` could refer to the module imported here
|
||||
--> $DIR/issue-109153.rs:1:5
|
||||
|
|
||||
LL | use foo::*;
|
||||
| ^^^^^^
|
||||
= help: consider adding an explicit import of `bar` to disambiguate
|
||||
note: `bar` could also refer to the module imported here
|
||||
--> $DIR/issue-109153.rs:12:5
|
||||
|
|
||||
LL | use bar::*;
|
||||
| ^^^^^^
|
||||
= help: consider adding an explicit import of `bar` to disambiguate
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0659`.
|
Loading…
Reference in New Issue
Block a user