Skip to content

Commit 1209891

Browse files
committed
Convert unknown_features lint into an error
1 parent 47619c0 commit 1209891

File tree

218 files changed

+247
-575
lines changed

Some content is hidden

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

218 files changed

+247
-575
lines changed

src/librustc/diagnostics.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,6 +1918,17 @@ fn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {
19181918
```
19191919
"##,
19201920

1921+
E0635: r##"
1922+
The `#![feature]` attribute specified an unknown feature.
1923+
1924+
Erroneous code example:
1925+
1926+
```compile_fail,E0635
1927+
#![feature(nonexistent_rust_feature)] // error: unknown feature
1928+
```
1929+
1930+
"##,
1931+
19211932
E0636: r##"
19221933
A `#![feature]` attribute was declared multiple times.
19231934

src/librustc/lint/builtin.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,6 @@ declare_lint! {
105105
"unused features found in crate-level #[feature] directives"
106106
}
107107

108-
declare_lint! {
109-
pub UNKNOWN_FEATURES,
110-
Deny,
111-
"unknown features found in crate-level #[feature] directives"
112-
}
113-
114108
declare_lint! {
115109
pub STABLE_FEATURES,
116110
Warn,
@@ -368,7 +362,6 @@ impl LintPass for HardwiredLints {
368362
UNUSED_MACROS,
369363
WARNINGS,
370364
UNUSED_FEATURES,
371-
UNKNOWN_FEATURES,
372365
STABLE_FEATURES,
373366
UNKNOWN_CRATE_TYPES,
374367
TRIVIAL_CASTS,

src/librustc/middle/stability.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,10 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
840840
// FIXME(varkor): we don't properly handle lib features behind `cfg` attributes yet,
841841
// but it happens just to affect `libc`, so we're just going to hard-code it for now.
842842
remaining_lib_features.remove(&Symbol::intern("libc"));
843+
// FIXME(varkor): we have a problem gathering features on macros right now, so we're
844+
// going to hard-code some features here for now.
845+
remaining_lib_features.remove(&Symbol::intern("await_macro"));
846+
remaining_lib_features.remove(&Symbol::intern("unstable_macros"));
843847

844848
for (feature, stable) in tcx.lib_features().iter() {
845849
if let Some(since) = stable {
@@ -852,10 +856,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
852856
}
853857

854858
for (feature, span) in remaining_lib_features {
855-
tcx.lint_node(lint::builtin::UNKNOWN_FEATURES,
856-
ast::CRATE_NODE_ID,
857-
span,
858-
&format!("unknown feature `{}`", feature));
859+
struct_span_err!(tcx.sess, span, E0635, "unknown feature `{}`", feature).emit();
859860
}
860861

861862
// FIXME(#44232): the `used_features` table no longer exists, so we

src/librustc_lint/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
188188
UNUSED_DOC_COMMENTS,
189189
UNUSED_EXTERN_CRATES,
190190
UNUSED_FEATURES,
191-
UNKNOWN_FEATURES,
192191
UNUSED_LABELS,
193192
UNUSED_PARENS);
194193

@@ -343,6 +342,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
343342
store.register_renamed("bare_trait_object", "bare_trait_objects");
344343
store.register_renamed("unstable_name_collision", "unstable_name_collisions");
345344
store.register_renamed("unused_doc_comment", "unused_doc_comments");
345+
store.register_removed("unknown_features", "replaced by an error");
346346
store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");
347347
store.register_removed("negate_unsigned", "cast a signed value instead");
348348
store.register_removed("raw_pointer_derive", "using derive with raw pointers is ok");

src/libsyntax/diagnostic_list.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -374,18 +374,6 @@ and likely to change in the future.
374374
375375
"##,
376376

377-
E0635: r##"
378-
The `#![feature]` attribute specified an unknown feature.
379-
380-
Erroneous code example:
381-
382-
```compile_fail,E0635
383-
#![feature(nonexistent_rust_feature)] // error: unknown feature
384-
```
385-
386-
"##,
387-
388-
389377
}
390378

391379
register_diagnostics! {

src/libsyntax/feature_gate.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ declare_features! (
140140
(active, linkage, "1.0.0", Some(29603), None),
141141
(active, quote, "1.0.0", Some(29601), None),
142142

143-
144143
// rustc internal
145144
(active, rustc_diagnostic_macros, "1.0.0", None, None),
146145
(active, rustc_const_unstable, "1.0.0", None, None),

src/test/compile-fail/lint-renamed-allow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313

1414
#![allow(renamed_and_removed_lints)]
1515

16-
#[deny(unknown_features)]
16+
#[deny(single_use_lifetime)]
1717
#[deny(unused)]
1818
fn main() { let unused = (); } //~ ERROR unused

src/test/compile-fail/lint-unknown-feature-default.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
// Tests the default for the unused_features lint
1212

13+
#![allow(stable_features)]
1314
// FIXME(#44232) we should warn that this isn't used.
14-
#![feature(this_is_not_a_feature)]
15+
#![feature(rust1)]
1516

1617
#![feature(rustc_attrs)]
1718

src/test/compile-fail/lint-unknown-feature.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
#![warn(unused_features)]
1212

13+
#![allow(stable_features)]
1314
// FIXME(#44232) we should warn that this isn't used.
14-
#![feature(this_is_not_a_feature)]
15+
#![feature(rust1)]
1516

1617
#![feature(rustc_attrs)]
1718

src/test/run-fail/args-panic.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
// error-pattern:meep
1313

14-
#![allow(unknown_features)]
1514
#![feature(box_syntax)]
1615

1716
fn f(_a: isize, _b: isize, _c: Box<isize>) {

0 commit comments

Comments
 (0)