]> git.lizzy.rs Git - rust.git/commitdiff
Add a couple more tests
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Tue, 20 Nov 2018 22:28:07 +0000 (01:28 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Tue, 20 Nov 2018 22:28:07 +0000 (01:28 +0300)
src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.rs
src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr
src/test/ui/imports/extern-prelude-extern-crate-shadowing.rs [new file with mode: 0644]

index 3eefaf1267e88e1e52fc23546564a4cf5f44c4d7..6ff3ab73639c0bec32db8ef41797a66fa84beb8e 100644 (file)
@@ -14,4 +14,13 @@ fn check() {
     }
 }
 
+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() {}
index 218dfb796f77ad3964915b2a834875a4c48b00bf..795e1761ccdb3e097ca9b11542f28953e45c0443 100644 (file)
@@ -1,12 +1,21 @@
+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;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -14,6 +23,6 @@ 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`.
diff --git a/src/test/ui/imports/extern-prelude-extern-crate-shadowing.rs b/src/test/ui/imports/extern-prelude-extern-crate-shadowing.rs
new file mode 100644 (file)
index 0000000..c5adeaf
--- /dev/null
@@ -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() {}