diff options
| author | bors <bors@rust-lang.org> | 2022-02-24 22:29:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-02-24 22:29:14 +0000 |
| commit | 4e82f35492ea5c78e19609bf4468f0a686d9a756 (patch) | |
| tree | 23fbd4cd23c587684432375a288e303b80be8051 /compiler/rustc_session/src | |
| parent | 4b043faba34ccc053a4d0110634c323f6c03765e (diff) | |
| parent | 3bd163f4e8422db4c0de384b2b21bfaaecd2e5c1 (diff) | |
| download | rust-4e82f35492ea5c78e19609bf4468f0a686d9a756.tar.gz rust-4e82f35492ea5c78e19609bf4468f0a686d9a756.zip | |
Auto merge of #94333 - Dylan-DPC:rollup-7yxtywp, r=Dylan-DPC
Rollup of 9 pull requests Successful merges: - #91795 (resolve/metadata: Stop encoding macros as reexports) - #93714 (better ObligationCause for normalization errors in `can_type_implement_copy`) - #94175 (Improve `--check-cfg` implementation) - #94212 (Stop manually SIMDing in `swap_nonoverlapping`) - #94242 (properly handle fat pointers to uninhabitable types) - #94308 (Normalize main return type during mono item collection & codegen) - #94315 (update auto trait lint for `PhantomData`) - #94316 (Improve string literal unescaping) - #94327 (Avoid emitting full macro body into JSON errors) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 7a0d9a212c9..f9b75690e37 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -8,7 +8,7 @@ use crate::search_paths::SearchPath; use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind}; use crate::{early_error, early_warn, Session}; -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::impl_stable_hash_via_hash; use rustc_target::abi::{Align, TargetDataLayout}; @@ -1023,34 +1023,30 @@ pub fn to_crate_config(cfg: FxHashSet<(String, Option<String>)>) -> CrateConfig /// The parsed `--check-cfg` options pub struct CheckCfg<T = String> { - /// Set if `names()` checking is enabled - pub names_checked: bool, - /// The union of all `names()` - pub names_valid: FxHashSet<T>, - /// The set of names for which `values()` was used - pub values_checked: FxHashSet<T>, - /// The set of all (name, value) pairs passed in `values()` - pub values_valid: FxHashSet<(T, T)>, + /// The set of all `names()`, if None no name checking is performed + pub names_valid: Option<FxHashSet<T>>, + /// The set of all `values()` + pub values_valid: FxHashMap<T, FxHashSet<T>>, } impl<T> Default for CheckCfg<T> { fn default() -> Self { - CheckCfg { - names_checked: false, - names_valid: FxHashSet::default(), - values_checked: FxHashSet::default(), - values_valid: FxHashSet::default(), - } + CheckCfg { names_valid: Default::default(), values_valid: Default::default() } } } impl<T> CheckCfg<T> { fn map_data<O: Eq + Hash>(&self, f: impl Fn(&T) -> O) -> CheckCfg<O> { CheckCfg { - names_checked: self.names_checked, - names_valid: self.names_valid.iter().map(|a| f(a)).collect(), - values_checked: self.values_checked.iter().map(|a| f(a)).collect(), - values_valid: self.values_valid.iter().map(|(a, b)| (f(a), f(b))).collect(), + names_valid: self + .names_valid + .as_ref() + .map(|names_valid| names_valid.iter().map(|a| f(a)).collect()), + values_valid: self + .values_valid + .iter() + .map(|(a, b)| (f(a), b.iter().map(|b| f(b)).collect())) + .collect(), } } } @@ -1090,17 +1086,23 @@ impl CrateCheckConfig { sym::doctest, sym::feature, ]; - for &name in WELL_KNOWN_NAMES { - self.names_valid.insert(name); + if let Some(names_valid) = &mut self.names_valid { + for &name in WELL_KNOWN_NAMES { + names_valid.insert(name); + } } } /// Fills a `CrateCheckConfig` with configuration names and values that are actually active. pub fn fill_actual(&mut self, cfg: &CrateConfig) { for &(k, v) in cfg { - self.names_valid.insert(k); + if let Some(names_valid) = &mut self.names_valid { + names_valid.insert(k); + } if let Some(v) = v { - self.values_valid.insert((k, v)); + self.values_valid.entry(k).and_modify(|values| { + values.insert(v); + }); } } } |
