Skip to content

Commit 303e7d1

Browse files
committed
Split tests in unix/non-unix
1 parent 4a405c9 commit 303e7d1

6 files changed

+169
-94
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// run-rustfix
2+
3+
#![warn(clippy::mismatched_target_os)]
4+
#![allow(unused)]
5+
6+
#[cfg(target_os = "cloudabi")]
7+
fn cloudabi() {}
8+
9+
#[cfg(target_os = "hermit")]
10+
fn hermit() {}
11+
12+
#[cfg(target_os = "wasi")]
13+
fn wasi() {}
14+
15+
#[cfg(target_os = "none")]
16+
fn none() {}
17+
18+
// list with conditions
19+
#[cfg(all(not(any(windows, target_os = "cloudabi")), target_os = "wasi"))]
20+
fn list() {}
21+
22+
// windows is a valid target family, should be ignored
23+
#[cfg(windows)]
24+
fn windows() {}
25+
26+
// correct use, should be ignored
27+
#[cfg(target_os = "hermit")]
28+
fn correct() {}
29+
30+
fn main() {}
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// run-rustfix
2+
3+
#![warn(clippy::mismatched_target_os)]
4+
#![allow(unused)]
5+
6+
#[cfg(cloudabi)]
7+
fn cloudabi() {}
8+
9+
#[cfg(hermit)]
10+
fn hermit() {}
11+
12+
#[cfg(wasi)]
13+
fn wasi() {}
14+
15+
#[cfg(none)]
16+
fn none() {}
17+
18+
// list with conditions
19+
#[cfg(all(not(any(windows, cloudabi)), wasi))]
20+
fn list() {}
21+
22+
// windows is a valid target family, should be ignored
23+
#[cfg(windows)]
24+
fn windows() {}
25+
26+
// correct use, should be ignored
27+
#[cfg(target_os = "hermit")]
28+
fn correct() {}
29+
30+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
error: operating system used in target family position
2+
--> $DIR/mismatched_target_os_non_unix.rs:6:1
3+
|
4+
LL | #[cfg(cloudabi)]
5+
| ^^^^^^--------^^
6+
| |
7+
| help: try: `target_os = "cloudabi"`
8+
|
9+
= note: `-D clippy::mismatched-target-os` implied by `-D warnings`
10+
11+
error: operating system used in target family position
12+
--> $DIR/mismatched_target_os_non_unix.rs:9:1
13+
|
14+
LL | #[cfg(hermit)]
15+
| ^^^^^^------^^
16+
| |
17+
| help: try: `target_os = "hermit"`
18+
19+
error: operating system used in target family position
20+
--> $DIR/mismatched_target_os_non_unix.rs:12:1
21+
|
22+
LL | #[cfg(wasi)]
23+
| ^^^^^^----^^
24+
| |
25+
| help: try: `target_os = "wasi"`
26+
27+
error: operating system used in target family position
28+
--> $DIR/mismatched_target_os_non_unix.rs:15:1
29+
|
30+
LL | #[cfg(none)]
31+
| ^^^^^^----^^
32+
| |
33+
| help: try: `target_os = "none"`
34+
35+
error: operating system used in target family position
36+
--> $DIR/mismatched_target_os_non_unix.rs:19:1
37+
|
38+
LL | #[cfg(all(not(any(windows, cloudabi)), wasi))]
39+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40+
|
41+
help: try
42+
|
43+
LL | #[cfg(all(not(any(windows, target_os = "cloudabi")), wasi))]
44+
| ^^^^^^^^^^^^^^^^^^^^^^
45+
help: try
46+
|
47+
LL | #[cfg(all(not(any(windows, cloudabi)), target_os = "wasi"))]
48+
| ^^^^^^^^^^^^^^^^^^
49+
50+
error: aborting due to 5 previous errors
51+

tests/ui/mismatched_target_os.fixed renamed to tests/ui/mismatched_target_os_unix.fixed

+8-22
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#![warn(clippy::mismatched_target_os)]
44
#![allow(unused)]
55

6-
// unix
7-
86
#[cfg(target_os = "linux")]
97
fn linux() {}
108

@@ -38,6 +36,12 @@ fn fuchsia() {}
3836
#[cfg(target_os = "haiku")]
3937
fn haiku() {}
4038

39+
#[cfg(target_os = "illumos")]
40+
fn illumos() {}
41+
42+
#[cfg(target_os = "l4re")]
43+
fn l4re() {}
44+
4145
#[cfg(target_os = "redox")]
4246
fn redox() {}
4347

@@ -47,30 +51,12 @@ fn solaris() {}
4751
#[cfg(target_os = "vxworks")]
4852
fn vxworks() {}
4953

50-
// non-unix
51-
52-
#[cfg(target_os = "cloudabi")]
53-
fn cloudabi() {}
54-
55-
#[cfg(target_os = "hermit")]
56-
fn hermit() {}
57-
58-
#[cfg(target_os = "wasi")]
59-
fn wasi() {}
60-
61-
#[cfg(target_os = "none")]
62-
fn none() {}
63-
6454
// list with conditions
65-
#[cfg(all(not(any(windows, target_os = "linux")), target_os = "freebsd"))]
55+
#[cfg(all(not(any(target_os = "solaris", target_os = "linux")), target_os = "freebsd"))]
6656
fn list() {}
6757

68-
// windows is a valid target family, should be ignored
69-
#[cfg(windows)]
70-
fn windows() {}
71-
7258
// correct use, should be ignored
7359
#[cfg(target_os = "freebsd")]
74-
fn freebsd() {}
60+
fn correct() {}
7561

7662
fn main() {}

tests/ui/mismatched_target_os.rs renamed to tests/ui/mismatched_target_os_unix.rs

+8-22
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#![warn(clippy::mismatched_target_os)]
44
#![allow(unused)]
55

6-
// unix
7-
86
#[cfg(linux)]
97
fn linux() {}
108

@@ -38,6 +36,12 @@ fn fuchsia() {}
3836
#[cfg(haiku)]
3937
fn haiku() {}
4038

39+
#[cfg(illumos)]
40+
fn illumos() {}
41+
42+
#[cfg(l4re)]
43+
fn l4re() {}
44+
4145
#[cfg(redox)]
4246
fn redox() {}
4347

@@ -47,30 +51,12 @@ fn solaris() {}
4751
#[cfg(vxworks)]
4852
fn vxworks() {}
4953

50-
// non-unix
51-
52-
#[cfg(cloudabi)]
53-
fn cloudabi() {}
54-
55-
#[cfg(hermit)]
56-
fn hermit() {}
57-
58-
#[cfg(wasi)]
59-
fn wasi() {}
60-
61-
#[cfg(none)]
62-
fn none() {}
63-
6454
// list with conditions
65-
#[cfg(all(not(any(windows, linux)), freebsd))]
55+
#[cfg(all(not(any(solaris, linux)), freebsd))]
6656
fn list() {}
6757

68-
// windows is a valid target family, should be ignored
69-
#[cfg(windows)]
70-
fn windows() {}
71-
7258
// correct use, should be ignored
7359
#[cfg(target_os = "freebsd")]
74-
fn freebsd() {}
60+
fn correct() {}
7561

7662
fn main() {}

0 commit comments

Comments
 (0)