1
Fork 0

Rollup merge of #131034 - Urgau:cfg-true-false, r=nnethercote

Implement RFC3695 Allow boolean literals as cfg predicates

This PR implements https://github.com/rust-lang/rfcs/pull/3695: allow boolean literals as cfg predicates, i.e. `cfg(true)` and `cfg(false)`.

r? `@nnethercote` *(or anyone with parser knowledge)*
cc `@clubby789`
This commit is contained in:
Guillaume Gomez 2024-10-04 15:42:53 +02:00 committed by GitHub
commit 2ceeeb159d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 284 additions and 58 deletions

View file

@ -1,7 +1,7 @@
use std::ops::ControlFlow;
use std::path::{Path, PathBuf};
use rustc_ast::{CRATE_NODE_ID, NestedMetaItem};
use rustc_ast::CRATE_NODE_ID;
use rustc_attr as attr;
use rustc_data_structures::fx::FxHashSet;
use rustc_middle::query::LocalCrate;
@ -304,7 +304,12 @@ impl<'tcx> Collector<'tcx> {
sess.dcx().emit_err(errors::LinkCfgForm { span: item.span() });
continue;
};
let [NestedMetaItem::MetaItem(link_cfg)] = link_cfg else {
let [link_cfg] = link_cfg else {
sess.dcx()
.emit_err(errors::LinkCfgSinglePredicate { span: item.span() });
continue;
};
let Some(link_cfg) = link_cfg.meta_item_or_bool() else {
sess.dcx()
.emit_err(errors::LinkCfgSinglePredicate { span: item.span() });
continue;