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`
This commit is contained in:
commit
9d733eca06
6 changed files with 31 additions and 24 deletions
|
@ -570,6 +570,14 @@ impl MetaItemInner {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the bool if `self` is a boolean `MetaItemInner::Literal`.
|
||||
pub fn boolean_literal(&self) -> Option<bool> {
|
||||
match self {
|
||||
MetaItemInner::Lit(MetaItemLit { kind: LitKind::Bool(b), .. }) => Some(*b),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the `MetaItem` if `self` is a `MetaItemInner::MetaItem` or if it's
|
||||
/// `MetaItemInner::Lit(MetaItemLit { kind: LitKind::Bool(_), .. })`.
|
||||
pub fn meta_item_or_bool(&self) -> Option<&MetaItemInner> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue