diff options
| author | bors <bors@rust-lang.org> | 2019-01-01 02:08:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-01-01 02:08:39 +0000 |
| commit | d8371c61e65a9287f89730956166aa20765c78c0 (patch) | |
| tree | e7358769b82e40248db3cc8332216d401d10b823 /src/test | |
| parent | fe6a54d2207c9ab2c5eb5aa3c9488d92c7c86bfb (diff) | |
| parent | 06f22ba427660589c543d6f37c8c45de88d28093 (diff) | |
| download | rust-d8371c61e65a9287f89730956166aa20765c78c0.tar.gz rust-d8371c61e65a9287f89730956166aa20765c78c0.zip | |
Auto merge of #57199 - petrochenkov:ambig, r=estebank
resolve: Simplify treatment of ambiguity errors
If we have a glob conflict like this
```rust
mod m1 { struct S; }
mod m2 { struct S; }
use m1::*;
use m2::*;
```
we treat it as a special "ambiguity item" that's not an error by itself, but produces an error when actually used.
```rust
use m1::*; // primary
use m2::*; // secondary
=>
ambiguity S(m1::S, m2::S);
```
Ambiguity items were *sometimes* treated as their primary items for error recovery, but pretty irregularly.
After this PR they are always treated as their primary items, except that
- If an ambiguity item is marked as used, then it still produces an error.
- Ambiguity items are still filtered away when exported to other crates (which is also a use in some sense).
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/imports/auxiliary/glob-conflict.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/imports/duplicate.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/imports/glob-conflict-cross-crate.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/imports/glob-conflict-cross-crate.stderr | 8 |
4 files changed, 13 insertions, 2 deletions
diff --git a/src/test/ui/imports/auxiliary/glob-conflict.rs b/src/test/ui/imports/auxiliary/glob-conflict.rs index ac12ed9c81c..c83db64c643 100644 --- a/src/test/ui/imports/auxiliary/glob-conflict.rs +++ b/src/test/ui/imports/auxiliary/glob-conflict.rs @@ -7,3 +7,7 @@ mod m2 { pub use m1::*; pub use m2::*; + +pub mod glob { + pub use *; +} diff --git a/src/test/ui/imports/duplicate.rs b/src/test/ui/imports/duplicate.rs index d62bbf765b7..db6538969ec 100644 --- a/src/test/ui/imports/duplicate.rs +++ b/src/test/ui/imports/duplicate.rs @@ -37,7 +37,7 @@ fn main() { } mod ambiguous_module_errors { - pub mod m1 { pub use super::m1 as foo; } + pub mod m1 { pub use super::m1 as foo; pub fn bar() {} } pub mod m2 { pub use super::m2 as foo; } use self::m1::*; diff --git a/src/test/ui/imports/glob-conflict-cross-crate.rs b/src/test/ui/imports/glob-conflict-cross-crate.rs index e02148b19f7..c8b18525d80 100644 --- a/src/test/ui/imports/glob-conflict-cross-crate.rs +++ b/src/test/ui/imports/glob-conflict-cross-crate.rs @@ -4,4 +4,5 @@ extern crate glob_conflict; fn main() { glob_conflict::f(); //~ ERROR cannot find function `f` in module `glob_conflict` + glob_conflict::glob::f(); //~ ERROR cannot find function `f` in module `glob_conflict::glob` } diff --git a/src/test/ui/imports/glob-conflict-cross-crate.stderr b/src/test/ui/imports/glob-conflict-cross-crate.stderr index f64637fd6f6..f5a82ef1b3b 100644 --- a/src/test/ui/imports/glob-conflict-cross-crate.stderr +++ b/src/test/ui/imports/glob-conflict-cross-crate.stderr @@ -4,6 +4,12 @@ error[E0425]: cannot find function `f` in module `glob_conflict` LL | glob_conflict::f(); //~ ERROR cannot find function `f` in module `glob_conflict` | ^ not found in `glob_conflict` -error: aborting due to previous error +error[E0425]: cannot find function `f` in module `glob_conflict::glob` + --> $DIR/glob-conflict-cross-crate.rs:7:26 + | +LL | glob_conflict::glob::f(); //~ ERROR cannot find function `f` in module `glob_conflict::glob` + | ^ not found in `glob_conflict::glob` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0425`. |
