Add more tests for cfg_boolean_literals
This commit is contained in:
parent
984c51f6a1
commit
d83f415325
4 changed files with 41 additions and 0 deletions
14
tests/ui/cfg/both-true-false.rs
Normal file
14
tests/ui/cfg/both-true-false.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
/// Test that placing a `cfg(true)` and `cfg(false)` on the same item result in
|
||||
//. it being disabled.`
|
||||
|
||||
#[cfg(false)]
|
||||
#[cfg(true)]
|
||||
fn foo() {}
|
||||
|
||||
#[cfg(true)]
|
||||
#[cfg(false)]
|
||||
fn foo() {}
|
||||
|
||||
fn main() {
|
||||
foo(); //~ ERROR cannot find function `foo` in this scope
|
||||
}
|
9
tests/ui/cfg/both-true-false.stderr
Normal file
9
tests/ui/cfg/both-true-false.stderr
Normal file
|
@ -0,0 +1,9 @@
|
|||
error[E0425]: cannot find function `foo` in this scope
|
||||
--> $DIR/both-true-false.rs:13:5
|
||||
|
|
||||
LL | foo();
|
||||
| ^^^ not found in this scope
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0425`.
|
9
tests/ui/cfg/cmdline-false.rs
Normal file
9
tests/ui/cfg/cmdline-false.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
/// Test that `--cfg false` doesn't cause `cfg(false)` to evaluate to `true`
|
||||
//@ compile-flags: --cfg false
|
||||
|
||||
#[cfg(false)]
|
||||
fn foo() {}
|
||||
|
||||
fn main() {
|
||||
foo(); //~ ERROR cannot find function `foo` in this scope
|
||||
}
|
9
tests/ui/cfg/cmdline-false.stderr
Normal file
9
tests/ui/cfg/cmdline-false.stderr
Normal file
|
@ -0,0 +1,9 @@
|
|||
error[E0425]: cannot find function `foo` in this scope
|
||||
--> $DIR/cmdline-false.rs:8:5
|
||||
|
|
||||
LL | foo();
|
||||
| ^^^ not found in this scope
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0425`.
|
Loading…
Add table
Add a link
Reference in a new issue