Skip to content
Permalink
Browse files

derive(Default) for Features

  • Loading branch information
Centril committed Nov 30, 2019
1 parent 79077f1 commit ded177a06a1cde44ab64dcd09c63f6c2b815a9fe
Showing with 4 additions and 14 deletions.
  1. +2 −12 src/librustc_feature/active.rs
  2. +1 −1 src/librustc_parse/config.rs
  3. +1 −1 src/libsyntax/feature_gate/check.rs
@@ -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 {

0 comments on commit ded177a

Please sign in to comment.
You can’t perform that action at this time.