Skip to content

Commit

Permalink
Add a couple more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Nov 20, 2018
1 parent 1af682a commit d4934c7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,13 @@ mod m {
}
}

macro_rules! define_other_core {
() => {
extern crate std as core;
//~^ ERROR macro-expanded `extern crate` items cannot shadow names passed with `--extern`
}
}

define_other_core!();

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
error: macro-expanded `extern crate` items cannot shadow names passed with `--extern`
--> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:19:9
|
LL | extern crate std as core;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | define_other_core!();
| --------------------- in this macro invocation

error[E0659]: `Vec` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
--> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:15:9
--> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:13:9
|
LL | Vec::panic!(); //~ ERROR `Vec` is ambiguous
| ^^^ ambiguous name
|
= note: `Vec` could refer to a struct from prelude
note: `Vec` could also refer to the extern crate imported here
--> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:7:9
--> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:5:9
|
LL | extern crate std as Vec;
| ^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | define_vec!();
| -------------- in this macro invocation

error: aborting due to previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0659`.
12 changes: 12 additions & 0 deletions src/test/ui/imports/extern-prelude-extern-crate-shadowing.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// compile-pass
// aux-build:two_macros.rs

extern crate two_macros as core;

mod m {
fn check() {
core::m!(); // OK
}
}

fn main() {}

0 comments on commit d4934c7

Please sign in to comment.