diff options
| author | Loïc BRANSTETT <lolo.branstett@numericable.fr> | 2022-02-25 13:43:57 +0100 |
|---|---|---|
| committer | Loïc BRANSTETT <lolo.branstett@numericable.fr> | 2022-03-03 12:00:28 +0100 |
| commit | 50e61a1a667929d0db91132246e61c1a67ab07af (patch) | |
| tree | 6345cab4790dafc92ca209a9aafa7071967c5c4f | |
| parent | 2f8d1a835b4e7feaf625f74d0d5cb9b84dbc845a (diff) | |
| download | rust-50e61a1a667929d0db91132246e61c1a67ab07af.tar.gz rust-50e61a1a667929d0db91132246e61c1a67ab07af.zip | |
Add support for values() with --check-cfg
| -rw-r--r-- | compiler/rustc_interface/src/interface.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/check-cfg/empty-values.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/check-cfg/empty-values.stderr | 2 |
4 files changed, 13 insertions, 5 deletions
diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 7f4a4ffadec..e7563933c88 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -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; } } } diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index f9b75690e37..02cfdcf86f8 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -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, } } } diff --git a/src/test/ui/check-cfg/empty-values.rs b/src/test/ui/check-cfg/empty-values.rs index 38ef9e51c7a..5464846409a 100644 --- a/src/test/ui/check-cfg/empty-values.rs +++ b/src/test/ui/check-cfg/empty-values.rs @@ -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() {} diff --git a/src/test/ui/check-cfg/empty-values.stderr b/src/test/ui/check-cfg/empty-values.stderr deleted file mode 100644 index 106d5b7b47f..00000000000 --- a/src/test/ui/check-cfg/empty-values.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: invalid `--check-cfg` argument: `values()` (expected `names(name1, name2, ... nameN)` or `values(name, "value1", "value2", ... "valueN")`) - |
