Skip to content

Commit 2c7c4a8

Browse files
committed
Add more tests for cfg_boolean_literals
1 parent 1d4648d commit 2c7c4a8

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

tests/ui/cfg/both-true-false.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// Test that placing a `cfg(true)` and `cfg(false)` on the same item result in
2+
//. it being disabled.`
3+
4+
#[cfg(false)]
5+
#[cfg(true)]
6+
fn foo() {}
7+
8+
#[cfg(true)]
9+
#[cfg(false)]
10+
fn foo() {}
11+
12+
fn main() {
13+
foo(); //~ ERROR cannot find function `foo` in this scope
14+
}

tests/ui/cfg/both-true-false.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0425]: cannot find function `foo` in this scope
2+
--> $DIR/both-true-false.rs:13:5
3+
|
4+
LL | foo();
5+
| ^^^ not found in this scope
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0425`.

tests/ui/cfg/cmdline-false.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// Test that `--cfg false` doesn't cause `cfg(false)` to evaluate to `true`
2+
//@ compile-flags: --cfg false
3+
4+
#[cfg(false)]
5+
fn foo() {}
6+
7+
fn main() {
8+
foo(); //~ ERROR cannot find function `foo` in this scope
9+
}

tests/ui/cfg/cmdline-false.stderr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0425]: cannot find function `foo` in this scope
2+
--> $DIR/cmdline-false.rs:8:5
3+
|
4+
LL | foo();
5+
| ^^^ not found in this scope
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0425`.

0 commit comments

Comments
 (0)