syntax: process all edition features before other features.
This commit is contained in:
parent
d767ee1161
commit
0f00979517
3 changed files with 44 additions and 20 deletions
|
|
@ -1923,7 +1923,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
|
|||
let mut features = Features::new();
|
||||
let mut edition_enabled_features = FxHashMap();
|
||||
|
||||
for &(name, .., f_edition, set) in ACTIVE_FEATURES.iter() {
|
||||
for &(name, .., f_edition, set) in ACTIVE_FEATURES {
|
||||
if let Some(f_edition) = f_edition {
|
||||
if f_edition <= crate_edition {
|
||||
set(&mut features, DUMMY_SP);
|
||||
|
|
@ -1932,6 +1932,44 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
|
|||
}
|
||||
}
|
||||
|
||||
// Process the edition umbrella feature-gates first, to ensure
|
||||
// `edition_enabled_features` is completed before it's queried.
|
||||
for attr in krate_attrs {
|
||||
if !attr.check_name("feature") {
|
||||
continue
|
||||
}
|
||||
|
||||
let list = match attr.meta_item_list() {
|
||||
Some(list) => list,
|
||||
None => continue,
|
||||
};
|
||||
|
||||
for mi in list {
|
||||
let name = if let Some(word) = mi.word() {
|
||||
word.name()
|
||||
} else {
|
||||
continue
|
||||
};
|
||||
|
||||
if let Some(edition) = ALL_EDITIONS.iter().find(|e| name == e.feature_name()) {
|
||||
if *edition <= crate_edition {
|
||||
continue;
|
||||
}
|
||||
|
||||
for &(name, .., f_edition, set) in ACTIVE_FEATURES {
|
||||
if let Some(f_edition) = f_edition {
|
||||
if f_edition <= *edition {
|
||||
// FIXME(Manishearth) there is currently no way to set
|
||||
// lib features by edition
|
||||
set(&mut features, DUMMY_SP);
|
||||
edition_enabled_features.insert(Symbol::intern(name), *edition);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for attr in krate_attrs {
|
||||
if !attr.check_name("feature") {
|
||||
continue
|
||||
|
|
@ -1955,23 +1993,9 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
|
|||
continue
|
||||
};
|
||||
|
||||
if let Some(edition) = ALL_EDITIONS.iter().find(|e| name == e.feature_name()) {
|
||||
if *edition <= crate_edition {
|
||||
continue
|
||||
}
|
||||
|
||||
for &(name, .., f_edition, set) in ACTIVE_FEATURES.iter() {
|
||||
if let Some(f_edition) = f_edition {
|
||||
if f_edition <= *edition {
|
||||
// FIXME(Manishearth) there is currently no way to set
|
||||
// lib features by edition
|
||||
set(&mut features, DUMMY_SP);
|
||||
edition_enabled_features.insert(Symbol::intern(name), *edition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
continue
|
||||
if ALL_EDITIONS.iter().any(|e| name == e.feature_name()) {
|
||||
// Handled in the separate loop above.
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some((.., set)) = ACTIVE_FEATURES.iter().find(|f| name == f.0) {
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
// compile-pass
|
||||
|
||||
#![feature(rust_2018_preview)]
|
||||
#![feature(raw_identifiers)]
|
||||
//~^ WARN the feature `raw_identifiers` is included in the Rust 2018 edition
|
||||
#![feature(rust_2018_preview)]
|
||||
|
||||
fn main() {
|
||||
let foo = 0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
warning[E0705]: the feature `raw_identifiers` is included in the Rust 2018 edition
|
||||
--> $DIR/E0705.rs:14:12
|
||||
--> $DIR/E0705.rs:13:12
|
||||
|
|
||||
LL | #![feature(raw_identifiers)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue