-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Easy edition feature flag #49252
Merged
Merged
Easy edition feature flag #49252
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ use self::AttributeGate::*; | |
use abi::Abi; | ||
use ast::{self, NodeId, PatKind, RangeEnd}; | ||
use attr; | ||
use edition::Edition; | ||
use edition::{ALL_EDITIONS, Edition}; | ||
use codemap::Spanned; | ||
use syntax_pos::{Span, DUMMY_SP}; | ||
use errors::{DiagnosticBuilder, Handler, FatalError}; | ||
|
@@ -1818,21 +1818,15 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { | |
} | ||
|
||
pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute], | ||
edition: Edition) -> Features { | ||
crate_edition: Edition) -> Features { | ||
fn feature_removed(span_handler: &Handler, span: Span) { | ||
span_err!(span_handler, span, E0557, "feature has been removed"); | ||
} | ||
|
||
let mut features = Features::new(); | ||
|
||
let mut feature_checker = FeatureChecker::default(); | ||
|
||
for &(.., f_edition, set) in ACTIVE_FEATURES.iter() { | ||
if let Some(f_edition) = f_edition { | ||
if edition >= f_edition { | ||
// FIXME(Manishearth) there is currently no way to set | ||
// lang features by edition | ||
set(&mut features, DUMMY_SP); | ||
} | ||
} | ||
} | ||
|
||
for attr in krate_attrs { | ||
if !attr.check_name("feature") { | ||
continue | ||
|
@@ -1845,6 +1839,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute], | |
} | ||
Some(list) => { | ||
for mi in list { | ||
|
||
let name = if let Some(word) = mi.word() { | ||
word.name() | ||
} else { | ||
|
@@ -1862,11 +1857,26 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute], | |
.find(|& &(n, _, _)| name == n) | ||
.or_else(|| STABLE_REMOVED_FEATURES.iter() | ||
.find(|& &(n, _, _)| name == n)) { | ||
span_err!(span_handler, mi.span, E0557, "feature has been removed"); | ||
feature_removed(span_handler, mi.span); | ||
} | ||
else if let Some(&(_, _, _)) = ACCEPTED_FEATURES.iter() | ||
.find(|& &(n, _, _)| name == n) { | ||
features.declared_stable_lang_features.push((name, mi.span)); | ||
} else if let Some(&edition) = ALL_EDITIONS.iter() | ||
.find(|e| name == e.feature_name()) { | ||
if edition <= crate_edition { | ||
feature_removed(span_handler, mi.span); | ||
} else { | ||
for &(.., f_edition, set) in ACTIVE_FEATURES.iter() { | ||
if let Some(f_edition) = f_edition { | ||
if edition >= f_edition { | ||
// FIXME(Manishearth) there is currently no way to set | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you mean libs? :) |
||
// lib features by edition | ||
set(&mut features, DUMMY_SP); | ||
} | ||
} | ||
} | ||
} | ||
} else { | ||
features.declared_lib_features.push((name, mi.span)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoiding the anachronism of "preview" may be more valuable than keeping these names symmetrical?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, once a feature is added it can't be "removed" completely.
There's no way to use the rust_2015_preview feature, that feature exists only so that attempting to use it will throw a "feature removed" warning. This goes for the 2018_preview feature when you enable the 2018 epoch, as well.
Yes, we could just not do this for 2015, but it didn't seem worth it to special case 2015.