Skip to content

Commit f2b3f3e

Browse files
committed
tests/ui: prepare some tests for --check-cfg by default
1 parent a61b14d commit f2b3f3e

6 files changed

+25
-27
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#[cfg(target(os = "x"))] //~ ERROR compact `cfg(target(..))` is experimental
1+
#[cfg(target(os = "linux"))] //~ ERROR compact `cfg(target(..))` is experimental
22
struct Foo(u64, u64);
33

4-
#[cfg_attr(target(os = "x"), x)] //~ ERROR compact `cfg(target(..))` is experimental
4+
#[cfg_attr(target(os = "linux"), non_exhaustive)] //~ ERROR compact `cfg(target(..))` is experimental
55
struct Bar(u64, u64);
66

7-
#[cfg(not(any(all(target(os = "x")))))] //~ ERROR compact `cfg(target(..))` is experimental
7+
#[cfg(not(any(all(target(os = "linux")))))] //~ ERROR compact `cfg(target(..))` is experimental
88
fn foo() {}
99

1010
fn main() {
11-
cfg!(target(os = "x"));
11+
cfg!(target(os = "linux"));
1212
//~^ ERROR compact `cfg(target(..))` is experimental and subject to change
1313
}

tests/ui/feature-gates/feature-gate-cfg-target-compact.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0658]: compact `cfg(target(..))` is experimental and subject to change
22
--> $DIR/feature-gate-cfg-target-compact.rs:1:7
33
|
4-
LL | #[cfg(target(os = "x"))]
5-
| ^^^^^^^^^^^^^^^^
4+
LL | #[cfg(target(os = "linux"))]
5+
| ^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: see issue #96901 <https://github.com/rust-lang/rust/issues/96901> for more information
88
= help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable
@@ -11,8 +11,8 @@ LL | #[cfg(target(os = "x"))]
1111
error[E0658]: compact `cfg(target(..))` is experimental and subject to change
1212
--> $DIR/feature-gate-cfg-target-compact.rs:4:12
1313
|
14-
LL | #[cfg_attr(target(os = "x"), x)]
15-
| ^^^^^^^^^^^^^^^^
14+
LL | #[cfg_attr(target(os = "linux"), non_exhaustive)]
15+
| ^^^^^^^^^^^^^^^^^^^^
1616
|
1717
= note: see issue #96901 <https://github.com/rust-lang/rust/issues/96901> for more information
1818
= help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable
@@ -21,8 +21,8 @@ LL | #[cfg_attr(target(os = "x"), x)]
2121
error[E0658]: compact `cfg(target(..))` is experimental and subject to change
2222
--> $DIR/feature-gate-cfg-target-compact.rs:7:19
2323
|
24-
LL | #[cfg(not(any(all(target(os = "x")))))]
25-
| ^^^^^^^^^^^^^^^^
24+
LL | #[cfg(not(any(all(target(os = "linux")))))]
25+
| ^^^^^^^^^^^^^^^^^^^^
2626
|
2727
= note: see issue #96901 <https://github.com/rust-lang/rust/issues/96901> for more information
2828
= help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable
@@ -31,8 +31,8 @@ LL | #[cfg(not(any(all(target(os = "x")))))]
3131
error[E0658]: compact `cfg(target(..))` is experimental and subject to change
3232
--> $DIR/feature-gate-cfg-target-compact.rs:11:10
3333
|
34-
LL | cfg!(target(os = "x"));
35-
| ^^^^^^^^^^^^^^^^
34+
LL | cfg!(target(os = "linux"));
35+
| ^^^^^^^^^^^^^^^^^^^^
3636
|
3737
= note: see issue #96901 <https://github.com/rust-lang/rust/issues/96901> for more information
3838
= help: add `#![feature(cfg_target_compact)]` to the crate attributes to enable

tests/ui/issues/issue-11085.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
//@ run-pass
2-
#![allow(dead_code)]
3-
//@ compile-flags: --cfg foo
4-
52
//@ pretty-expanded FIXME #23616
63

4+
#![allow(dead_code)]
5+
76
struct Foo {
87
#[cfg(FALSE)]
98
bar: baz,
109
foo: isize,
1110
}
1211

1312
struct Foo2 {
14-
#[cfg(foo)]
13+
#[cfg(all())]
1514
foo: isize,
1615
}
1716

tests/ui/issues/issue-24434.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ check-pass
2-
//@ compile-flags:--cfg set1
32

4-
#![cfg_attr(set1, feature(rustc_attrs))]
3+
#![cfg_attr(all(), feature(rustc_attrs))]
54
#![rustc_dummy]
65

76
fn main() {}

tests/ui/macros/macro-meta-items.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ macro_rules! emit {
1616
}
1717

1818
// item
19-
compiles_fine!(bar);
19+
compiles_fine!(FALSE);
2020
emit!(foo);
2121

2222
fn foo() {
@@ -25,7 +25,7 @@ fn foo() {
2525

2626
pub fn main() {
2727
// statement
28-
compiles_fine!(baz);
29-
emit!(baz);
28+
compiles_fine!(FALSE);
29+
emit!(FALSE);
3030
println!("{}", MISTYPED);
3131
}

tests/ui/macros/syntax-extension-cfg.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ pub fn main() {
1414
if cfg!(not(all(foo, qux="foo"))) { panic!() }
1515
if cfg!(all(not(all(foo, qux="foo")))) { panic!() }
1616

17-
if cfg!(not_a_cfg) { panic!() }
18-
if cfg!(all(not_a_cfg, foo, qux="foo")) { panic!() }
19-
if cfg!(all(not_a_cfg, foo, qux="foo")) { panic!() }
20-
if ! cfg!(any(not_a_cfg, foo)) { panic!() }
17+
if cfg!(FALSE) { panic!() }
18+
if cfg!(all(FALSE, foo, qux="foo")) { panic!() }
19+
if cfg!(all(FALSE, foo, qux="foo")) { panic!() }
20+
if ! cfg!(any(FALSE, foo)) { panic!() }
2121

22-
if ! cfg!(not(not_a_cfg)) { panic!() }
23-
if ! cfg!(all(not(not_a_cfg), foo, qux="foo")) { panic!() }
22+
if ! cfg!(not(FALSE)) { panic!() }
23+
if ! cfg!(all(not(FALSE), foo, qux="foo")) { panic!() }
2424
}

0 commit comments

Comments
 (0)