Skip to content

Commit 851d4c4

Browse files
committed
add several resolution test cases
1 parent 0e42435 commit 851d4c4

24 files changed

+269
-3
lines changed

tests/ui/imports/ambiguous-2.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ extern crate ambiguous_1;
66

77
fn main() {
88
ambiguous_1::id();
9+
//^ FIXME: `id` should be identified as an ambiguous item.
910
}

tests/ui/imports/ambiguous-4.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ extern crate ambiguous_4_extern;
55

66
fn main() {
77
ambiguous_4_extern::id();
8-
// `warning_ambiguous` had been lost at metadata.
8+
//^ FIXME: `id` should be identified as an ambiguous item.
99
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
mod a {
2+
pub type C = i8;
3+
}
4+
5+
mod b {
6+
pub type C = i16;
7+
}
8+
9+
pub use a::*;
10+
pub use b::*;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
macro_rules! m {
2+
() => {
3+
pub fn max() {}
4+
pub(crate) mod max {}
5+
};
6+
}
7+
8+
mod d {
9+
m! {}
10+
}
11+
12+
mod e {
13+
pub type max = i32;
14+
}
15+
16+
pub use self::d::*;
17+
pub use self::e::*;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
mod gio {
2+
pub trait SettingsExt {
3+
fn abc(&self) {}
4+
}
5+
impl<T> SettingsExt for T {}
6+
}
7+
8+
mod gtk {
9+
pub trait SettingsExt {
10+
fn efg(&self) {}
11+
}
12+
impl<T> SettingsExt for T {}
13+
}
14+
15+
pub use gtk::*;
16+
pub use gio::*;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
mod a {
2+
pub type Result<T> = std::result::Result<T, ()>;
3+
}
4+
5+
mod b {
6+
pub type Result<T> = std::result::Result<T, ()>;
7+
}
8+
9+
pub use a::*;
10+
pub use b::*;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub struct Url;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// edition: 2018
2+
// aux-build: issue-114682-5-extern-1.rs
3+
// compile-flags: --extern issue_114682_5_extern_1
4+
5+
pub mod p {
6+
pub use crate::types::*;
7+
pub use crate::*;
8+
}
9+
mod types {
10+
pub mod issue_114682_5_extern_1 {}
11+
}
12+
13+
pub use issue_114682_5_extern_1;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
mod a {
2+
pub fn log() {}
3+
}
4+
mod b {
5+
pub fn log() {}
6+
}
7+
8+
pub use self::a::*;
9+
pub use self::b::*;

tests/ui/imports/extern-with-ambiguous-2.rs

+2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ mod s {
1212
use s::*;
1313
use extern_with_ambiguous_2_extern::*;
1414
use error::*;
15+
//^ FIXME: An ambiguity error should be thrown for `error`,
16+
// as there is ambiguity present within `extern-with-ambiguous-2-extern.rs`.
1517

1618
fn main() {}

tests/ui/imports/extern-with-ambiguous-3.rs

+2
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@ mod s {
1313
use s::*;
1414
use extern_with_ambiguous_3_extern::*;
1515
use error::*;
16+
//^ FIXME: An ambiguity error should be thrown for `error`,
17+
// as there is ambiguity present within `extern-with-ambiguous-3-extern.rs`.
1618

1719
fn main() {}

tests/ui/imports/glob-conflict-cross-crate.rs tests/ui/imports/glob-conflict-cross-crate-1.rs

+4
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ extern crate glob_conflict;
44

55
fn main() {
66
glob_conflict::f(); //~ ERROR cannot find function `f` in crate `glob_conflict`
7+
//^ FIXME: `glob_conflict::f` should raise an
8+
// ambiguity error instead of a not found error.
79
glob_conflict::glob::f(); //~ ERROR cannot find function `f` in module `glob_conflict::glob`
10+
//^ FIXME: `glob_conflict::glob::f` should raise an
11+
// ambiguity error instead of a not found error.
812
}

tests/ui/imports/glob-conflict-cross-crate.stderr tests/ui/imports/glob-conflict-cross-crate-1.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0425]: cannot find function `f` in crate `glob_conflict`
2-
--> $DIR/glob-conflict-cross-crate.rs:6:20
2+
--> $DIR/glob-conflict-cross-crate-1.rs:6:20
33
|
44
LL | glob_conflict::f();
55
| ^ not found in `glob_conflict`
66

77
error[E0425]: cannot find function `f` in module `glob_conflict::glob`
8-
--> $DIR/glob-conflict-cross-crate.rs:7:26
8+
--> $DIR/glob-conflict-cross-crate-1.rs:9:26
99
|
1010
LL | glob_conflict::glob::f();
1111
| ^ not found in `glob_conflict::glob`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// aux-build:glob-conflict-cross-crate-2-extern.rs
2+
3+
extern crate glob_conflict_cross_crate_2_extern;
4+
5+
use glob_conflict_cross_crate_2_extern::*;
6+
7+
fn main() {
8+
let _a: C = 1; //~ ERROR cannot find type `C` in this scope
9+
//^ FIXME: `C` should be identified as an ambiguous item.
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0412]: cannot find type `C` in this scope
2+
--> $DIR/glob-conflict-cross-crate-2.rs:8:13
3+
|
4+
LL | let _a: C = 1;
5+
| ^ not found in this scope
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0412`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// check-pass
2+
// aux-build:glob-conflict-cross-crate-2-extern.rs
3+
4+
extern crate glob_conflict_cross_crate_2_extern;
5+
6+
mod a {
7+
pub type C = i32;
8+
}
9+
10+
use glob_conflict_cross_crate_2_extern::*;
11+
use a::*;
12+
13+
fn main() {
14+
let _a: C = 1;
15+
//^ FIXME: `C` should be identified as an ambiguous item.
16+
}

tests/ui/imports/issue-114682-1.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// https://github.com/rust-lang/rust/pull/114682#discussion_r1420534109
2+
3+
#![feature(decl_macro)]
4+
5+
macro_rules! mac {
6+
() => {
7+
pub macro A() {
8+
println!("non import")
9+
}
10+
}
11+
}
12+
13+
mod m {
14+
pub macro A() {
15+
println!("import")
16+
}
17+
}
18+
19+
pub use m::*;
20+
mac!();
21+
22+
fn main() {
23+
A!();
24+
//~^ ERROR `A` is ambiguous
25+
}
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error[E0659]: `A` is ambiguous
2+
--> $DIR/issue-114682-1.rs:23:5
3+
|
4+
LL | A!();
5+
| ^ ambiguous name
6+
|
7+
= note: ambiguous because of a conflict between a name from a glob import and a macro-expanded name in the same module during import or macro resolution
8+
note: `A` could refer to the macro defined here
9+
--> $DIR/issue-114682-1.rs:7:9
10+
|
11+
LL | / pub macro A() {
12+
LL | | println!("non import")
13+
LL | | }
14+
| |_________^
15+
...
16+
LL | mac!();
17+
| ------ in this macro invocation
18+
note: `A` could also refer to the macro imported here
19+
--> $DIR/issue-114682-1.rs:19:9
20+
|
21+
LL | pub use m::*;
22+
| ^^^^
23+
= help: consider adding an explicit import of `A` to disambiguate
24+
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
25+
26+
error: aborting due to 1 previous error
27+
28+
For more information about this error, try `rustc --explain E0659`.

tests/ui/imports/issue-114682-2.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// aux-build: issue-114682-2-extern.rs
2+
// https://github.com/rust-lang/rust/pull/114682#issuecomment-1879998900
3+
4+
extern crate issue_114682_2_extern;
5+
6+
use issue_114682_2_extern::max;
7+
8+
type A = issue_114682_2_extern::max;
9+
//~^ ERROR: expected type, found function `issue_114682_2_extern::max`
10+
// FIXME:
11+
// The above error was emitted due to `(Mod(issue_114682_2_extern), Namespace(Type), Ident(max))`
12+
// being identified as an ambiguous item.
13+
// However, there are two points worth discussing:
14+
// First, should this ambiguous item be omitted considering the maximum visibility
15+
// of `issue_114682_2_extern::m::max` in the type namespace is only within the extern crate.
16+
// Second, if we retain the ambiguous item of the extern crate, should it be treated
17+
// as an ambiguous item within the local crate for the same reasoning?
18+
19+
fn main() {}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0573]: expected type, found function `issue_114682_2_extern::max`
2+
--> $DIR/issue-114682-2.rs:8:10
3+
|
4+
LL | type A = issue_114682_2_extern::max;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ not a type
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0573`.

tests/ui/imports/issue-114682-3.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// check-pass
2+
// aux-build: issue-114682-3-extern.rs
3+
// https://github.com/rust-lang/rust/pull/114682#issuecomment-1880625909
4+
5+
extern crate issue_114682_3_extern;
6+
7+
use issue_114682_3_extern::*;
8+
9+
mod auto {
10+
pub trait SettingsExt {
11+
fn ext(&self) {}
12+
}
13+
14+
impl<T> SettingsExt for T {}
15+
}
16+
17+
pub use self::auto::*;
18+
19+
fn main() {
20+
let a: u8 = 1;
21+
a.ext();
22+
//^ FIXME: it should report `ext` not found because `SettingsExt`
23+
// is an ambiguous item in `issue-114682-3-extern.rs`.
24+
}

tests/ui/imports/issue-114682-4.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// check-pass
2+
// aux-build: issue-114682-4-extern.rs
3+
// https://github.com/rust-lang/rust/pull/114682#issuecomment-1880755441
4+
5+
extern crate issue_114682_4_extern;
6+
7+
use issue_114682_4_extern::*;
8+
9+
fn a() -> Result<i32, ()> { // FIXME: `Result` should be identified as an ambiguous item.
10+
Ok(1)
11+
}
12+
13+
fn main() {}

tests/ui/imports/issue-114682-5.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// check-pass
2+
// edition: 2018
3+
// aux-build: issue-114682-5-extern-1.rs
4+
// aux-build: issue-114682-5-extern-2.rs
5+
// compile-flags: --extern issue_114682_5_extern_1
6+
// https://github.com/rust-lang/rust/pull/114682#issuecomment-1880755441
7+
8+
extern crate issue_114682_5_extern_2;
9+
10+
use issue_114682_5_extern_2::p::*;
11+
use issue_114682_5_extern_1::Url;
12+
// FIXME: The `issue_114682_5_extern_1` should be considered an ambiguous item,
13+
// as it has already been recognized as ambiguous in `issue_114682_5_extern_2`.
14+
15+
fn main() {}

tests/ui/imports/issue-114682-6.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// check-pass
2+
// aux-build: issue-114682-6-extern.rs
3+
// https://github.com/rust-lang/rust/pull/114682#issuecomment-1880755441
4+
5+
extern crate issue_114682_6_extern;
6+
7+
use issue_114682_6_extern::*;
8+
9+
fn main() {
10+
let log = 2;
11+
//^ `log` should be identified as an ambiguous item.
12+
let _ = log;
13+
}

0 commit comments

Comments
 (0)