Skip to content

Commit 448e516

Browse files
yaahcVoultapher
authored andcommitted
Add test cases
1 parent 2fcaddb commit 448e516

18 files changed

+396
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ edition: 2024
2+
//@ check-pass
3+
#![crate_type = "lib"]
4+
mod m1 {
5+
pub use core::prelude::v1::*;
6+
}
7+
8+
mod m2 {
9+
pub use std::prelude::v1::*;
10+
}
11+
12+
#[allow(unused)]
13+
use m2::*;
14+
fn foo() {
15+
use m1::*;
16+
17+
panic!();
18+
//~^ WARN: `panic` is ambiguous [ambiguous_panic_imports]
19+
//~| WARN: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
20+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
warning: `panic` is ambiguous
2+
--> $DIR/ambiguous-panic-glob-vs-multiouter.rs:20:5
3+
|
4+
LL | panic!();
5+
| ^^^^^ ambiguous name
6+
|
7+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8+
= note: for more information, see issue #147319 <https://github.com/rust-lang/rust/issues/147319>
9+
= note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
10+
note: `panic` could refer to the macro imported here
11+
--> $DIR/ambiguous-panic-glob-vs-multiouter.rs:15:9
12+
|
13+
LL | use m1::*;
14+
| ^^^^^
15+
= help: consider adding an explicit import of `panic` to disambiguate
16+
note: `panic` could also refer to the macro imported here
17+
--> $DIR/ambiguous-panic-glob-vs-multiouter.rs:13:5
18+
|
19+
LL | use m2::*;
20+
| ^^^^^
21+
= help: use `crate::panic` to refer to this macro unambiguously
22+
= note: `#[warn(ambiguous_panic_imports)]` (part of `#[warn(future_incompatible)]`) on by default
23+
24+
warning: 1 warning emitted
25+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//@ edition: 2024
2+
#![crate_type = "lib"]
3+
mod m1 {
4+
pub use core::prelude::v1::*;
5+
}
6+
7+
mod m2 {
8+
pub use std::prelude::v1::*;
9+
}
10+
11+
#[allow(unused)]
12+
fn foo() {
13+
use m1::*;
14+
use m2::*;
15+
16+
// I had hoped that this would not produce the globvsglob error because it would never be
17+
// resolving `panic` via one of the ambiguous glob imports above but it appears to do so, not
18+
// sure why
19+
panic!();
20+
//~^ ERROR: `panic` is ambiguous [E0659]
21+
//~| WARN: `panic` is ambiguous [ambiguous_panic_imports]
22+
//~| WARN: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
23+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
error[E0659]: `panic` is ambiguous
2+
--> $DIR/ambiguous-panic-globvsglob.rs:19:5
3+
|
4+
LL | panic!();
5+
| ^^^^^ ambiguous name
6+
|
7+
= note: ambiguous because of multiple glob imports of a name in the same module
8+
note: `panic` could refer to the macro imported here
9+
--> $DIR/ambiguous-panic-globvsglob.rs:13:9
10+
|
11+
LL | use m1::*;
12+
| ^^^^^
13+
= help: consider adding an explicit import of `panic` to disambiguate
14+
note: `panic` could also refer to the macro imported here
15+
--> $DIR/ambiguous-panic-globvsglob.rs:14:9
16+
|
17+
LL | use m2::*;
18+
| ^^^^^
19+
= help: consider adding an explicit import of `panic` to disambiguate
20+
21+
warning: `panic` is ambiguous
22+
--> $DIR/ambiguous-panic-globvsglob.rs:19:5
23+
|
24+
LL | panic!();
25+
| ^^^^^ ambiguous name
26+
|
27+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
28+
= note: for more information, see issue #147319 <https://github.com/rust-lang/rust/issues/147319>
29+
= note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
30+
note: `panic` could refer to the macro imported here
31+
--> $DIR/ambiguous-panic-globvsglob.rs:13:9
32+
|
33+
LL | use m1::*;
34+
| ^^^^^
35+
= help: consider adding an explicit import of `panic` to disambiguate
36+
note: `panic` could also refer to a macro from prelude
37+
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
38+
= note: `#[warn(ambiguous_panic_imports)]` (part of `#[warn(future_incompatible)]`) on by default
39+
40+
error: aborting due to 1 previous error; 1 warning emitted
41+
42+
For more information about this error, try `rustc --explain E0659`.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ edition: 2024
2+
#![crate_type = "lib"]
3+
#![no_implicit_prelude]
4+
5+
mod m1 {
6+
macro_rules! panic {
7+
() => {};
8+
}
9+
10+
pub(crate) use panic;
11+
}
12+
13+
fn foo() {
14+
use m1::*;
15+
panic!(); //~ERROR: `panic` is ambiguous [E0659]
16+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0659]: `panic` is ambiguous
2+
--> $DIR/ambiguous-panic-no-implicit-prelude.rs:15:5
3+
|
4+
LL | panic!();
5+
| ^^^^^ ambiguous name
6+
|
7+
= note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
8+
note: `panic` could refer to the macro imported here
9+
--> $DIR/ambiguous-panic-no-implicit-prelude.rs:14:9
10+
|
11+
LL | use m1::*;
12+
| ^^^^^
13+
= help: consider adding an explicit import of `panic` to disambiguate
14+
note: `panic` could also refer to a macro from prelude
15+
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
16+
17+
error: aborting due to 1 previous error
18+
19+
For more information about this error, try `rustc --explain E0659`.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ edition: 2024
2+
//@ check-pass
3+
#![crate_type = "lib"]
4+
5+
use ::core::*;
6+
7+
fn f() {
8+
panic!();
9+
//~^ WARN: `panic` is ambiguous [ambiguous_panic_imports]
10+
//~| WARN: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
11+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
warning: `panic` is ambiguous
2+
--> $DIR/ambiguous-panic-non-prelude-core-glob.rs:8:5
3+
|
4+
LL | panic!();
5+
| ^^^^^ ambiguous name
6+
|
7+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8+
= note: for more information, see issue #147319 <https://github.com/rust-lang/rust/issues/147319>
9+
= note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
10+
note: `panic` could refer to the macro imported here
11+
--> $DIR/ambiguous-panic-non-prelude-core-glob.rs:5:5
12+
|
13+
LL | use ::core::*;
14+
| ^^^^^^^^^
15+
= help: consider adding an explicit import of `panic` to disambiguate
16+
= help: or use `crate::panic` to refer to this macro unambiguously
17+
note: `panic` could also refer to a macro from prelude
18+
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
19+
= note: `#[warn(ambiguous_panic_imports)]` (part of `#[warn(future_incompatible)]`) on by default
20+
21+
warning: 1 warning emitted
22+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ check-pass
2+
#![crate_type = "lib"]
3+
#![no_std]
4+
5+
extern crate std;
6+
use ::std::*;
7+
8+
fn f() {
9+
panic!();
10+
//~^ WARN: `panic` is ambiguous [ambiguous_panic_imports]
11+
//~| WARN: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
12+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
warning: `panic` is ambiguous
2+
--> $DIR/ambiguous-panic-non-prelude-std-glob.rs:9:5
3+
|
4+
LL | panic!();
5+
| ^^^^^ ambiguous name
6+
|
7+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8+
= note: for more information, see issue #147319 <https://github.com/rust-lang/rust/issues/147319>
9+
= note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
10+
note: `panic` could refer to the macro imported here
11+
--> $DIR/ambiguous-panic-non-prelude-std-glob.rs:6:5
12+
|
13+
LL | use ::std::*;
14+
| ^^^^^^^^
15+
= help: consider adding an explicit import of `panic` to disambiguate
16+
= help: or use `crate::panic` to refer to this macro unambiguously
17+
note: `panic` could also refer to a macro from prelude
18+
--> $SRC_DIR/core/src/prelude/mod.rs:LL:COL
19+
= note: `#[warn(ambiguous_panic_imports)]` (part of `#[warn(future_incompatible)]`) on by default
20+
21+
warning: 1 warning emitted
22+

0 commit comments

Comments
 (0)