Convert cfg syntax to new system

This removes the ability to use `foo(bar)` style cfgs. Switch them to
`foo_bar` or `foo="bar"` instead.

[breaking-change]
This commit is contained in:
Steven Fackler 2014-09-24 20:22:57 -07:00
parent dcdbdc1003
commit 9519abecfb
13 changed files with 102 additions and 66 deletions

View file

@ -12,10 +12,9 @@
fn foo(x: int) { println!("{}", x); }
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "x86_64")]
#[cfg(target_arch = "arm")]
#[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm"))]
pub fn main() {
let x: int;
let y: int;
@ -27,5 +26,5 @@ pub fn main() {
foo(y);
}
#[cfg(not(target_arch = "x86"), not(target_arch = "x86_64"), not(target_arch = "arm"))]
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "arm")))]
pub fn main() {}

View file

@ -14,8 +14,8 @@
#![allow(dead_code)]
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "x86_64")]
#[cfg(any(target_arch = "x86",
target_arch = "x86_64"))]
pub fn main() {
// assignment not dead
let mut x: int = 0;

View file

@ -12,9 +12,9 @@
fn foo(x: int) { println!("{}", x); }
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "x86_64")]
#[cfg(target_arch = "arm")]
#[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm"))]
pub fn main() {
let x: int;
x = 1; //~ NOTE prior assignment occurs here
@ -25,5 +25,5 @@ pub fn main() {
foo(x);
}
#[cfg(not(target_arch = "x86"), not(target_arch = "x86_64"), not(target_arch = "arm"))]
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "arm")))]
pub fn main() {}

View file

@ -12,9 +12,9 @@
fn foo(x: int) { println!("{}", x); }
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "x86_64")]
#[cfg(target_arch = "arm")]
#[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm"))]
pub fn main() {
let x: int;
unsafe {
@ -23,5 +23,5 @@ pub fn main() {
foo(x);
}
#[cfg(not(target_arch = "x86"), not(target_arch = "x86_64"), not(target_arch = "arm"))]
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "arm")))]
pub fn main() {}

View file

@ -12,9 +12,9 @@
fn foo(x: int) { println!("{}", x); }
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "x86_64")]
#[cfg(target_arch = "arm")]
#[cfg(any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm"))]
pub fn main() {
let x: int;
unsafe {
@ -23,5 +23,5 @@ pub fn main() {
foo(x);
}
#[cfg(not(target_arch = "x86"), not(target_arch = "x86_64"), not(target_arch = "arm"))]
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "arm")))]
pub fn main() {}

View file

@ -10,7 +10,7 @@
// compile-flags: --cfg foo
#[cfg(foo, bar)] // foo AND bar
#[cfg(all(foo, bar))] // foo AND bar
fn foo() {}
fn main() {

View file

@ -12,7 +12,7 @@
#![feature(asm)]
#[cfg = r#"just parse this"#]
#[cfg(foo = r#"just parse this"#)]
extern crate r##"blah"## as blah;
fn main() { unsafe { asm!(r###"blah"###); } }

View file

@ -8,27 +8,27 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags: --cfg foo --cfg bar(baz) --cfg qux="foo"
// compile-flags: --cfg foo --cfg qux="foo"
pub fn main() {
// check
if ! cfg!(foo) { fail!() }
if cfg!(not(foo)) { fail!() }
if ! cfg!(bar(baz)) { fail!() }
if cfg!(not(bar(baz))) { fail!() }
if ! cfg!(qux="foo") { fail!() }
if cfg!(not(qux="foo")) { fail!() }
if ! cfg!(foo, bar(baz), qux="foo") { fail!() }
if cfg!(not(foo, bar(baz), 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!(not_a_cfg) { fail!() }
if cfg!(not_a_cfg, foo, bar(baz), qux="foo") { fail!() }
if cfg!(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, bar(baz), qux="foo") { fail!() }
if ! cfg!(not(not_a_cfg), foo, qux="foo") { fail!() }
if cfg!(trailing_comma, ) { fail!() }
}