Skip to content

Commit ded177a

Browse files
committed
derive(Default) for Features
1 parent 79077f1 commit ded177a

File tree

3 files changed

+4
-14
lines changed

3 files changed

+4
-14
lines changed

src/librustc_feature/active.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ macro_rules! declare_features {
3636
),+];
3737

3838
/// A set of features to be used by later passes.
39-
#[derive(Clone)]
39+
#[derive(Clone, Default)]
4040
pub struct Features {
4141
/// `#![feature]` attrs for language features, for error reporting.
4242
pub declared_lang_features: Vec<(Symbol, Span, Option<Symbol>)>,
@@ -49,17 +49,7 @@ macro_rules! declare_features {
4949
}
5050

5151
impl Features {
52-
pub fn new() -> Features {
53-
Features {
54-
declared_lang_features: Vec::new(),
55-
declared_lib_features: Vec::new(),
56-
$($feature: false),+
57-
}
58-
}
59-
60-
pub fn walk_feature_fields<F>(&self, mut f: F)
61-
where F: FnMut(&str, bool)
62-
{
52+
pub fn walk_feature_fields(&self, mut f: impl FnMut(&str, bool)) {
6353
$(f(stringify!($feature), self.$feature);)+
6454
}
6555
}

src/librustc_parse/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn features(mut krate: ast::Crate, sess: &ParseSess, edition: Edition,
4747
} else { // the entire crate is unconfigured
4848
krate.attrs = Vec::new();
4949
krate.module.items = Vec::new();
50-
return (krate, Features::new());
50+
return (krate, Features::default());
5151
}
5252

5353
features = get_features(&sess.span_diagnostic, &krate.attrs, edition, allow_features);

src/libsyntax/feature_gate/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],
641641
err.emit();
642642
}
643643

644-
let mut features = Features::new();
644+
let mut features = Features::default();
645645
let mut edition_enabled_features = FxHashMap::default();
646646

647647
for &edition in ALL_EDITIONS {

0 commit comments

Comments
 (0)