diff options
| author | Steven Fackler <sfackler@gmail.com> | 2014-10-11 18:05:54 -0700 |
|---|---|---|
| committer | Steven Fackler <sfackler@gmail.com> | 2014-10-12 11:40:19 -0700 |
| commit | aa3b1261b164eeac3e68573bfc698d1ca943fb05 (patch) | |
| tree | 782e225f5db942be43f37941fa0d1ce70fd63dac | |
| parent | cd1fa91d2bf97a6331e1d0265eec0f3324191f89 (diff) | |
| download | rust-aa3b1261b164eeac3e68573bfc698d1ca943fb05.tar.gz rust-aa3b1261b164eeac3e68573bfc698d1ca943fb05.zip | |
Continue cfg syntax transition
All deprecation warnings have been converted to errors. This includes the warning for multiple cfgs on one item. We'll leave that as an error for some period of time to ensure that all uses are updated before the behavior changes from "or" to "and".
25 files changed, 98 insertions, 190 deletions
diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 2b52ac65e47..ab8d924a442 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -952,10 +952,10 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> , to_lower(line).as_slice().starts_with(to_lower(prefix).as_slice()) } - #[cfg(target_os = "linux")] - #[cfg(target_os = "macos")] - #[cfg(target_os = "freebsd")] - #[cfg(target_os = "dragonfly")] + #[cfg(any(target_os = "linux", + target_os = "macos", + target_os = "freebsd", + target_os = "dragonfly"))] fn prefix_matches( line : &str, prefix : &str ) -> bool { line.starts_with( prefix ) } @@ -1356,10 +1356,10 @@ fn program_output(config: &Config, testfile: &Path, lib_path: &str, prog: String } // Linux and mac don't require adjusting the library search path -#[cfg(target_os = "linux")] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "dragonfly")] +#[cfg(any(target_os = "linux", + target_os = "macos", + target_os = "freebsd", + target_os = "dragonfly"))] fn make_cmdline(_libpath: &str, prog: &str, args: &[String]) -> String { format!("{} {}", prog, args.connect(" ")) } diff --git a/src/doc/guide-ffi.md b/src/doc/guide-ffi.md index 14e60b5ba08..abd2cd7b33e 100644 --- a/src/doc/guide-ffi.md +++ b/src/doc/guide-ffi.md @@ -475,7 +475,7 @@ conventions. Rust provides a way to tell the compiler which convention to use: ~~~~ extern crate libc; -#[cfg(target_os = "win32", target_arch = "x86")] +#[cfg(all(target_os = "win32", target_arch = "x86"))] #[link(name = "kernel32")] #[allow(non_snake_case)] extern "stdcall" { diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md index fe6664bd848..7756abc8020 100644 --- a/src/doc/guide-unsafe.md +++ b/src/doc/guide-unsafe.md @@ -313,8 +313,7 @@ literal string (i.e `""`) ``` #![feature(asm)] -#[cfg(target_arch = "x86")] -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] fn foo() { unsafe { asm!("NOP"); @@ -322,8 +321,7 @@ fn foo() { } // other platforms -#[cfg(not(target_arch = "x86"), - not(target_arch = "x86_64"))] +#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] fn foo() { /* ... */ } fn main() { @@ -340,7 +338,7 @@ but you must add the right number of `:` if you skip them: ``` # #![feature(asm)] -# #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] +# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] # fn main() { unsafe { asm!("xor %eax, %eax" : @@ -354,7 +352,7 @@ Whitespace also doesn't matter: ``` # #![feature(asm)] -# #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] +# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] # fn main() { unsafe { asm!("xor %eax, %eax" ::: "eax"); # } } @@ -368,7 +366,7 @@ expressions must be mutable lvalues: ``` # #![feature(asm)] -# #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] +# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] fn add(a: int, b: int) -> int { let mut c = 0; unsafe { @@ -379,7 +377,7 @@ fn add(a: int, b: int) -> int { } c } -# #[cfg(not(target_arch = "x86"), not(target_arch = "x86_64"))] +# #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] # fn add(a: int, b: int) -> int { a + b } fn main() { @@ -396,7 +394,7 @@ stay valid. ``` # #![feature(asm)] -# #[cfg(target_arch = "x86")] #[cfg(target_arch = "x86_64")] +# #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] # fn main() { unsafe { // Put the value 0x200 in eax asm!("mov $$0x200, %eax" : /* no outputs */ : /* no inputs */ : "eax"); diff --git a/src/doc/reference.md b/src/doc/reference.md index c34a136a68e..cf9504736eb 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2066,26 +2066,28 @@ fn macos_only() { } // This function is only included when either foo or bar is defined -#[cfg(foo)] -#[cfg(bar)] +#[cfg(any(foo, bar))] fn needs_foo_or_bar() { // ... } // This function is only included when compiling for a unixish OS with a 32-bit // architecture -#[cfg(unix, target_word_size = "32")] +#[cfg(all(unix, target_word_size = "32"))] fn on_32bit_unix() { // ... } + +// This function is only included when foo is not defined +#[cfg(not(foo))] +fn needs_not_foo() { + // ... +} ``` This illustrates some conditional compilation can be achieved using the -`#[cfg(...)]` attribute. Note that `#[cfg(foo, bar)]` is a condition that needs -both `foo` and `bar` to be defined while `#[cfg(foo)] #[cfg(bar)]` only needs -one of `foo` and `bar` to be defined (this resembles in the disjunctive normal -form). Additionally, one can reverse a condition by enclosing it in a -`not(...)`, like e. g. `#[cfg(not(target_os = "win32"))]`. +`#[cfg(...)]` attribute. `any`, `all` and `not` can be used to assemble +arbitrarily complex configurations through nesting. The following configurations must be defined by the implementation: diff --git a/src/libcoretest/mem.rs b/src/libcoretest/mem.rs index fde640158f5..76409c8612f 100644 --- a/src/libcoretest/mem.rs +++ b/src/libcoretest/mem.rs @@ -19,10 +19,10 @@ fn size_of_basic() { } #[test] -#[cfg(target_arch = "x86")] -#[cfg(target_arch = "arm")] -#[cfg(target_arch = "mips")] -#[cfg(target_arch = "mipsel")] +#[cfg(any(target_arch = "x86", + target_arch = "arm", + target_arch = "mips", + target_arch = "mipsel"))] fn size_of_32() { assert_eq!(size_of::<uint>(), 4u); assert_eq!(size_of::<*const uint>(), 4u); @@ -51,10 +51,10 @@ fn align_of_basic() { } #[test] -#[cfg(target_arch = "x86")] -#[cfg(target_arch = "arm")] -#[cfg(target_arch = "mips")] -#[cfg(target_arch = "mipsel")] +#[cfg(any(target_arch = "x86", + target_arch = "arm", + target_arch = "mips", + target_arch = "mipsel"))] fn align_of_32() { assert_eq!(align_of::<uint>(), 4u); assert_eq!(align_of::<*const uint>(), 4u); diff --git a/src/librustc_back/rpath.rs b/src/librustc_back/rpath.rs index abb594d6e47..a7a234dc18a 100644 --- a/src/librustc_back/rpath.rs +++ b/src/librustc_back/rpath.rs @@ -200,8 +200,7 @@ mod test { } #[test] - #[cfg(target_os = "linux")] - #[cfg(target_os = "android")] + #[cfg(any(target_os = "linux", target_os = "android"))] fn test_rpath_relative() { let config = &mut RPathConfig { os: abi::OsLinux, diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 1491f02b3f5..148d986399d 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -316,11 +316,10 @@ pub fn cfg_matches(diagnostic: &SpanHandler, cfgs: &[P<MetaItem>], cfg: &ast::Me mis.iter().all(|mi| cfg_matches(diagnostic, cfgs, &**mi)), ast::MetaList(ref pred, ref mis) if pred.get() == "not" => { if mis.len() != 1 { - diagnostic.span_warn(cfg.span, "the use of multiple cfgs in the same `not` \ - statement is deprecated. Change `not(a, b)` to \ - `not(all(a, b))`."); + diagnostic.span_err(cfg.span, "expected 1 cfg-pattern"); + return false; } - !mis.iter().all(|mi| cfg_matches(diagnostic, cfgs, &**mi)) + !cfg_matches(diagnostic, cfgs, &*mis[0]) } ast::MetaList(ref pred, _) => { diagnostic.span_err(cfg.span, format!("invalid predicate `{}`", pred).as_slice()); @@ -330,56 +329,6 @@ pub fn cfg_matches(diagnostic: &SpanHandler, cfgs: &[P<MetaItem>], cfg: &ast::Me } } -/// Tests if any `cfg(...)` meta items in `metas` match `cfg`. e.g. -/// -/// test_cfg(`[foo="a", bar]`, `[cfg(foo), cfg(bar)]`) == true -/// test_cfg(`[foo="a", bar]`, `[cfg(not(bar))]`) == false -/// test_cfg(`[foo="a", bar]`, `[cfg(bar, foo="a")]`) == true -/// test_cfg(`[foo="a", bar]`, `[cfg(bar, foo="b")]`) == false -pub fn test_cfg<'a, AM: AttrMetaMethods, It: Iterator<&'a AM>> - (cfg: &[P<MetaItem>], mut metas: It) -> bool { - // having no #[cfg(...)] attributes counts as matching. - let mut no_cfgs = true; - - // this would be much nicer as a chain of iterator adaptors, but - // this doesn't work. - let some_cfg_matches = metas.fold(false, |matches, mi| { - debug!("testing name: {}", mi.name()); - let this_matches = if mi.check_name("cfg") { // it is a #[cfg()] attribute - debug!("is cfg"); - no_cfgs = false; - // only #[cfg(...)] ones are understood. - match mi.meta_item_list() { - Some(cfg_meta) => { - debug!("is cfg(...)"); - cfg_meta.iter().all(|cfg_mi| { - debug!("cfg({}[...])", cfg_mi.name()); - match cfg_mi.node { - ast::MetaList(ref s, ref not_cfgs) - if s.equiv(&("not")) => { - debug!("not!"); - // inside #[cfg(not(...))], so these need to all - // not match. - !not_cfgs.iter().all(|mi| { - debug!("cfg(not({}[...]))", mi.name()); - contains(cfg, &**mi) - }) - } - _ => contains(cfg, &**cfg_mi) - } - }) - } - None => false - } - } else { - false - }; - matches || this_matches - }); - debug!("test_cfg (no_cfgs={}, some_cfg_matches={})", no_cfgs, some_cfg_matches); - no_cfgs || some_cfg_matches -} - /// Represents the #[deprecated="foo"] and friends attributes. #[deriving(Encodable,Decodable,Clone,Show)] pub struct Stability { diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 9b4748f88ab..3511e167e97 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -261,20 +261,20 @@ fn in_cfg(diagnostic: &SpanHandler, cfg: &[P<ast::MetaItem>], attrs: &[ast::Attr }; if mis.len() != 1 { - diagnostic.span_warn(attr.span, "The use of multiple cfgs in the top level of \ - `#[cfg(..)]` is deprecated. Change `#[cfg(a, b)]` to \ - `#[cfg(all(a, b))]`."); + diagnostic.span_err(attr.span, "expected 1 cfg-pattern"); + return false; } if seen_cfg { - diagnostic.span_warn(attr.span, "The semantics of multiple `#[cfg(..)]` attributes on \ - same item are changing from the union of the cfgs to \ - the intersection of the cfgs. Change `#[cfg(a)] \ - #[cfg(b)]` to `#[cfg(any(a, b))]`."); + diagnostic.span_err(attr.span, "The semantics of multiple `#[cfg(..)]` attributes on \ + same item are changing from the union of the cfgs to \ + the intersection of the cfgs. Change `#[cfg(a)] \ + #[cfg(b)]` to `#[cfg(any(a, b))]`."); + return false; } seen_cfg = true; - in_cfg |= mis.iter().all(|mi| attr::cfg_matches(diagnostic, cfg, &**mi)); + in_cfg |= attr::cfg_matches(diagnostic, cfg, &*mis[0]); } in_cfg | !seen_cfg } diff --git a/src/libsyntax/ext/cfg.rs b/src/libsyntax/ext/cfg.rs index 74039da6cab..f697acb417d 100644 --- a/src/libsyntax/ext/cfg.rs +++ b/src/libsyntax/ext/cfg.rs @@ -8,11 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/** -The compiler code necessary to support the cfg! extension, which -expands to a literal `true` or `false` based on whether the given cfgs -match the current compilation environment. -*/ +/// The compiler code necessary to support the cfg! extension, which expands to +/// a literal `true` or `false` based on whether the given cfg matches the +/// current compilation environment. use ast; use codemap::Span; @@ -24,28 +22,18 @@ use attr::*; use parse::attr::ParserAttr; use parse::token; - pub fn expand_cfg<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> Box<base::MacResult+'static> { let mut p = cx.new_parser_from_tts(tts); - let mut cfgs = Vec::new(); - // parse `cfg!(meta_item, meta_item(x,y), meta_item="foo", ...)` - while p.token != token::EOF { - cfgs.push(p.parse_meta_item()); - if p.eat(&token::EOF) { break } // trailing comma is optional,. - p.expect(&token::COMMA); - } + let cfg = p.parse_meta_item(); - if cfgs.len() != 1 { - cx.span_warn(sp, "The use of multiple cfgs at the top level of `cfg!` \ - is deprecated. Change `cfg!(a, b)` to \ - `cfg!(all(a, b))`."); + if !p.eat(&token::EOF) { + cx.span_err(sp, "expected 1 cfg-pattern"); + return DummyResult::expr(sp); } - let matches_cfg = cfgs.iter().all(|cfg| attr::cfg_matches(&cx.parse_sess.span_diagnostic, - cx.cfg.as_slice(), &**cfg)); - + let matches_cfg = attr::cfg_matches(&cx.parse_sess.span_diagnostic, cx.cfg.as_slice(), &*cfg); MacExpr::new(cx.expr_bool(sp, matches_cfg)) } diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 9fb5742bb9b..37586f6abd7 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -126,7 +126,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> { span: i.span, path: self.cx.path.clone(), bench: is_bench_fn(&self.cx, &*i), - ignore: is_ignored(&self.cx, &*i), + ignore: is_ignored(&*i), should_fail: should_fail(&*i) }; self.cx.testfns.push(test); @@ -343,22 +343,8 @@ fn is_bench_fn(cx: &TestCtxt, i: &ast::Item) -> bool { return has_bench_attr && has_test_signature(i); } -fn is_ignored(cx: &TestCtxt, i: &ast::Item) -> bool { - i.attrs.iter().any(|attr| { - // check ignore(cfg(foo, bar)) - attr.check_name("ignore") && match attr.meta_item_list() { - Some(ref cfgs) => { - if cfgs.iter().any(|cfg| cfg.check_name("cfg")) { - cx.span_diagnostic.span_warn(attr.span, - "The use of cfg filters in #[ignore] is \ - deprecated. Use #[cfg_attr(<cfg pattern>, \ - ignore)] instead."); - } - attr::test_cfg(cx.config.as_slice(), cfgs.iter()) - } - None => true - } - }) +fn is_ignored(i: &ast::Item) -> bool { + i.attrs.iter().any(|attr| attr.check_name("ignore")) } fn should_fail(i: &ast::Item) -> bool { diff --git a/src/test/auxiliary/extern_calling_convention.rs b/src/test/auxiliary/extern_calling_convention.rs index 4dbae50aad4..2319a4545ef 100644 --- a/src/test/auxiliary/extern_calling_convention.rs +++ b/src/test/auxiliary/extern_calling_convention.rs @@ -26,8 +26,7 @@ pub extern "win64" fn foo(a: int, b: int, c: int, d: int) { } #[inline(never)] -#[cfg(target_arch = "x86")] -#[cfg(target_arch = "arm")] +#[cfg(any(target_arch = "x86", target_arch = "arm"))] pub extern fn foo(a: int, b: int, c: int, d: int) { assert!(a == 1); assert!(b == 2); diff --git a/src/test/run-make/test-harness/test-ignore-cfg.rs b/src/test/run-make/test-harness/test-ignore-cfg.rs index a8f88cc8544..990d3d10485 100644 --- a/src/test/run-make/test-harness/test-ignore-cfg.rs +++ b/src/test/run-make/test-harness/test-ignore-cfg.rs @@ -9,11 +9,11 @@ // except according to those terms. #[test] -#[ignore(cfg(ignorecfg))] +#[cfg_attr(ignorecfg, ignore)] fn shouldignore() { } #[test] -#[ignore(cfg(noignorecfg))] +#[cfg_attr(noignorecfg, ignore)] fn shouldnotignore() { } diff --git a/src/test/run-pass/asm-in-out-operand.rs b/src/test/run-pass/asm-in-out-operand.rs index 8a921129f92..ce0fcad40ee 100644 --- a/src/test/run-pass/asm-in-out-operand.rs +++ b/src/test/run-pass/asm-in-out-operand.rs @@ -10,8 +10,7 @@ #![feature(asm)] -#[cfg(target_arch = "x86")] -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] unsafe fn next_power_of_2(n: u32) -> u32 { let mut tmp = n; asm!("dec $0" : "+rm"(tmp) :: "cc"); @@ -28,8 +27,7 @@ unsafe fn next_power_of_2(n: u32) -> u32 { return tmp; } -#[cfg(target_arch = "x86")] -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub fn main() { unsafe { assert_eq!(64, next_power_of_2(37)); @@ -62,5 +60,5 @@ pub fn main() { assert_eq!(x, 60); } -#[cfg(not(target_arch = "x86"), not(target_arch = "x86_64"))] +#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] pub fn main() {} diff --git a/src/test/run-pass/asm-out-assign.rs b/src/test/run-pass/asm-out-assign.rs index ebbfbf925f9..f7853908467 100644 --- a/src/test/run-pass/asm-out-assign.rs +++ b/src/test/run-pass/asm-out-assign.rs @@ -10,8 +10,7 @@ #![feature(asm)] -#[cfg(target_arch = "x86")] -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub fn main() { let x: int; unsafe { @@ -30,5 +29,5 @@ pub fn main() { assert_eq!(x, 13); } -#[cfg(not(target_arch = "x86"), not(target_arch = "x86_64"))] +#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] pub fn main() {} diff --git a/src/test/run-pass/bitwise.rs b/src/test/run-pass/bitwise.rs index 305739a56d7..c2d5f17054d 100644 --- a/src/test/run-pass/bitwise.rs +++ b/src/test/run-pass/bitwise.rs @@ -9,8 +9,7 @@ // except according to those terms. -#[cfg(target_arch = "x86")] -#[cfg(target_arch = "arm")] +#[cfg(any(target_arch = "x86", target_arch = "arm"))] fn target() { assert_eq!(-1000 as uint >> 3u, 536870787u); } diff --git a/src/test/run-pass/cfgs-on-items.rs b/src/test/run-pass/cfgs-on-items.rs index 205dce64b78..b7cf3c4d22a 100644 --- a/src/test/run-pass/cfgs-on-items.rs +++ b/src/test/run-pass/cfgs-on-items.rs @@ -11,24 +11,23 @@ // compile-flags: --cfg fooA --cfg fooB // fooA AND !bar -#[cfg(fooA, not(bar))] +#[cfg(all(fooA, not(bar)))] fn foo1() -> int { 1 } // !fooA AND !bar -#[cfg(not(fooA), not(bar))] +#[cfg(all(not(fooA), not(bar)))] fn foo2() -> int { 2 } // fooC OR (fooB AND !bar) -#[cfg(fooC)] -#[cfg(fooB, not(bar))] +#[cfg(any(fooC, all(fooB, not(bar))))] fn foo2() -> int { 3 } // fooA AND bar -#[cfg(fooA, bar)] +#[cfg(all(fooA, bar))] fn foo3() -> int { 2 } // !(fooA AND bar) -#[cfg(not(fooA, bar))] +#[cfg(not(all(fooA, bar)))] fn foo3() -> int { 3 } pub fn main() { diff --git a/src/test/run-pass/core-run-destroy.rs b/src/test/run-pass/core-run-destroy.rs index 6aaf91dee16..b4a54b599fe 100644 --- a/src/test/run-pass/core-run-destroy.rs +++ b/src/test/run-pass/core-run-destroy.rs @@ -60,10 +60,10 @@ pub fn test_destroy_actually_kills(force: bool) { use libc; use std::str; - #[cfg(unix,not(target_os="android"))] + #[cfg(all(unix,not(target_os="android")))] static BLOCK_COMMAND: &'static str = "cat"; - #[cfg(unix,target_os="android")] + #[cfg(all(unix,target_os="android"))] static BLOCK_COMMAND: &'static str = "/system/bin/cat"; #[cfg(windows)] diff --git a/src/test/run-pass/intrinsic-alignment.rs b/src/test/run-pass/intrinsic-alignment.rs index 4873dc13c40..6ab753d526f 100644 --- a/src/test/run-pass/intrinsic-alignment.rs +++ b/src/test/run-pass/intrinsic-alignment.rs @@ -17,10 +17,10 @@ mod rusti { } } -#[cfg(target_os = "linux")] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "dragonfly")] +#[cfg(any(target_os = "linux", + target_os = "macos", + target_os = "freebsd", + target_os = "dragonfly"))] mod m { #[main] #[cfg(target_arch = "x86")] @@ -32,8 +32,7 @@ mod m { } #[main] - #[cfg(target_arch = "x86_64")] - #[cfg(target_arch = "arm")] + #[cfg(any(target_arch = "x86_64", target_arch = "arm"))] pub fn main() { unsafe { assert_eq!(::rusti::pref_align_of::<u64>(), 8u); diff --git a/src/test/run-pass/issue-14936.rs b/src/test/run-pass/issue-14936.rs index 0aca74c76c3..960dae8b704 100644 --- a/src/test/run-pass/issue-14936.rs +++ b/src/test/run-pass/issue-14936.rs @@ -36,8 +36,7 @@ macro_rules! demo { } } -#[cfg(target_arch = "x86")] -#[cfg(target_arch = "x86_64")] +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] fn main() { fn out_write_only_expr_then_in_expr() { demo!("=r") @@ -51,5 +50,5 @@ fn main() { out_read_write_expr_then_in_expr(); } -#[cfg(not(target_arch = "x86"), not(target_arch = "x86_64"))] +#[cfg(all(not(target_arch = "x86"), not(target_arch = "x86_64")))] pub fn main() {} diff --git a/src/test/run-pass/issue-2895.rs b/src/test/run-pass/issue-2895.rs index 1e1db393780..b9f522f1f85 100644 --- a/src/test/run-pass/issue-2895.rs +++ b/src/test/run-pass/issue-2895.rs @@ -28,8 +28,7 @@ pub fn main() { assert_eq!(mem::size_of::<Kitty>(), 16 as uint); } -#[cfg(target_arch = "x86")] -#[cfg(target_arch = "arm")] +#[cfg(any(target_arch = "x86", target_arch = "arm"))] pub fn main() { assert_eq!(mem::size_of::<Cat>(), 4 as uint); assert_eq!(mem::size_of::<Kitty>(), 8 as uint); diff --git a/src/test/run-pass/rec-align-u32.rs b/src/test/run-pass/rec-align-u32.rs index d741b80ef5e..c5a721ee326 100644 --- a/src/test/run-pass/rec-align-u32.rs +++ b/src/test/run-pass/rec-align-u32.rs @@ -36,8 +36,7 @@ struct Outer { } -#[cfg(target_arch = "x86")] -#[cfg(target_arch = "arm")] +#[cfg(any(target_arch = "x86", target_arch = "arm"))] mod m { pub fn align() -> uint { 4u } pub fn size() -> uint { 8u } diff --git a/src/test/run-pass/rec-align-u64.rs b/src/test/run-pass/rec-align-u64.rs index 8bd7a499de6..4e41caf138e 100644 --- a/src/test/run-pass/rec-align-u64.rs +++ b/src/test/run-pass/rec-align-u64.rs @@ -36,10 +36,10 @@ struct Outer { } -#[cfg(target_os = "linux")] -#[cfg(target_os = "macos")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "dragonfly")] +#[cfg(any(target_os = "linux", + target_os = "macos", + target_os = "freebsd", + target_os = "dragonfly"))] mod m { #[cfg(target_arch = "x86")] pub mod m { @@ -47,8 +47,7 @@ mod m { pub fn size() -> uint { 12u } } - #[cfg(target_arch = "x86_64")] - #[cfg(target_arch = "arm")] + #[cfg(any(target_arch = "x86_64", target_arch = "arm"))] pub mod m { pub fn align() -> uint { 8u } pub fn size() -> uint { 16u } diff --git a/src/test/run-pass/struct-return.rs b/src/test/run-pass/struct-return.rs index 3e41b6d806c..63574316fe5 100644 --- a/src/test/run-pass/struct-return.rs +++ b/src/test/run-pass/struct-return.rs @@ -57,8 +57,7 @@ fn test2() { } } -#[cfg(target_arch = "x86")] -#[cfg(target_arch = "arm")] +#[cfg(any(target_arch = "x86", target_arch = "arm"))] fn test2() { } diff --git a/src/test/run-pass/syntax-extension-cfg.rs b/src/test/run-pass/syntax-extension-cfg.rs index ab6468b2a85..8f67532d89d 100644 --- a/src/test/run-pass/syntax-extension-cfg.rs +++ b/src/test/run-pass/syntax-extension-cfg.rs @@ -18,17 +18,15 @@ pub fn main() { if ! cfg!(qux="foo") { fail!() } if cfg!(not(qux="foo")) { fail!() } - if ! cfg!(foo, qux="foo") { fail!() } - if cfg!(not(foo, qux="foo")) { fail!() } - if cfg!(all(not(foo, qux="foo"))) { fail!() } + if ! cfg!(all(foo, qux="foo")) { fail!() } + if cfg!(not(all(foo, qux="foo"))) { fail!() } + if cfg!(all(not(all(foo, qux="foo")))) { fail!() } if cfg!(not_a_cfg) { fail!() } - if cfg!(not_a_cfg, foo, qux="foo") { fail!() } + if cfg!(all(not_a_cfg, foo, qux="foo")) { fail!() } if cfg!(all(not_a_cfg, foo, qux="foo")) { fail!() } if ! cfg!(any(not_a_cfg, foo)) { fail!() } if ! cfg!(not(not_a_cfg)) { fail!() } - if ! cfg!(not(not_a_cfg), foo, qux="foo") { fail!() } - - if cfg!(trailing_comma, ) { fail!() } + if ! cfg!(all(not(not_a_cfg), foo, qux="foo")) { fail!() } } diff --git a/src/test/run-pass/x86stdcall.rs b/src/test/run-pass/x86stdcall.rs index 66dbb6b1619..15d18525d0a 100644 --- a/src/test/run-pass/x86stdcall.rs +++ b/src/test/run-pass/x86stdcall.rs @@ -30,9 +30,9 @@ pub fn main() { } } -#[cfg(target_os = "macos")] -#[cfg(target_os = "linux")] -#[cfg(target_os = "freebsd")] -#[cfg(target_os = "dragonfly")] -#[cfg(target_os = "android")] +#[cfg(any(target_os = "macos", + target_os = "linux", + target_os = "freebsd", + target_os = "dragonfly", + target_os = "android"))] pub fn main() { } |
