Make -Z allow-features work for stdlib features

This commit is contained in:
Tyler Mandry 2019-04-25 14:03:45 -07:00
parent bd31c392f2
commit 0a26789af9
5 changed files with 35 additions and 19 deletions

View File

@ -2258,32 +2258,32 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
continue;
}
if let Some((.., set)) = ACTIVE_FEATURES.iter().find(|f| name == f.0) {
if let Some(allowed) = allow_features.as_ref() {
if allowed.iter().find(|f| *f == name.as_str()).is_none() {
span_err!(span_handler, mi.span(), E0725,
"the feature `{}` is not in the list of allowed features",
name);
continue;
}
}
set(&mut features, mi.span());
features.declared_lang_features.push((name, mi.span(), None));
continue
}
let removed = REMOVED_FEATURES.iter().find(|f| name == f.0);
let stable_removed = STABLE_REMOVED_FEATURES.iter().find(|f| name == f.0);
if let Some((.., reason)) = removed.or(stable_removed) {
feature_removed(span_handler, mi.span(), *reason);
continue
continue;
}
if let Some((_, since, ..)) = ACCEPTED_FEATURES.iter().find(|f| name == f.0) {
let since = Some(Symbol::intern(since));
features.declared_lang_features.push((name, mi.span(), since));
continue
continue;
}
if let Some(allowed) = allow_features.as_ref() {
if allowed.iter().find(|f| *f == name.as_str()).is_none() {
span_err!(span_handler, mi.span(), E0725,
"the feature `{}` is not in the list of allowed features",
name);
continue;
}
}
if let Some((.., set)) = ACTIVE_FEATURES.iter().find(|f| name == f.0) {
set(&mut features, mi.span());
features.declared_lang_features.push((name, mi.span(), None));
continue;
}
features.declared_lib_features.push((name, mi.span()));

View File

@ -7,4 +7,6 @@
#![feature(lang_items)] //~ ERROR
#![feature(unknown_stdlib_feature)] //~ ERROR
fn main() {}

View File

@ -16,6 +16,12 @@ error[E0725]: the feature `lang_items` is not in the list of allowed features
LL | #![feature(lang_items)]
| ^^^^^^^^^^
error: aborting due to 3 previous errors
error[E0725]: the feature `unknown_stdlib_feature` is not in the list of allowed features
--> $DIR/allow-features-empty.rs:10:12
|
LL | #![feature(unknown_stdlib_feature)]
| ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0725`.

View File

@ -7,4 +7,6 @@
#![feature(lang_items)]
#![feature(unknown_stdlib_feature)] //~ ERROR
fn main() {}

View File

@ -4,6 +4,12 @@ error[E0725]: the feature `rustc_const_unstable` is not in the list of allowed f
LL | #![feature(rustc_const_unstable)]
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
error[E0725]: the feature `unknown_stdlib_feature` is not in the list of allowed features
--> $DIR/allow-features.rs:10:12
|
LL | #![feature(unknown_stdlib_feature)]
| ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0725`.