mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Add two setter functions to Features
.
This commit is contained in:
parent
95d1aa075f
commit
56fd2531ac
@ -124,8 +124,7 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute]) -> Features {
|
||||
edition,
|
||||
});
|
||||
}
|
||||
features.declared_lang_features.push((name, mi.span(), None));
|
||||
features.declared_features.insert(name);
|
||||
features.set_declared_lang_feature(name, mi.span(), None);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -139,8 +138,7 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute]) -> Features {
|
||||
feature: name,
|
||||
edition: features_edition,
|
||||
});
|
||||
features.declared_lang_features.push((name, mi.span(), None));
|
||||
features.declared_features.insert(name);
|
||||
features.set_declared_lang_feature(name, mi.span(), None);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -158,8 +156,7 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute]) -> Features {
|
||||
// If the declared feature is stable, record it.
|
||||
if let Some(Feature { since, .. }) = ACCEPTED_FEATURES.iter().find(|f| name == f.name) {
|
||||
let since = Some(Symbol::intern(since));
|
||||
features.declared_lang_features.push((name, mi.span(), since));
|
||||
features.declared_features.insert(name);
|
||||
features.set_declared_lang_feature(name, mi.span(), since);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -176,15 +173,13 @@ pub fn features(sess: &Session, krate_attrs: &[Attribute]) -> Features {
|
||||
// If the declared feature is unstable, record it.
|
||||
if let Some(f) = ACTIVE_FEATURES.iter().find(|f| name == f.name) {
|
||||
f.set(&mut features);
|
||||
features.declared_lang_features.push((name, mi.span(), None));
|
||||
features.declared_features.insert(name);
|
||||
features.set_declared_lang_feature(name, mi.span(), None);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Otherwise, the feature is unknown. Record it at a lib feature.
|
||||
// Otherwise, the feature is unknown. Record it as a lib feature.
|
||||
// It will be checked later.
|
||||
features.declared_lib_features.push((name, mi.span()));
|
||||
features.declared_features.insert(name);
|
||||
features.set_declared_lib_feature(name, mi.span());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,21 @@ macro_rules! declare_features {
|
||||
}
|
||||
|
||||
impl Features {
|
||||
pub fn set_declared_lang_feature(
|
||||
&mut self,
|
||||
symbol: Symbol,
|
||||
span: Span,
|
||||
since: Option<Symbol>
|
||||
) {
|
||||
self.declared_lang_features.push((symbol, span, since));
|
||||
self.declared_features.insert(symbol);
|
||||
}
|
||||
|
||||
pub fn set_declared_lib_feature(&mut self, symbol: Symbol, span: Span) {
|
||||
self.declared_lib_features.push((symbol, span));
|
||||
self.declared_features.insert(symbol);
|
||||
}
|
||||
|
||||
pub fn walk_feature_fields(&self, mut f: impl FnMut(&str, bool)) {
|
||||
$(f(stringify!($feature), self.$feature);)+
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user