Skip to content

Commit 613ef6e

Browse files
authored
Rollup merge of rust-lang#62819 - crlf0710:update_libtest, r=oli-obk
Display name of crate requiring rustc_private in error messages. This is extraction and rebase of one part of rust-lang#59440 that doesn't involve external things. r? @oli-obk
2 parents 1a550d5 + 6a26b80 commit 613ef6e

9 files changed

+72
-12
lines changed

src/librustc/middle/stability.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,15 @@ impl<'tcx> Index<'tcx> {
431431
// while maintaining the invariant that all sysroot crates are unstable
432432
// by default and are unable to be used.
433433
if tcx.sess.opts.debugging_opts.force_unstable_if_unmarked {
434-
let reason = "this crate is being loaded from the sysroot, an \
435-
unstable location; did you mean to load this crate \
436-
from crates.io via `Cargo.toml` instead?";
434+
let reason = format!(
435+
"crate \"{}\" is being loaded from the sysroot, an \
436+
unstable location; did you mean to load this crate \
437+
from crates.io via `Cargo.toml` instead?",
438+
tcx.crate_name(LOCAL_CRATE)
439+
);
437440
let stability = tcx.intern_stability(Stability {
438441
level: attr::StabilityLevel::Unstable {
439-
reason: Some(Symbol::intern(reason)),
442+
reason: Some(Symbol::intern(&reason)),
440443
issue: 27812,
441444
},
442445
feature: sym::rustc_private,

src/libtest/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
#![unstable(feature = "test", issue = "27812")]
2323
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))]
2424
#![feature(asm)]
25-
#![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc, rustc_private))]
25+
#![feature(libc)]
26+
#![feature(rustc_private)]
2627
#![feature(nll)]
2728
#![feature(set_stdio)]
2829
#![feature(panic_unwind)]

src/test/ui-fulldeps/hash-stable-is-unstable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ use rustc_macros::HashStable;
1212

1313
#[derive(HashStable)]
1414
//~^ use of unstable library feature 'rustc_private'
15+
//~| use of unstable library feature 'rustc_private'
1516
struct Test;

src/test/ui-fulldeps/hash-stable-is-unstable.stderr

+15-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0601]: `main` function not found in crate `hash_stable_is_unstable`
22
|
33
= note: consider adding a `main` function to `$DIR/hash-stable-is-unstable.rs`
44

5-
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?
5+
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?
66
--> $DIR/hash-stable-is-unstable.rs:3:1
77
|
88
LL | extern crate rustc_data_structures;
@@ -11,7 +11,7 @@ LL | extern crate rustc_data_structures;
1111
= note: for more information, see https://github.com/rust-lang/rust/issues/27812
1212
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
1313

14-
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?
14+
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?
1515
--> $DIR/hash-stable-is-unstable.rs:5:1
1616
|
1717
LL | extern crate rustc;
@@ -20,7 +20,7 @@ LL | extern crate rustc;
2020
= note: for more information, see https://github.com/rust-lang/rust/issues/27812
2121
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
2222

23-
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?
23+
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?
2424
--> $DIR/hash-stable-is-unstable.rs:7:1
2525
|
2626
LL | extern crate rustc_macros;
@@ -29,7 +29,7 @@ LL | extern crate rustc_macros;
2929
= note: for more information, see https://github.com/rust-lang/rust/issues/27812
3030
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
3131

32-
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?
32+
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?
3333
--> $DIR/hash-stable-is-unstable.rs:10:5
3434
|
3535
LL | use rustc_macros::HashStable;
@@ -38,7 +38,7 @@ LL | use rustc_macros::HashStable;
3838
= note: for more information, see https://github.com/rust-lang/rust/issues/27812
3939
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
4040

41-
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?
41+
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?
4242
--> $DIR/hash-stable-is-unstable.rs:13:10
4343
|
4444
LL | #[derive(HashStable)]
@@ -47,7 +47,16 @@ LL | #[derive(HashStable)]
4747
= note: for more information, see https://github.com/rust-lang/rust/issues/27812
4848
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
4949

50-
error: aborting due to 6 previous errors
50+
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?
51+
--> $DIR/hash-stable-is-unstable.rs:13:10
52+
|
53+
LL | #[derive(HashStable)]
54+
| ^^^^^^^^^^
55+
|
56+
= note: for more information, see https://github.com/rust-lang/rust/issues/27812
57+
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
58+
59+
error: aborting due to 7 previous errors
5160

5261
Some errors have detailed explanations: E0601, E0658.
5362
For more information about an error, try `rustc --explain E0601`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
extern crate libc; //~ ERROR use of unstable
3+
use libc::*; //~ ERROR unresolved import
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0432]: unresolved import `libc`
2+
--> $DIR/feature-gate-rustc_private-libc.rs:3:9
3+
|
4+
LL | use libc::*;
5+
| ^^^^ maybe a missing `extern crate libc;`?
6+
7+
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?
8+
--> $DIR/feature-gate-rustc_private-libc.rs:2:5
9+
|
10+
LL | extern crate libc;
11+
| ^^^^^^^^^^^^^^^^^^
12+
|
13+
= note: for more information, see https://github.com/rust-lang/rust/issues/27812
14+
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
15+
16+
error: aborting due to 2 previous errors
17+
18+
Some errors have detailed explanations: E0432, E0658.
19+
For more information about an error, try `rustc --explain E0432`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
extern crate test; //~ ERROR use of unstable
3+
use test::*; //~ ERROR unresolved import
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0432]: unresolved import `test`
2+
--> $DIR/feature-gate-test.rs:3:9
3+
|
4+
LL | use test::*;
5+
| ^^^^ maybe a missing `extern crate test;`?
6+
7+
error[E0658]: use of unstable library feature 'test'
8+
--> $DIR/feature-gate-test.rs:2:5
9+
|
10+
LL | extern crate test;
11+
| ^^^^^^^^^^^^^^^^^^
12+
|
13+
= note: for more information, see https://github.com/rust-lang/rust/issues/27812
14+
= help: add `#![feature(test)]` to the crate attributes to enable
15+
16+
error: aborting due to 2 previous errors
17+
18+
Some errors have detailed explanations: E0432, E0658.
19+
For more information about an error, try `rustc --explain E0432`.

src/test/ui/issues/issue-37887.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0432]: unresolved import `libc`
44
LL | use libc::*;
55
| ^^^^ maybe a missing `extern crate libc;`?
66

7-
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?
7+
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?
88
--> $DIR/issue-37887.rs:2:5
99
|
1010
LL | extern crate libc;

0 commit comments

Comments
 (0)