Skip to content

Commit 0e5f520

Browse files
committed
Auto merge of #123577 - Urgau:prep-work-for-compiletest-check-cfg, r=oli-obk
Do some preparation work for compiletest check-cfg This PR does several preparation work for having always-on check-cfg in compiletest. In particular, this PR does two main things: - It unifies all the *always-false* cfgs under the `FALSE` cfg (as it seems to be the convention under `tests/ui`) - It also removes some useless conditions This is done ahead of the introduction of the always-on check-cfg in compiletest to reduce the amount of changes in that follow-up work. I also think that this is useful even without that follow-up work.
2 parents 7a495cc + 47ff773 commit 0e5f520

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+121
-165
lines changed

tests/ui/asm/inline-syntax.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#![feature(no_core, lang_items, rustc_attrs)]
1717
#![crate_type = "rlib"]
1818
#![no_core]
19-
#![cfg_attr(x86_64_allowed, allow(bad_asm_style))]
19+
2020

2121
#[rustc_builtin_macro]
2222
macro_rules! asm {

tests/ui/cfg/cfg-attr-cfg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
//@ pretty-expanded FIXME #23616
66

7-
#[cfg_attr(foo, cfg(bar))]
7+
#[cfg_attr(FALSE, cfg(bar))]
88
fn main() { }

tests/ui/cfg/cfg-attr-crate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
//@ pretty-expanded FIXME #23616
55

6-
#![cfg_attr(not_used, no_core)]
6+
#![cfg_attr(FALSE, no_core)]
77

88
fn main() { }

tests/ui/cfg/cfg-macros-notfoo.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
//@ run-pass
2-
//@ compile-flags:
32

43
// check that cfg correctly chooses between the macro impls (see also
54
// cfg-macros-foo.rs)
65

7-
8-
#[cfg(foo)]
6+
#[cfg(FALSE)]
97
#[macro_use]
108
mod foo {
119
macro_rules! bar {
1210
() => { true }
1311
}
1412
}
1513

16-
#[cfg(not(foo))]
14+
#[cfg(not(FALSE))]
1715
#[macro_use]
1816
mod foo {
1917
macro_rules! bar {

tests/ui/cfg/cfg-match-arm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ enum Foo {
1010
fn foo(f: Foo) {
1111
match f {
1212
Foo::Bar => {},
13-
#[cfg(not(asdfa))]
13+
#[cfg(not(FALSE))]
1414
Foo::Baz => {},
15-
#[cfg(afsd)]
15+
#[cfg(FALSE)]
1616
Basdfwe => {}
1717
}
1818
}

tests/ui/cfg/cfg-panic-abort.rs

-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22
//@ compile-flags: -C panic=abort
33
//@ no-prefer-dynamic
44

5-
65
#[cfg(panic = "unwind")]
76
pub fn bad() -> i32 { }
87

98
#[cfg(not(panic = "abort"))]
109
pub fn bad() -> i32 { }
1110

12-
#[cfg(panic = "some_imaginary_future_panic_handler")]
13-
pub fn bad() -> i32 { }
14-
1511
#[cfg(panic = "abort")]
1612
pub fn main() { }

tests/ui/cfg/cfg-panic.rs

-4
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22
//@ compile-flags: -C panic=unwind
33
//@ needs-unwind
44

5-
65
#[cfg(panic = "abort")]
76
pub fn bad() -> i32 { }
87

98
#[cfg(not(panic = "unwind"))]
109
pub fn bad() -> i32 { }
1110

12-
#[cfg(panic = "some_imaginary_future_panic_handler")]
13-
pub fn bad() -> i32 { }
14-
1511
#[cfg(panic = "unwind")]
1612
pub fn main() { }

tests/ui/cfg/cfg_stmt_expr.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,49 @@
77

88
fn main() {
99
let a = 413;
10-
#[cfg(unset)]
10+
#[cfg(FALSE)]
1111
let a = ();
1212
assert_eq!(a, 413);
1313

1414
let mut b = 612;
15-
#[cfg(unset)]
15+
#[cfg(FALSE)]
1616
{
1717
b = 1111;
1818
}
1919
assert_eq!(b, 612);
2020

21-
#[cfg(unset)]
21+
#[cfg(FALSE)]
2222
undefined_fn();
2323

24-
#[cfg(unset)]
24+
#[cfg(FALSE)]
2525
undefined_macro!();
26-
#[cfg(unset)]
26+
#[cfg(FALSE)]
2727
undefined_macro![];
28-
#[cfg(unset)]
28+
#[cfg(FALSE)]
2929
undefined_macro!{};
3030

3131
// pretty printer bug...
32-
// #[cfg(unset)]
32+
// #[cfg(FALSE)]
3333
// undefined_macro!{}
3434

35-
let () = (#[cfg(unset)] 341,); // Should this also work on parens?
36-
let t = (1, #[cfg(unset)] 3, 4);
35+
let () = (#[cfg(FALSE)] 341,); // Should this also work on parens?
36+
let t = (1, #[cfg(FALSE)] 3, 4);
3737
assert_eq!(t, (1, 4));
3838

3939
let f = |_: u32, _: u32| ();
40-
f(2, 1, #[cfg(unset)] 6);
40+
f(2, 1, #[cfg(FALSE)] 6);
4141

42-
let _: u32 = a.clone(#[cfg(unset)] undefined);
42+
let _: u32 = a.clone(#[cfg(FALSE)] undefined);
4343

44-
let _: [(); 0] = [#[cfg(unset)] 126];
45-
let t = [#[cfg(unset)] 1, 2, 6];
44+
let _: [(); 0] = [#[cfg(FALSE)] 126];
45+
let t = [#[cfg(FALSE)] 1, 2, 6];
4646
assert_eq!(t, [2, 6]);
4747

4848
{
4949
let r;
50-
#[cfg(unset)]
50+
#[cfg(FALSE)]
5151
(r = 5);
52-
#[cfg(not(unset))]
52+
#[cfg(not(FALSE))]
5353
(r = 10);
5454
assert_eq!(r, 10);
5555
}
@@ -69,13 +69,13 @@ fn main() {
6969
}
7070
}
7171

72-
let n = if_cfg!(unset? {
72+
let n = if_cfg!(FALSE? {
7373
413
7474
} else {
7575
612
7676
});
7777

78-
assert_eq!((#[cfg(unset)] 1, #[cfg(not(unset))] 2), (2,));
78+
assert_eq!((#[cfg(FALSE)] 1, #[cfg(not(FALSE))] 2), (2,));
7979
assert_eq!(n, 612);
8080

8181
// check that lints work

tests/ui/cfg/conditional-compile.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@
66

77
// Crate use statements
88

9-
#[cfg(bogus)]
9+
#[cfg(FALSE)]
1010
use flippity;
1111

12-
#[cfg(bogus)]
12+
#[cfg(FALSE)]
1313
static b: bool = false;
1414

1515
static b: bool = true;
1616

1717
mod rustrt {
18-
#[cfg(bogus)]
18+
#[cfg(FALSE)]
1919
extern "C" {
2020
// This symbol doesn't exist and would be a link error if this
2121
// module was codegened
22-
pub fn bogus();
22+
pub fn FALSE();
2323
}
2424

2525
extern "C" {}
2626
}
2727

28-
#[cfg(bogus)]
28+
#[cfg(FALSE)]
2929
type t = isize;
3030

3131
type t = bool;
3232

33-
#[cfg(bogus)]
33+
#[cfg(FALSE)]
3434
enum tg {
3535
foo,
3636
}
@@ -39,12 +39,12 @@ enum tg {
3939
bar,
4040
}
4141

42-
#[cfg(bogus)]
42+
#[cfg(FALSE)]
4343
struct r {
4444
i: isize,
4545
}
4646

47-
#[cfg(bogus)]
47+
#[cfg(FALSE)]
4848
fn r(i: isize) -> r {
4949
r { i: i }
5050
}
@@ -57,34 +57,34 @@ fn r(i: isize) -> r {
5757
r { i: i }
5858
}
5959

60-
#[cfg(bogus)]
60+
#[cfg(FALSE)]
6161
mod m {
6262
// This needs to parse but would fail in typeck. Since it's not in
6363
// the current config it should not be typechecked.
64-
pub fn bogus() {
64+
pub fn FALSE() {
6565
return 0;
6666
}
6767
}
6868

6969
mod m {
7070
// Submodules have slightly different code paths than the top-level
7171
// module, so let's make sure this jazz works here as well
72-
#[cfg(bogus)]
72+
#[cfg(FALSE)]
7373
pub fn f() {}
7474

7575
pub fn f() {}
7676
}
7777

78-
// Since the bogus configuration isn't defined main will just be
78+
// Since the FALSE configuration isn't defined main will just be
7979
// parsed, but nothing further will be done with it
80-
#[cfg(bogus)]
80+
#[cfg(FALSE)]
8181
pub fn main() {
8282
panic!()
8383
}
8484

8585
pub fn main() {
8686
// Exercise some of the configured items in ways that wouldn't be possible
87-
// if they had the bogus definition
87+
// if they had the FALSE definition
8888
assert!((b));
8989
let _x: t = true;
9090
let _y: tg = tg::bar;
@@ -93,14 +93,14 @@ pub fn main() {
9393
}
9494

9595
fn test_in_fn_ctxt() {
96-
#[cfg(bogus)]
96+
#[cfg(FALSE)]
9797
fn f() {
9898
panic!()
9999
}
100100
fn f() {}
101101
f();
102102

103-
#[cfg(bogus)]
103+
#[cfg(FALSE)]
104104
static i: isize = 0;
105105
static i: isize = 1;
106106
assert_eq!(i, 1);
@@ -109,15 +109,15 @@ fn test_in_fn_ctxt() {
109109
mod test_foreign_items {
110110
pub mod rustrt {
111111
extern "C" {
112-
#[cfg(bogus)]
112+
#[cfg(FALSE)]
113113
pub fn write() -> String;
114114
pub fn write() -> String;
115115
}
116116
}
117117
}
118118

119119
mod test_use_statements {
120-
#[cfg(bogus)]
120+
#[cfg(FALSE)]
121121
use flippity_foo;
122122
}
123123

@@ -127,24 +127,24 @@ mod test_methods {
127127
}
128128

129129
impl Fooable for Foo {
130-
#[cfg(bogus)]
130+
#[cfg(FALSE)]
131131
fn what(&self) {}
132132

133133
fn what(&self) {}
134134

135-
#[cfg(bogus)]
135+
#[cfg(FALSE)]
136136
fn the(&self) {}
137137

138138
fn the(&self) {}
139139
}
140140

141141
trait Fooable {
142-
#[cfg(bogus)]
142+
#[cfg(FALSE)]
143143
fn what(&self);
144144

145145
fn what(&self);
146146

147-
#[cfg(bogus)]
147+
#[cfg(FALSE)]
148148
fn the(&self);
149149

150150
fn the(&self);

tests/ui/cfg/diagnostics-reexport.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub use a::x;
1414
//~| NOTE no `x` in `a`
1515

1616
mod a {
17-
#[cfg(no)]
17+
#[cfg(FALSE)]
1818
pub fn x() {}
1919
//~^ NOTE found an item that was configured out
2020
}
@@ -25,10 +25,10 @@ pub use b::{x, y};
2525
//~| NOTE no `y` in `b`
2626

2727
mod b {
28-
#[cfg(no)]
28+
#[cfg(FALSE)]
2929
pub fn x() {}
3030
//~^ NOTE found an item that was configured out
31-
#[cfg(no)]
31+
#[cfg(FALSE)]
3232
pub fn y() {}
3333
//~^ NOTE found an item that was configured out
3434
}
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
// Check that `#[cfg_attr($PREDICATE,)]` triggers the `unused_attribute` lint.
22

3-
//@ compile-flags: --cfg TRUE
4-
53
#![deny(unused)]
64

75
#[cfg_attr(FALSE,)] //~ ERROR `#[cfg_attr]` does not expand to any attributes
86
fn _f() {}
97

10-
#[cfg_attr(TRUE,)] //~ ERROR `#[cfg_attr]` does not expand to any attributes
8+
#[cfg_attr(not(FALSE),)] //~ ERROR `#[cfg_attr]` does not expand to any attributes
119
fn _g() {}
1210

1311
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
error: `#[cfg_attr]` does not expand to any attributes
2-
--> $DIR/cfg-attr-empty-is-unused.rs:7:1
2+
--> $DIR/cfg-attr-empty-is-unused.rs:5:1
33
|
44
LL | #[cfg_attr(FALSE,)]
55
| ^^^^^^^^^^^^^^^^^^^
66
|
77
note: the lint level is defined here
8-
--> $DIR/cfg-attr-empty-is-unused.rs:5:9
8+
--> $DIR/cfg-attr-empty-is-unused.rs:3:9
99
|
1010
LL | #![deny(unused)]
1111
| ^^^^^^
1212
= note: `#[deny(unused_attributes)]` implied by `#[deny(unused)]`
1313

1414
error: `#[cfg_attr]` does not expand to any attributes
15-
--> $DIR/cfg-attr-empty-is-unused.rs:10:1
15+
--> $DIR/cfg-attr-empty-is-unused.rs:8:1
1616
|
17-
LL | #[cfg_attr(TRUE,)]
18-
| ^^^^^^^^^^^^^^^^^^
17+
LL | #[cfg_attr(not(FALSE),)]
18+
| ^^^^^^^^^^^^^^^^^^^^^^^^
1919

2020
error: aborting due to 2 previous errors
2121

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
//@ error-pattern: `main` function not found
22

3-
#![cfg(bar)]
3+
#![cfg(FALSE)]

0 commit comments

Comments
 (0)