Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/ui/cfg/both-true-false.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// Test that placing a `cfg(true)` and `cfg(false)` on the same item result in
//. it being disabled.`
//@ reference: cfg.attr.duplicates

#[cfg(false)]
#[cfg(true)]
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/cfg/both-true-false.stderr
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
error[E0425]: cannot find function `foo` in this scope
--> $DIR/both-true-false.rs:13:5
--> $DIR/both-true-false.rs:14:5
|
LL | foo();
| ^^^ not found in this scope
|
note: found an item that was configured out
--> $DIR/both-true-false.rs:6:4
--> $DIR/both-true-false.rs:7:4
|
LL | #[cfg(false)]
| ----- the item is gated here
LL | #[cfg(true)]
LL | fn foo() {}
| ^^^
note: found an item that was configured out
--> $DIR/both-true-false.rs:10:4
--> $DIR/both-true-false.rs:11:4
|
LL | #[cfg(false)]
| ----- the item is gated here
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/cfg/cfg-false-use-item.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//! Test that use items with cfg(false) are properly filtered out

//@ run-pass
//@ reference: cfg.predicate.literal
//@ reference: cfg.attr.effect

pub fn main() {
// Make sure that this view item is filtered out because otherwise it would
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/cfg/cfg-family.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//@ build-pass
//@ ignore-wasm32 no bare family
//@ ignore-sgx
//@ reference: cfg.target_family.unix
//@ reference: cfg.target_family.windows

#[cfg(windows)]
pub fn main() {
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/cfg/cfg-panic-abort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//@ compile-flags: -C panic=abort
//@ no-prefer-dynamic
//@ ignore-backends: gcc
//@ reference: cfg.panic.def
//@ reference: cfg.panic.values

#[cfg(panic = "unwind")]
pub fn bad() -> i32 { }
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/cfg/cfg-panic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//@ build-pass
//@ compile-flags: -C panic=unwind
//@ needs-unwind
//@ reference: cfg.panic.def
//@ reference: cfg.panic.values

#[cfg(panic = "abort")]
pub fn bad() -> i32 { }
Expand Down
1 change: 1 addition & 0 deletions tests/ui/cfg/cfg-path-error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ check-fail
//@ reference: cfg.option-spec

#![allow(unexpected_cfgs)] // invalid cfgs

Expand Down
8 changes: 4 additions & 4 deletions tests/ui/cfg/cfg-path-error.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0539]: malformed `cfg` attribute input
--> $DIR/cfg-path-error.rs:5:1
--> $DIR/cfg-path-error.rs:6:1
|
LL | #[cfg(any(foo, foo::bar))]
| ^^^^^^^^^^^^^^^--------^^^
Expand All @@ -10,7 +10,7 @@ LL | #[cfg(any(foo, foo::bar))]
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>

error[E0539]: malformed `cfg` attribute input
--> $DIR/cfg-path-error.rs:11:1
--> $DIR/cfg-path-error.rs:12:1
|
LL | #[cfg(any(foo::bar, foo))]
| ^^^^^^^^^^--------^^^^^^^^
Expand All @@ -21,7 +21,7 @@ LL | #[cfg(any(foo::bar, foo))]
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>

error[E0539]: malformed `cfg` attribute input
--> $DIR/cfg-path-error.rs:17:1
--> $DIR/cfg-path-error.rs:18:1
|
LL | #[cfg(all(foo, foo::bar))]
| ^^^^^^^^^^^^^^^--------^^^
Expand All @@ -32,7 +32,7 @@ LL | #[cfg(all(foo, foo::bar))]
= note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>

error[E0539]: malformed `cfg` attribute input
--> $DIR/cfg-path-error.rs:23:1
--> $DIR/cfg-path-error.rs:24:1
|
LL | #[cfg(all(foo::bar, foo))]
| ^^^^^^^^^^--------^^^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/cfg/cfg-target-abi.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@ run-pass
//@ reference: cfg.target_abi.def
//@ reference: cfg.target_abi.values

#[cfg(target_abi = "eabihf")]
pub fn main() {
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/cfg/cfg-target-family.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//@ build-pass
//@ ignore-sgx
//@ reference: cfg.target_family.def
//@ reference: cfg.target_family.values


#[cfg(target_family = "windows")]
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/cfg/cfg-target-vendor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@ run-pass
//@ reference: cfg.target_vendor.def
//@ reference: cfg.target_vendor.values
#[cfg(target_vendor = "unknown")]
pub fn main() {
}
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/cfg/cfg_attr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//@ run-pass
//@ compile-flags:--cfg set1 --cfg set2
//@ reference: cfg.cfg_attr.intro
//@ reference: cfg.cfg_attr.syntax

#![allow(dead_code, unexpected_cfgs)]

Expand Down
1 change: 1 addition & 0 deletions tests/ui/cfg/cfg_false_no_std-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

//@ check-pass
//@ aux-build: cfg_false_lib_no_std_after.rs
//@ reference: cfg.attr.crate-level-attrs

#![no_std]

Expand Down
1 change: 1 addition & 0 deletions tests/ui/cfg/cfg_false_no_std-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//@ compile-flags: -Cpanic=abort

//@ aux-build: cfg_false_lib_no_std_before.rs
//@ reference: cfg.attr.crate-level-attrs

#![no_std]

Expand Down
1 change: 1 addition & 0 deletions tests/ui/cfg/cfg_false_no_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

//@ check-pass
//@ aux-build: cfg_false_lib.rs
//@ reference: cfg.attr.crate-level-attrs

#![no_std]

Expand Down
1 change: 1 addition & 0 deletions tests/ui/cfg/cfg_stmt_expr.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ run-pass
//@ reference: cfg.attr.allowed-positions
#![allow(dead_code)]
#![allow(unused_mut)]
#![allow(unused_variables)]
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/cfg/cfgs-on-items.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//@ run-pass
//@ compile-flags: --cfg fooA --cfg fooB --check-cfg=cfg(fooA,fooB,fooC,bar)
//@ reference: cfg.predicate.all
//@ reference: cfg.predicate.any
//@ reference: cfg.predicate.not

// fooA AND !bar
#[cfg(all(fooA, not(bar)))]
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/cfg/conditional-compile-arch.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@ run-pass
//@ reference: cfg.target_arch.def
//@ reference: cfg.target_arch.values

#[cfg(target_arch = "x86")]
pub fn main() { }
Expand Down
1 change: 1 addition & 0 deletions tests/ui/cfg/conditional-compile.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ run-pass
//@ reference: cfg.attr.allowed-positions
#![allow(dead_code)]
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
Expand Down
1 change: 1 addition & 0 deletions tests/ui/cfg/crate-attributes-using-cfg_attr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//@ check-fail
//@ compile-flags:--cfg foo --check-cfg=cfg(foo)
//@ reference: cfg.cfg_attr.attr-restriction

#![cfg_attr(foo, crate_type="bin")]
//~^ERROR `crate_type` within
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/cfg/crate-attributes-using-cfg_attr.stderr
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
error: `crate_type` within an `#![cfg_attr]` attribute is forbidden
--> $DIR/crate-attributes-using-cfg_attr.rs:4:18
--> $DIR/crate-attributes-using-cfg_attr.rs:5:18
|
LL | #![cfg_attr(foo, crate_type="bin")]
| ^^^^^^^^^^^^^^^^

error: `crate_name` within an `#![cfg_attr]` attribute is forbidden
--> $DIR/crate-attributes-using-cfg_attr.rs:7:18
--> $DIR/crate-attributes-using-cfg_attr.rs:8:18
|
LL | #![cfg_attr(foo, crate_name="bar")]
| ^^^^^^^^^^^^^^^^

error: `crate_type` within an `#![cfg_attr]` attribute is forbidden
--> $DIR/crate-attributes-using-cfg_attr.rs:4:18
--> $DIR/crate-attributes-using-cfg_attr.rs:5:18
|
LL | #![cfg_attr(foo, crate_type="bin")]
| ^^^^^^^^^^^^^^^^
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`

error: `crate_name` within an `#![cfg_attr]` attribute is forbidden
--> $DIR/crate-attributes-using-cfg_attr.rs:7:18
--> $DIR/crate-attributes-using-cfg_attr.rs:8:18
|
LL | #![cfg_attr(foo, crate_name="bar")]
| ^^^^^^^^^^^^^^^^
Expand Down
3 changes: 3 additions & 0 deletions tests/ui/cfg/invalid-cli-cfg-pred.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
//@ compile-flags: --cfg foo=1x
//@ reference: cfg.option-spec
//@ reference: cfg.option-name
//@ reference: cfg.option-key-value
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you say why this includes cfg.option-spec and cfg.option-name? It looks like this test is just validating the error case when the value is not a valid string (which I think is covered by cfg.option-key-value).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured that cfg.option-key-value was saying "here is how to use cfg with a key-value pair" and that cfg.option-spec (saying that cfg options are either names or key-value pairs) and cfg.option-name (allowing names) are all tested by confirming that something other than a key-value pair is not allowed. I would say that

validating the error case when the value is not a valid string

is not just cfg.option-key-value since I read cfg.option-key-value to describe one thing that is accepted (key-value pairs where the value is a string) but on its own that rule isn't enough to say that things like foo=1x are not accepted, only with all three rules do you get the exhaustiveness


fn main() {}

Expand Down
3 changes: 3 additions & 0 deletions tests/ui/cfg/invalid-cli-check-cfg-pred.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
//@ compile-flags: --check-cfg 'foo=1x'
//@ reference: cfg.option-spec
//@ reference: cfg.option-name
//@ reference: cfg.option-key-value

fn main() {}

Expand Down
2 changes: 2 additions & 0 deletions tests/ui/cfg/path-kw-as-cfg-pred.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@ edition: 2024
//@ reference: cfg.attr.syntax
//@ reference: cfg.cfg_attr.syntax

#![allow(unexpected_cfgs)]

Expand Down
Loading
Loading