diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-02-06 05:41:13 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-02-06 16:21:11 +0530 |
| commit | 8e4c00b939b0c7586571d33c34bf9445fef6aa3b (patch) | |
| tree | 89ef8898c2e1ccc763dd12d3f8ca161b8abb4397 /src/libsyntax/feature_gate.rs | |
| parent | 6c28ad61a20f8c50b73ca9a6b4308acb62acdf2c (diff) | |
| parent | 456d23e73ee5d8c22b67336061ed7b457742d7ff (diff) | |
| download | rust-8e4c00b939b0c7586571d33c34bf9445fef6aa3b.tar.gz rust-8e4c00b939b0c7586571d33c34bf9445fef6aa3b.zip | |
Rollup merge of #21958 - brson:stable-features, r=alexcrichton
.... The 'stable_features' lint helps people progress from unstable to stable Rust by telling them when they no longer need a `feature` attribute because upstream Rust has declared it stable. This compares to the existing 'unstable_features' lint, which is used to implement feature staging, and triggers on *any* use of `#[feature]`.
Diffstat (limited to 'src/libsyntax/feature_gate.rs')
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 96151815d07..a93ddbb2379 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -149,7 +149,10 @@ pub struct Features { pub old_orphan_check: bool, pub simd_ffi: bool, pub unmarked_api: bool, - pub lib_features: Vec<(InternedString, Span)> + /// spans of #![feature] attrs for stable language features. for error reporting + pub declared_stable_lang_features: Vec<Span>, + /// #![feature] attrs for non-language (library) features + pub declared_lib_features: Vec<(InternedString, Span)> } impl Features { @@ -162,7 +165,8 @@ impl Features { old_orphan_check: false, simd_ffi: false, unmarked_api: false, - lib_features: Vec::new() + declared_stable_lang_features: Vec::new(), + declared_lib_features: Vec::new() } } } @@ -511,6 +515,7 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::C cm: cm, }; + let mut accepted_features = Vec::new(); let mut unknown_features = Vec::new(); for attr in &krate.attrs { @@ -550,8 +555,7 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::C span_handler.span_err(mi.span, "feature has been removed"); } Some(&(_, _, Accepted)) => { - span_handler.span_warn(mi.span, "feature has been added to Rust, \ - directive not necessary"); + accepted_features.push(mi.span); } None => { unknown_features.push((name, mi.span)); @@ -572,7 +576,8 @@ fn check_crate_inner<F>(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::C old_orphan_check: cx.has_feature("old_orphan_check"), simd_ffi: cx.has_feature("simd_ffi"), unmarked_api: cx.has_feature("unmarked_api"), - lib_features: unknown_features + declared_stable_lang_features: accepted_features, + declared_lib_features: unknown_features } } |
