diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index ed56ef15a1c8..7ff9a73f29d9 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -317,9 +317,9 @@ pub fn test_cfg> debug!("not!"); // inside #[cfg(not(...))], so these need to all // not match. - not_cfgs.iter().all(|mi| { + !not_cfgs.iter().all(|mi| { debug!("cfg(not({}[...]))", mi.name()); - !contains(cfg, *mi) + contains(cfg, *mi) }) } _ => contains(cfg, *cfg_mi) diff --git a/src/test/run-pass/cfgs-on-items.rs b/src/test/run-pass/cfgs-on-items.rs index 72d12b56c5c9..f1c91dbaf354 100644 --- a/src/test/run-pass/cfgs-on-items.rs +++ b/src/test/run-pass/cfgs-on-items.rs @@ -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()); }