about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-10-24 01:03:47 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-10-24 01:33:35 +0300
commitd1e337bded30b84df777f6de3d8fc588286f0834 (patch)
treecad542c2482fd9a4480f24a76437f4df57cbb08e /src/test
parent7976aa32a97335f8f15dd70ce3f67adea595dd46 (diff)
downloadrust-d1e337bded30b84df777f6de3d8fc588286f0834.tar.gz
rust-d1e337bded30b84df777f6de3d8fc588286f0834.zip
Prohibit macro-expanded `extern crate` items shadowing crates passed with `--extern`
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/feature-gates/feature-gate-extern_crate_item_prelude.rs7
-rw-r--r--src/test/ui/feature-gates/feature-gate-extern_crate_item_prelude.stderr10
-rw-r--r--src/test/ui/imports/extern-prelude-extern-crate-fail.rs9
-rw-r--r--src/test/ui/imports/extern-prelude-extern-crate-fail.stderr13
4 files changed, 36 insertions, 3 deletions
diff --git a/src/test/ui/feature-gates/feature-gate-extern_crate_item_prelude.rs b/src/test/ui/feature-gates/feature-gate-extern_crate_item_prelude.rs
index eb7c52c3d0f..a043b6c2e61 100644
--- a/src/test/ui/feature-gates/feature-gate-extern_crate_item_prelude.rs
+++ b/src/test/ui/feature-gates/feature-gate-extern_crate_item_prelude.rs
@@ -36,4 +36,11 @@ mod import_absolute {
     //~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
 }
 
+extern crate alloc as core;
+
+mod unrelated_crate_renamed {
+    type A = core::boxed::Box<u8>;
+    //~^ ERROR use of extern prelude names introduced with `extern crate` items is unstable
+}
+
 fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-extern_crate_item_prelude.stderr b/src/test/ui/feature-gates/feature-gate-extern_crate_item_prelude.stderr
index 4dec8a35bca..cabfb56d7a8 100644
--- a/src/test/ui/feature-gates/feature-gate-extern_crate_item_prelude.stderr
+++ b/src/test/ui/feature-gates/feature-gate-extern_crate_item_prelude.stderr
@@ -62,6 +62,14 @@ LL |         type A = ::alloc::boxed::Box<u8>;
    |
    = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
 
-error: aborting due to 8 previous errors
+error[E0658]: use of extern prelude names introduced with `extern crate` items is unstable (see issue #54658)
+  --> $DIR/feature-gate-extern_crate_item_prelude.rs:42:14
+   |
+LL |     type A = core::boxed::Box<u8>;
+   |              ^^^^
+   |
+   = help: add #![feature(extern_crate_item_prelude)] to the crate attributes to enable
+
+error: aborting due to 9 previous errors
 
 For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/imports/extern-prelude-extern-crate-fail.rs b/src/test/ui/imports/extern-prelude-extern-crate-fail.rs
index 22248af6d3a..57b097c9df3 100644
--- a/src/test/ui/imports/extern-prelude-extern-crate-fail.rs
+++ b/src/test/ui/imports/extern-prelude-extern-crate-fail.rs
@@ -1,4 +1,5 @@
 // aux-build:two_macros.rs
+// compile-flags:--extern non_existent
 
 mod n {
     extern crate two_macros;
@@ -10,4 +11,12 @@ mod m {
     }
 }
 
+macro_rules! define_std_as_non_existent {
+    () => {
+        extern crate std as non_existent;
+        //~^ ERROR `extern crate` items cannot shadow names passed with `--extern`
+    }
+}
+define_std_as_non_existent!();
+
 fn main() {}
diff --git a/src/test/ui/imports/extern-prelude-extern-crate-fail.stderr b/src/test/ui/imports/extern-prelude-extern-crate-fail.stderr
index 464812f1f69..8f68d2af34c 100644
--- a/src/test/ui/imports/extern-prelude-extern-crate-fail.stderr
+++ b/src/test/ui/imports/extern-prelude-extern-crate-fail.stderr
@@ -1,9 +1,18 @@
+error: macro-expanded `extern crate` items cannot shadow names passed with `--extern`
+  --> $DIR/extern-prelude-extern-crate-fail.rs:16:9
+   |
+LL |         extern crate std as non_existent;
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+...
+LL | define_std_as_non_existent!();
+   | ------------------------------ in this macro invocation
+
 error[E0433]: failed to resolve. Use of undeclared type or module `two_macros`
-  --> $DIR/extern-prelude-extern-crate-fail.rs:9:9
+  --> $DIR/extern-prelude-extern-crate-fail.rs:10:9
    |
 LL |         two_macros::m!(); //~ ERROR failed to resolve. Use of undeclared type or module `two_macros`
    |         ^^^^^^^^^^ Use of undeclared type or module `two_macros`
 
-error: aborting due to previous error
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0433`.