about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-11-30 07:44:01 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2019-11-30 07:44:50 +0100
commitded177a06a1cde44ab64dcd09c63f6c2b815a9fe (patch)
tree46db50adb2323c3a11ab36a47c42c74e885a206c
parent79077f13ffa9194161a0ed574b036794ab1a8c36 (diff)
downloadrust-ded177a06a1cde44ab64dcd09c63f6c2b815a9fe.tar.gz
rust-ded177a06a1cde44ab64dcd09c63f6c2b815a9fe.zip
derive(Default) for Features
-rw-r--r--src/librustc_feature/active.rs14
-rw-r--r--src/librustc_parse/config.rs2
-rw-r--r--src/libsyntax/feature_gate/check.rs2
3 files changed, 4 insertions, 14 deletions
diff --git a/src/librustc_feature/active.rs b/src/librustc_feature/active.rs
index fc1f770e226..7c0d39965fc 100644
--- a/src/librustc_feature/active.rs
+++ b/src/librustc_feature/active.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);)+
             }
         }
diff --git a/src/librustc_parse/config.rs b/src/librustc_parse/config.rs
index 6293858ed4e..26e51e83d62 100644
--- a/src/librustc_parse/config.rs
+++ b/src/librustc_parse/config.rs
@@ -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);
diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs
index c90f4c6f19f..3d2c3b1d4f9 100644
--- a/src/libsyntax/feature_gate/check.rs
+++ b/src/libsyntax/feature_gate/check.rs
@@ -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 {