diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 5ab762ab225f9..704a764f58936 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -431,12 +431,15 @@ impl<'tcx> Index<'tcx> { // while maintaining the invariant that all sysroot crates are unstable // by default and are unable to be used. if tcx.sess.opts.debugging_opts.force_unstable_if_unmarked { - let reason = "this crate is being loaded from the sysroot, an \ - unstable location; did you mean to load this crate \ - from crates.io via `Cargo.toml` instead?"; + let reason = format!( + "crate \"{}\" is being loaded from the sysroot, an \ + unstable location; did you mean to load this crate \ + from crates.io via `Cargo.toml` instead?", + tcx.crate_name(LOCAL_CRATE) + ); let stability = tcx.intern_stability(Stability { level: attr::StabilityLevel::Unstable { - reason: Some(Symbol::intern(reason)), + reason: Some(Symbol::intern(&reason)), issue: 27812, }, feature: sym::rustc_private, diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index fa45c9d7d9d79..c702de7e41cc6 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -22,7 +22,8 @@ #![unstable(feature = "test", issue = "27812")] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))] #![feature(asm)] -#![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc, rustc_private))] +#![feature(libc)] +#![feature(rustc_private)] #![feature(nll)] #![feature(set_stdio)] #![feature(panic_unwind)] diff --git a/src/test/ui-fulldeps/hash-stable-is-unstable.rs b/src/test/ui-fulldeps/hash-stable-is-unstable.rs index 9f67f642df1ce..448184757fe16 100644 --- a/src/test/ui-fulldeps/hash-stable-is-unstable.rs +++ b/src/test/ui-fulldeps/hash-stable-is-unstable.rs @@ -12,4 +12,5 @@ use rustc_macros::HashStable; #[derive(HashStable)] //~^ use of unstable library feature 'rustc_private' +//~| use of unstable library feature 'rustc_private' struct Test; diff --git a/src/test/ui-fulldeps/hash-stable-is-unstable.stderr b/src/test/ui-fulldeps/hash-stable-is-unstable.stderr index 02056d30eae9c..9f1ef4d985c8a 100644 --- a/src/test/ui-fulldeps/hash-stable-is-unstable.stderr +++ b/src/test/ui-fulldeps/hash-stable-is-unstable.stderr @@ -2,7 +2,7 @@ error[E0601]: `main` function not found in crate `hash_stable_is_unstable` | = note: consider adding a `main` function to `$DIR/hash-stable-is-unstable.rs` -error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? +error[E0658]: use of unstable library feature 'rustc_private': crate "rustc_data_structures" is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? --> $DIR/hash-stable-is-unstable.rs:3:1 | LL | extern crate rustc_data_structures; @@ -11,7 +11,7 @@ LL | extern crate rustc_data_structures; = note: for more information, see https://github.com/rust-lang/rust/issues/27812 = help: add `#![feature(rustc_private)]` to the crate attributes to enable -error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? +error[E0658]: use of unstable library feature 'rustc_private': crate "rustc" is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? --> $DIR/hash-stable-is-unstable.rs:5:1 | LL | extern crate rustc; @@ -20,7 +20,7 @@ LL | extern crate rustc; = note: for more information, see https://github.com/rust-lang/rust/issues/27812 = help: add `#![feature(rustc_private)]` to the crate attributes to enable -error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? +error[E0658]: use of unstable library feature 'rustc_private': crate "rustc_macros" is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? --> $DIR/hash-stable-is-unstable.rs:7:1 | LL | extern crate rustc_macros; @@ -29,7 +29,7 @@ LL | extern crate rustc_macros; = note: for more information, see https://github.com/rust-lang/rust/issues/27812 = help: add `#![feature(rustc_private)]` to the crate attributes to enable -error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? +error[E0658]: use of unstable library feature 'rustc_private': crate "rustc_macros" is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? --> $DIR/hash-stable-is-unstable.rs:10:5 | LL | use rustc_macros::HashStable; @@ -38,7 +38,7 @@ LL | use rustc_macros::HashStable; = note: for more information, see https://github.com/rust-lang/rust/issues/27812 = help: add `#![feature(rustc_private)]` to the crate attributes to enable -error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? +error[E0658]: use of unstable library feature 'rustc_private': crate "rustc_data_structures" is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? --> $DIR/hash-stable-is-unstable.rs:13:10 | LL | #[derive(HashStable)] @@ -47,7 +47,16 @@ LL | #[derive(HashStable)] = note: for more information, see https://github.com/rust-lang/rust/issues/27812 = help: add `#![feature(rustc_private)]` to the crate attributes to enable -error: aborting due to 6 previous errors +error[E0658]: use of unstable library feature 'rustc_private': crate "rustc" is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? + --> $DIR/hash-stable-is-unstable.rs:13:10 + | +LL | #[derive(HashStable)] + | ^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/27812 + = help: add `#![feature(rustc_private)]` to the crate attributes to enable + +error: aborting due to 7 previous errors Some errors have detailed explanations: E0601, E0658. For more information about an error, try `rustc --explain E0601`. diff --git a/src/test/ui/feature-gates/feature-gate-rustc_private-libc.rs b/src/test/ui/feature-gates/feature-gate-rustc_private-libc.rs new file mode 100644 index 0000000000000..58f0c6b651ad6 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-rustc_private-libc.rs @@ -0,0 +1,4 @@ +fn main() { + extern crate libc; //~ ERROR use of unstable + use libc::*; //~ ERROR unresolved import +} diff --git a/src/test/ui/feature-gates/feature-gate-rustc_private-libc.stderr b/src/test/ui/feature-gates/feature-gate-rustc_private-libc.stderr new file mode 100644 index 0000000000000..c686a6b141f82 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-rustc_private-libc.stderr @@ -0,0 +1,19 @@ +error[E0432]: unresolved import `libc` + --> $DIR/feature-gate-rustc_private-libc.rs:3:9 + | +LL | use libc::*; + | ^^^^ maybe a missing `extern crate libc;`? + +error[E0658]: use of unstable library feature 'rustc_private': crate "libc" is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? + --> $DIR/feature-gate-rustc_private-libc.rs:2:5 + | +LL | extern crate libc; + | ^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/27812 + = help: add `#![feature(rustc_private)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0432, E0658. +For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/feature-gates/feature-gate-test.rs b/src/test/ui/feature-gates/feature-gate-test.rs new file mode 100644 index 0000000000000..919f46d34c6d9 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-test.rs @@ -0,0 +1,4 @@ +fn main() { + extern crate test; //~ ERROR use of unstable + use test::*; //~ ERROR unresolved import +} diff --git a/src/test/ui/feature-gates/feature-gate-test.stderr b/src/test/ui/feature-gates/feature-gate-test.stderr new file mode 100644 index 0000000000000..569f285edb26d --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-test.stderr @@ -0,0 +1,19 @@ +error[E0432]: unresolved import `test` + --> $DIR/feature-gate-test.rs:3:9 + | +LL | use test::*; + | ^^^^ maybe a missing `extern crate test;`? + +error[E0658]: use of unstable library feature 'test' + --> $DIR/feature-gate-test.rs:2:5 + | +LL | extern crate test; + | ^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/27812 + = help: add `#![feature(test)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0432, E0658. +For more information about an error, try `rustc --explain E0432`. diff --git a/src/test/ui/issues/issue-37887.stderr b/src/test/ui/issues/issue-37887.stderr index b1b9754523f67..67f3a795761bb 100644 --- a/src/test/ui/issues/issue-37887.stderr +++ b/src/test/ui/issues/issue-37887.stderr @@ -4,7 +4,7 @@ error[E0432]: unresolved import `libc` LL | use libc::*; | ^^^^ maybe a missing `extern crate libc;`? -error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? +error[E0658]: use of unstable library feature 'rustc_private': crate "libc" is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead? --> $DIR/issue-37887.rs:2:5 | LL | extern crate libc;