diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-04-03 21:18:30 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-03 21:18:30 +0200 |
| commit | 9d733eca06f7ab138925e0db260955fd32135d87 (patch) | |
| tree | 589307e56a1d9b65c925d95024c089e3f2861b73 /compiler/rustc_interface | |
| parent | 48a39198846cf1d1679247259b1628b5e931d0b3 (diff) | |
| parent | 3df2acd31ba14544ddb7fb1b0e73e6235824d4a3 (diff) | |
| download | rust-9d733eca06f7ab138925e0db260955fd32135d87.tar.gz rust-9d733eca06f7ab138925e0db260955fd32135d87.zip | |
Rollup merge of #138767 - clubby789:check-cfg-bool, r=Urgau
Allow boolean literals in `check-cfg` https://github.com/rust-lang/rust/pull/138632#issuecomment-2738114495 This makes it consistent with `--cfg` We could alternatively add a forward-compatible lint against `--cfg true/false` r? `@Urgau`
Diffstat (limited to 'compiler/rustc_interface')
| -rw-r--r-- | compiler/rustc_interface/src/interface.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 3f87b1a547b..33b4a48b28d 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -204,6 +204,14 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch error!("`cfg()` names cannot be after values"); } names.push(ident); + } else if let Some(boolean) = arg.boolean_literal() { + if values_specified { + error!("`cfg()` names cannot be after values"); + } + names.push(rustc_span::Ident::new( + if boolean { rustc_span::kw::True } else { rustc_span::kw::False }, + arg.span(), + )); } else if arg.has_name(sym::any) && let Some(args) = arg.meta_item_list() { |
