Skip to content

Commit eb8dbbe

Browse files
committed
add several resolution test cases
1 parent cb25c5b commit eb8dbbe

19 files changed

+233
-2
lines changed
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/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:7: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,9 @@
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+
}
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,15 @@
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+
}

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

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// check-pass
2+
// aux-build: issue-114682-2-extern.rs
3+
// https://github.com/rust-lang/rust/pull/114682#issuecomment-1879998900
4+
5+
extern crate issue_114682_2_extern;
6+
7+
use issue_114682_2_extern::max;
8+
9+
fn main() {}

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

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
}

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, ()> {
10+
Ok(1)
11+
}
12+
13+
fn main() {}

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

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
13+
fn main() {}

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

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
let _ = log;
12+
}

0 commit comments

Comments
 (0)