Skip to content

Commit 50e61a1

Browse files
committed
Add support for values() with --check-cfg
1 parent 2f8d1a8 commit 50e61a1

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

compiler/rustc_interface/src/interface.rs

+3
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ pub fn parse_check_cfg(specs: Vec<String>) -> CheckCfg {
207207
"`values()` first argument must be a simple identifer"
208208
);
209209
}
210+
} else if args.is_empty() {
211+
cfg.well_known_values = true;
212+
continue 'specs;
210213
}
211214
}
212215
}

compiler/rustc_session/src/config.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1025,13 +1025,19 @@ pub fn to_crate_config(cfg: FxHashSet<(String, Option<String>)>) -> CrateConfig
10251025
pub struct CheckCfg<T = String> {
10261026
/// The set of all `names()`, if None no name checking is performed
10271027
pub names_valid: Option<FxHashSet<T>>,
1028+
/// Is well known values activated
1029+
pub well_known_values: bool,
10281030
/// The set of all `values()`
10291031
pub values_valid: FxHashMap<T, FxHashSet<T>>,
10301032
}
10311033

10321034
impl<T> Default for CheckCfg<T> {
10331035
fn default() -> Self {
1034-
CheckCfg { names_valid: Default::default(), values_valid: Default::default() }
1036+
CheckCfg {
1037+
names_valid: Default::default(),
1038+
values_valid: Default::default(),
1039+
well_known_values: false,
1040+
}
10351041
}
10361042
}
10371043

@@ -1047,6 +1053,7 @@ impl<T> CheckCfg<T> {
10471053
.iter()
10481054
.map(|(a, b)| (f(a), b.iter().map(|b| f(b)).collect()))
10491055
.collect(),
1056+
well_known_values: self.well_known_values,
10501057
}
10511058
}
10521059
}

src/test/ui/check-cfg/empty-values.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Check that a an empty values() is rejected
1+
// Check that a an empty values() pass
22
//
3-
// check-fail
3+
// check-pass
44
// compile-flags: --check-cfg=values() -Z unstable-options
55

66
fn main() {}

src/test/ui/check-cfg/empty-values.stderr

-2
This file was deleted.

0 commit comments

Comments
 (0)