derive(Default) for Features
This commit is contained in:
parent
79077f13ff
commit
ded177a06a
3 changed files with 4 additions and 14 deletions
|
@ -36,7 +36,7 @@ macro_rules! declare_features {
|
|||
),+];
|
||||
|
||||
/// A set of features to be used by later passes.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct Features {
|
||||
/// `#![feature]` attrs for language features, for error reporting.
|
||||
pub declared_lang_features: Vec<(Symbol, Span, Option<Symbol>)>,
|
||||
|
@ -49,17 +49,7 @@ macro_rules! declare_features {
|
|||
}
|
||||
|
||||
impl Features {
|
||||
pub fn new() -> Features {
|
||||
Features {
|
||||
declared_lang_features: Vec::new(),
|
||||
declared_lib_features: Vec::new(),
|
||||
$($feature: false),+
|
||||
}
|
||||
}
|
||||
|
||||
pub fn walk_feature_fields<F>(&self, mut f: F)
|
||||
where F: FnMut(&str, bool)
|
||||
{
|
||||
pub fn walk_feature_fields(&self, mut f: impl FnMut(&str, bool)) {
|
||||
$(f(stringify!($feature), self.$feature);)+
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ pub fn features(mut krate: ast::Crate, sess: &ParseSess, edition: Edition,
|
|||
} else { // the entire crate is unconfigured
|
||||
krate.attrs = Vec::new();
|
||||
krate.module.items = Vec::new();
|
||||
return (krate, Features::new());
|
||||
return (krate, Features::default());
|
||||
}
|
||||
|
||||
features = get_features(&sess.span_diagnostic, &krate.attrs, edition, allow_features);
|
||||
|
|
|
@ -641,7 +641,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
|
|||
err.emit();
|
||||
}
|
||||
|
||||
let mut features = Features::new();
|
||||
let mut features = Features::default();
|
||||
let mut edition_enabled_features = FxHashMap::default();
|
||||
|
||||
for &edition in ALL_EDITIONS {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue