about summary refs log tree commit diff
path: root/compiler/rustc_session/src
diff options
context:
space:
mode:
authorLoïc BRANSTETT <lolo.branstett@numericable.fr>2022-02-20 01:26:52 +0100
committerLoïc BRANSTETT <lolo.branstett@numericable.fr>2022-02-23 13:22:23 +0100
commit8d3de56da1eba68d012977d4c743d5eaaa1baee8 (patch)
treef9e20f36386f0fcb218504528db33c9ff1561a81 /compiler/rustc_session/src
parent3d234770b1c83840d18305e8625da38e97da3174 (diff)
Continue improvements on the --check-cfg implementation
- Test the combinations of --check-cfg with partial values() and --cfg
- Test that we detect unexpected value when none are expected
Diffstat (limited to 'compiler/rustc_session/src')
-rw-r--r--compiler/rustc_session/src/config.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
index e0a3cc78b17..f9b75690e37 100644
--- a/compiler/rustc_session/src/config.rs
+++ b/compiler/rustc_session/src/config.rs
@@ -1023,10 +1023,10 @@ pub fn to_crate_config(cfg: FxHashSet<(String, Option<String>)>) -> CrateConfig
 
 /// The parsed `--check-cfg` options
 pub struct CheckCfg<T = String> {
-    /// The set of all `names()`, if none no names checking is performed
+    /// The set of all `names()`, if None no name checking is performed
     pub names_valid: Option<FxHashSet<T>>,
-    /// The set of all `values()`, if none no values chcking is performed
-    pub values_valid: Option<FxHashMap<T, FxHashSet<T>>>,
+    /// The set of all `values()`
+    pub values_valid: FxHashMap<T, FxHashSet<T>>,
 }
 
 impl<T> Default for CheckCfg<T> {
@@ -1042,9 +1042,11 @@ impl<T> CheckCfg<T> {
                 .names_valid
                 .as_ref()
                 .map(|names_valid| names_valid.iter().map(|a| f(a)).collect()),
-            values_valid: self.values_valid.as_ref().map(|values_valid| {
-                values_valid.iter().map(|(a, b)| (f(a), b.iter().map(|b| f(b)).collect())).collect()
-            }),
+            values_valid: self
+                .values_valid
+                .iter()
+                .map(|(a, b)| (f(a), b.iter().map(|b| f(b)).collect()))
+                .collect(),
         }
     }
 }
@@ -1098,11 +1100,9 @@ impl CrateCheckConfig {
                 names_valid.insert(k);
             }
             if let Some(v) = v {
-                if let Some(values_valid) = &mut self.values_valid {
-                    values_valid.entry(k).and_modify(|values| {
-                        values.insert(v);
-                    });
-                }
+                self.values_valid.entry(k).and_modify(|values| {
+                    values.insert(v);
+                });
             }
         }
     }