mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-04 02:54:00 +00:00
Add support for values() with --check-cfg
This commit is contained in:
parent
2f8d1a835b
commit
50e61a1a66
@ -207,6 +207,9 @@ pub fn parse_check_cfg(specs: Vec<String>) -> CheckCfg {
|
||||
"`values()` first argument must be a simple identifer"
|
||||
);
|
||||
}
|
||||
} else if args.is_empty() {
|
||||
cfg.well_known_values = true;
|
||||
continue 'specs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1025,13 +1025,19 @@ pub fn to_crate_config(cfg: FxHashSet<(String, Option<String>)>) -> CrateConfig
|
||||
pub struct CheckCfg<T = String> {
|
||||
/// The set of all `names()`, if None no name checking is performed
|
||||
pub names_valid: Option<FxHashSet<T>>,
|
||||
/// Is well known values activated
|
||||
pub well_known_values: bool,
|
||||
/// The set of all `values()`
|
||||
pub values_valid: FxHashMap<T, FxHashSet<T>>,
|
||||
}
|
||||
|
||||
impl<T> Default for CheckCfg<T> {
|
||||
fn default() -> Self {
|
||||
CheckCfg { names_valid: Default::default(), values_valid: Default::default() }
|
||||
CheckCfg {
|
||||
names_valid: Default::default(),
|
||||
values_valid: Default::default(),
|
||||
well_known_values: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1047,6 +1053,7 @@ impl<T> CheckCfg<T> {
|
||||
.iter()
|
||||
.map(|(a, b)| (f(a), b.iter().map(|b| f(b)).collect()))
|
||||
.collect(),
|
||||
well_known_values: self.well_known_values,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
// Check that a an empty values() is rejected
|
||||
// Check that a an empty values() pass
|
||||
//
|
||||
// check-fail
|
||||
// check-pass
|
||||
// compile-flags: --check-cfg=values() -Z unstable-options
|
||||
|
||||
fn main() {}
|
||||
|
@ -1,2 +0,0 @@
|
||||
error: invalid `--check-cfg` argument: `values()` (expected `names(name1, name2, ... nameN)` or `values(name, "value1", "value2", ... "valueN")`)
|
||||
|
Loading…
Reference in New Issue
Block a user