rustc: Fix cfg(not(a, b)) to be not(a && b)
Previously, the cfg attribute `cfg(not(a, b))` was translated to `(!a && !b)`, but this isn't very useful because that can already be expressed as `cfg(not(a), not(b))`. This commit changes the translation to `!(a && b)` which is more symmetrical of the rest of the `cfg` attribute. Put another way, I would expect `cfg(clause)` to be the opposite of `cfg(not(clause))`, but this is not currently the case with multiple element clauses.
This commit is contained in:
parent
2585803ec1
commit
770b6e2fc2
2 changed files with 11 additions and 3 deletions
|
|
@ -16,7 +16,7 @@
|
|||
fn foo1() -> int { 1 }
|
||||
|
||||
// !fooA AND !bar
|
||||
#[cfg(not(fooA, bar))]
|
||||
#[cfg(not(fooA), not(bar))]
|
||||
fn foo2() -> int { 2 }
|
||||
|
||||
// fooC OR (fooB AND !bar)
|
||||
|
|
@ -24,8 +24,16 @@ fn foo2() -> int { 2 }
|
|||
#[cfg(fooB, not(bar))]
|
||||
fn foo2() -> int { 3 }
|
||||
|
||||
// fooA AND bar
|
||||
#[cfg(fooA, bar)]
|
||||
fn foo3() -> int { 2 }
|
||||
|
||||
// !(fooA AND bar)
|
||||
#[cfg(not(fooA, bar))]
|
||||
fn foo3() -> int { 3 }
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!(1, foo1());
|
||||
assert_eq!(3, foo2());
|
||||
assert_eq!(3, foo3());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue