Skip to content

Commit b9db639

Browse files
authored
Rollup merge of #132544 - dianne:unstable-library-feature-backticks, r=compiler-errors
Use backticks instead of single quotes for library feature names in diagnostics This PR changes the text of library feature errors for using unstable or body-unstable items. Displaying library feature names in backticks is consistent with other diagnostics (e.g. those from `rustc_passes`) and with the `reason`s on unstable attributes in the library. Additionally, this simplifies diagnostics when supporting multiple unstable attributes on items (see #131824) since `DiagSymbolList` also displays symbols using backticks.
2 parents c89a6cd + ae42814 commit b9db639

File tree

113 files changed

+433
-431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+433
-431
lines changed

compiler/rustc_hir_analysis/messages.ftl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ hir_analysis_missing_trait_item_suggestion = implement the missing item: `{$snip
311311
312312
hir_analysis_missing_trait_item_unstable = not all trait items implemented, missing: `{$missing_item_name}`
313313
.note = default implementation of `{$missing_item_name}` is unstable
314-
.some_note = use of unstable library feature '{$feature}': {$reason}
315-
.none_note = use of unstable library feature '{$feature}'
314+
.some_note = use of unstable library feature `{$feature}`: {$reason}
315+
.none_note = use of unstable library feature `{$feature}`
316316
317317
hir_analysis_missing_type_params =
318318
the type {$parameterCount ->

compiler/rustc_middle/src/middle/stability.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ pub fn report_unstable(
112112
soft_handler: impl FnOnce(&'static Lint, Span, String),
113113
) {
114114
let msg = match reason {
115-
Some(r) => format!("use of unstable library feature '{feature}': {r}"),
116-
None => format!("use of unstable library feature '{feature}'"),
115+
Some(r) => format!("use of unstable library feature `{feature}`: {r}"),
116+
None => format!("use of unstable library feature `{feature}`"),
117117
};
118118

119119
if is_soft {

tests/ui-fulldeps/hash-stable-is-unstable.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1+
//@ ignore-stage1 FIXME: this line can be removed once these new error messages are in stage 0 rustc
12
//@ compile-flags: -Zdeduplicate-diagnostics=yes
23
extern crate rustc_data_structures;
3-
//~^ use of unstable library feature 'rustc_private'
4+
//~^ use of unstable library feature `rustc_private`
45
//~| NOTE: issue #27812 <https://github.com/rust-lang/rust/issues/27812> for more information
56
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
67
extern crate rustc_macros;
7-
//~^ use of unstable library feature 'rustc_private'
8+
//~^ use of unstable library feature `rustc_private`
89
//~| NOTE: see issue #27812 <https://github.com/rust-lang/rust/issues/27812> for more information
910
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1011
extern crate rustc_query_system;
11-
//~^ use of unstable library feature 'rustc_private'
12+
//~^ use of unstable library feature `rustc_private`
1213
//~| NOTE: see issue #27812 <https://github.com/rust-lang/rust/issues/27812> for more information
1314
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1415

1516
use rustc_macros::HashStable;
16-
//~^ use of unstable library feature 'rustc_private'
17+
//~^ use of unstable library feature `rustc_private`
1718
//~| NOTE: see issue #27812 <https://github.com/rust-lang/rust/issues/27812> for more information
1819
//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1920

2021
#[derive(HashStable)]
21-
//~^ use of unstable library feature 'rustc_private'
22+
//~^ use of unstable library feature `rustc_private`
2223
//~| NOTE: in this expansion of #[derive(HashStable)]
2324
//~| NOTE: in this expansion of #[derive(HashStable)]
2425
//~| NOTE: in this expansion of #[derive(HashStable)]

tests/ui-fulldeps/hash-stable-is-unstable.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
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?
2-
--> $DIR/hash-stable-is-unstable.rs:2:1
1+
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?
2+
--> $DIR/hash-stable-is-unstable.rs:3:1
33
|
44
LL | extern crate rustc_data_structures;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,8 +8,8 @@ LL | extern crate rustc_data_structures;
88
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

11-
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?
12-
--> $DIR/hash-stable-is-unstable.rs:6:1
11+
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?
12+
--> $DIR/hash-stable-is-unstable.rs:7:1
1313
|
1414
LL | extern crate rustc_macros;
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -18,8 +18,8 @@ LL | extern crate rustc_macros;
1818
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
1919
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
2020

21-
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?
22-
--> $DIR/hash-stable-is-unstable.rs:10:1
21+
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?
22+
--> $DIR/hash-stable-is-unstable.rs:11:1
2323
|
2424
LL | extern crate rustc_query_system;
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -28,8 +28,8 @@ LL | extern crate rustc_query_system;
2828
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
2929
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
3030

31-
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-
--> $DIR/hash-stable-is-unstable.rs:15:5
31+
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+
--> $DIR/hash-stable-is-unstable.rs:16:5
3333
|
3434
LL | use rustc_macros::HashStable;
3535
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -38,8 +38,8 @@ LL | use rustc_macros::HashStable;
3838
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
3939
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
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?
42-
--> $DIR/hash-stable-is-unstable.rs:20:10
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?
42+
--> $DIR/hash-stable-is-unstable.rs:21:10
4343
|
4444
LL | #[derive(HashStable)]
4545
| ^^^^^^^^^^
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
//@ ignore-stage1 FIXME: this line can be removed once these new error messages are in stage 0 rustc
12
//@ edition:2018
23
//@ compile-flags:--extern rustc_middle
34

45
// Test that `--extern rustc_middle` fails with `rustc_private`.
56

67
pub use rustc_middle;
7-
//~^ ERROR use of unstable library feature 'rustc_private'
8+
//~^ ERROR use of unstable library feature `rustc_private`
89

910
fn main() {}

tests/ui-fulldeps/pathless-extern-unstable.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
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?
2-
--> $DIR/pathless-extern-unstable.rs:6:9
1+
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?
2+
--> $DIR/pathless-extern-unstable.rs:7:9
33
|
44
LL | pub use rustc_middle;
55
| ^^^^^^^^^^^^

tests/ui/associated-inherent-types/assoc-inherent-unstable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
#![feature(inherent_associated_types)]
55
#![allow(incomplete_features)]
66

7-
type Data = aux::Owner::Data; //~ ERROR use of unstable library feature 'data'
7+
type Data = aux::Owner::Data; //~ ERROR use of unstable library feature `data`
88

99
fn main() {}

tests/ui/associated-inherent-types/assoc-inherent-unstable.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0658]: use of unstable library feature 'data'
1+
error[E0658]: use of unstable library feature `data`
22
--> $DIR/assoc-inherent-unstable.rs:7:13
33
|
44
LL | type Data = aux::Owner::Data;

tests/ui/async-await/async-fn/edition-2015.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ fn foo(x: impl async Fn()) -> impl async Fn() { x }
33
//~| ERROR `async` trait bounds are only allowed in Rust 2018 or later
44
//~| ERROR async closures are unstable
55
//~| ERROR async closures are unstable
6-
//~| ERROR use of unstable library feature 'async_closure'
7-
//~| ERROR use of unstable library feature 'async_closure'
6+
//~| ERROR use of unstable library feature `async_closure`
7+
//~| ERROR use of unstable library feature `async_closure`
88

99
fn main() {}

tests/ui/async-await/async-fn/edition-2015.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
3838
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
3939
= help: to use an async block, remove the `||`: `async {`
4040

41-
error[E0658]: use of unstable library feature 'async_closure'
41+
error[E0658]: use of unstable library feature `async_closure`
4242
--> $DIR/edition-2015.rs:1:42
4343
|
4444
LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
@@ -48,7 +48,7 @@ LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
4848
= help: add `#![feature(async_closure)]` to the crate attributes to enable
4949
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
5050

51-
error[E0658]: use of unstable library feature 'async_closure'
51+
error[E0658]: use of unstable library feature `async_closure`
5252
--> $DIR/edition-2015.rs:1:22
5353
|
5454
LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }

0 commit comments

Comments
 (0)