about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-02-10 08:43:01 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-02-10 08:43:01 -0800
commitbbc8a54c63c843676ce5801cb2e97f0b4e691646 (patch)
tree18995c5fd8d376dac8610e9a58cab6cc817e4f21 /src/test
parentc33acf658a5b6e14d57016ea5a455277f7e0c966 (diff)
parent5354317037368124d180acc3f8754bdb2b0387b8 (diff)
downloadrust-bbc8a54c63c843676ce5801cb2e97f0b4e691646.tar.gz
rust-bbc8a54c63c843676ce5801cb2e97f0b4e691646.zip
rollup merge of #22116: kmcallister/cfg_attr
Fixes #22070.
Fixes #19372.

r? @sfackler
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/cfg-attr-cfg-2.rs18
-rw-r--r--src/test/compile-fail/cfg-attr-crate-2.rs17
-rw-r--r--src/test/run-pass/cfg-attr-cfg.rs15
-rw-r--r--src/test/run-pass/cfg-attr-crate.rs15
4 files changed, 65 insertions, 0 deletions
diff --git a/src/test/compile-fail/cfg-attr-cfg-2.rs b/src/test/compile-fail/cfg-attr-cfg-2.rs
new file mode 100644
index 00000000000..b71a3be5dce
--- /dev/null
+++ b/src/test/compile-fail/cfg-attr-cfg-2.rs
@@ -0,0 +1,18 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+//
+// error-pattern: main function not found
+// compile-flags: --cfg foo
+
+// main is conditionally compiled, but the conditional compilation
+// is conditional too!
+
+#[cfg_attr(foo, cfg(bar))]
+fn main() { }
diff --git a/src/test/compile-fail/cfg-attr-crate-2.rs b/src/test/compile-fail/cfg-attr-crate-2.rs
new file mode 100644
index 00000000000..4867dd8d0b4
--- /dev/null
+++ b/src/test/compile-fail/cfg-attr-crate-2.rs
@@ -0,0 +1,17 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+//
+// compile-flags: --cfg broken
+
+// https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044
+
+#![cfg_attr(broken, no_std)] //~ ERROR no_std is experimental
+
+fn main() { }
diff --git a/src/test/run-pass/cfg-attr-cfg.rs b/src/test/run-pass/cfg-attr-cfg.rs
new file mode 100644
index 00000000000..09ab7019486
--- /dev/null
+++ b/src/test/run-pass/cfg-attr-cfg.rs
@@ -0,0 +1,15 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// main is conditionally compiled, but the conditional compilation
+// is conditional too!
+
+#[cfg_attr(foo, cfg(bar))]
+fn main() { }
diff --git a/src/test/run-pass/cfg-attr-crate.rs b/src/test/run-pass/cfg-attr-crate.rs
new file mode 100644
index 00000000000..e6bd8afad28
--- /dev/null
+++ b/src/test/run-pass/cfg-attr-crate.rs
@@ -0,0 +1,15 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// https://github.com/rust-lang/rust/issues/21833#issuecomment-72353044
+
+#![cfg_attr(not_used, no_std)]
+
+fn main() { }