Skip to content

Commit

Permalink
derive(Default) for Features
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Nov 30, 2019
1 parent 79077f1 commit ded177a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
14 changes: 2 additions & 12 deletions src/librustc_feature/active.rs
Expand Up @@ -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>)>,
Expand All @@ -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);)+
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_parse/config.rs
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/feature_gate/check.rs
Expand Up @@ -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 {
Expand Down

0 comments on commit ded177a

Please sign in to comment.