about summary refs log tree commit diff
path: root/compiler/rustc_interface/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-05-11 07:05:27 +0200
committerGitHub <noreply@github.com>2023-05-11 07:05:27 +0200
commitaa9adf457b85a4c75f3b0f791338395b1bd367e5 (patch)
treed0022f6b82b7ed60465acb7ff790b8a9ce45994a /compiler/rustc_interface/src
parent40d933a19a9dd6718bbe59fd473372cde9515a3a (diff)
parentf4ca42f573e3a8bd9bb5099efa0285855b77367f (diff)
downloadrust-aa9adf457b85a4c75f3b0f791338395b1bd367e5.tar.gz
rust-aa9adf457b85a4c75f3b0f791338395b1bd367e5.zip
Rollup merge of #111292 - Urgau:check-cfg-issue-111291, r=petrochenkov
Fix mishandled `--check-cfg` arguments order

This PR fixes a bug in `--check-cfg` where the order of `--check-cfg=names(a)` and `--check-cfg=values(a,…)` would trip the compiler.

Fixes https://github.com/rust-lang/rust/issues/111291
cc `@taiki-e` `@petrochenkov`
Diffstat (limited to 'compiler/rustc_interface/src')
-rw-r--r--compiler/rustc_interface/src/interface.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs
index 9d9f4ee13f4..51354c2b127 100644
--- a/compiler/rustc_interface/src/interface.rs
+++ b/compiler/rustc_interface/src/interface.rs
@@ -173,12 +173,21 @@ pub fn parse_check_cfg(specs: Vec<String>) -> CheckCfg {
                                         let expected_values = check_cfg
                                             .expecteds
                                             .entry(ident.name.to_string())
+                                            .and_modify(|expected_values| match expected_values {
+                                                ExpectedValues::Some(_) => {}
+                                                ExpectedValues::Any => {
+                                                    // handle the case where names(...) was done
+                                                    // before values by changing to a list
+                                                    *expected_values =
+                                                        ExpectedValues::Some(FxHashSet::default());
+                                                }
+                                            })
                                             .or_insert_with(|| {
                                                 ExpectedValues::Some(FxHashSet::default())
                                             });
 
                                         let ExpectedValues::Some(expected_values) = expected_values else {
-                                            bug!("shoudn't be possible")
+                                            bug!("`expected_values` should be a list a values")
                                         };
 
                                         for val in values {