Skip to content

Commit d4934c7

Browse files
committed
Add a couple more tests
1 parent 1af682a commit d4934c7

3 files changed

+33
-3
lines changed

src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs

+9
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,13 @@ mod m {
1414
}
1515
}
1616

17+
macro_rules! define_other_core {
18+
() => {
19+
extern crate std as core;
20+
//~^ ERROR macro-expanded `extern crate` items cannot shadow names passed with `--extern`
21+
}
22+
}
23+
24+
define_other_core!();
25+
1726
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
1+
error: macro-expanded `extern crate` items cannot shadow names passed with `--extern`
2+
--> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:19:9
3+
|
4+
LL | extern crate std as core;
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
6+
...
7+
LL | define_other_core!();
8+
| --------------------- in this macro invocation
9+
110
error[E0659]: `Vec` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
2-
--> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:15:9
11+
--> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:13:9
312
|
413
LL | Vec::panic!(); //~ ERROR `Vec` is ambiguous
514
| ^^^ ambiguous name
615
|
716
= note: `Vec` could refer to a struct from prelude
817
note: `Vec` could also refer to the extern crate imported here
9-
--> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:7:9
18+
--> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:5:9
1019
|
1120
LL | extern crate std as Vec;
1221
| ^^^^^^^^^^^^^^^^^^^^^^^^
1322
...
1423
LL | define_vec!();
1524
| -------------- in this macro invocation
1625

17-
error: aborting due to previous error
26+
error: aborting due to 2 previous errors
1827

1928
For more information about this error, try `rustc --explain E0659`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// compile-pass
2+
// aux-build:two_macros.rs
3+
4+
extern crate two_macros as core;
5+
6+
mod m {
7+
fn check() {
8+
core::m!(); // OK
9+
}
10+
}
11+
12+
fn main() {}

0 commit comments

Comments
 (0)