Skip to content

Commit 6fa140b

Browse files
committed
extended information for E0554 feature attributes only work on nightlies
It's more pleasing to use the inner-attribute syntax (`#!` rather than `#`) in the error message, as that is how `feature` attributes in particular will be declared (as they apply to the entire crate).
1 parent 78d1442 commit 6fa140b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/libsyntax/diagnostic_list.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,21 @@ For more information about the cfg attribute, read:
162162
https://doc.rust-lang.org/reference.html#conditional-compilation
163163
"##,
164164

165+
E0554: r##"
166+
Feature attributes are only allowed on the nightly release channel. Stable or
167+
beta compilers will not comply.
168+
169+
Example of erroneous code (on a stable compiler):
170+
171+
```ignore (depends on release channel)
172+
#![feature(non_ascii_idents)] // error: #![feature] may not be used on the
173+
// stable release channel
174+
```
175+
176+
If you need the feature, make sure to use a nightly release of the compiler
177+
(but be warned that the feature may be removed or altered in the future).
178+
"##,
179+
165180
E0558: r##"
166181
The `export_name` attribute was malformed.
167182
@@ -301,7 +316,6 @@ register_diagnostics! {
301316
E0550, // multiple deprecated attributes
302317
E0551, // incorrect meta item
303318
E0552, // unrecognized representation hint
304-
E0554, // #[feature] may not be used on the [] release channel
305319
E0555, // malformed feature attribute, expected #![feature(...)]
306320
E0556, // malformed feature, expected just one word
307321
E0557, // feature has been removed

src/libsyntax/feature_gate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,7 @@ fn maybe_stage_features(span_handler: &Handler, krate: &ast::Crate,
16021602
if attr.check_name("feature") {
16031603
let release_channel = option_env!("CFG_RELEASE_CHANNEL").unwrap_or("(unknown)");
16041604
span_err!(span_handler, attr.span, E0554,
1605-
"#[feature] may not be used on the {} release channel",
1605+
"#![feature] may not be used on the {} release channel",
16061606
release_channel);
16071607
}
16081608
}

0 commit comments

Comments
 (0)