Skip to content

Commit 4e89ffa

Browse files
committed
Auto merge of rust-lang#9640 - Alexendoo:edition-revisions, r=llogiq
Fix edition revision ui tests rust-lang#9605 had me wondering how the edition revision tests were working for `manual_assert` but not for `@nyurik,` but it turns out `manual_assert`'s tests weren't working either. I checked how `rust-lang/rust` does it and apparently it comes down to whitespace, `//[rev] edition:X` works 😬 Removes the revisions from `match_wild_err_arm` as I couldn't find any edition dependant behaviour there r? `@llogiq` changelog: none
2 parents fe3200c + 124caeb commit 4e89ffa

13 files changed

+55
-188
lines changed

tests/ui/manual_assert.edition2018.fixed

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// revisions: edition2018 edition2021
2-
// [edition2018] edition:2018
3-
// [edition2021] edition:2021
2+
//[edition2018] edition:2018
3+
//[edition2021] edition:2021
44
// run-rustfix
55

66
#![warn(clippy::manual_assert)]
@@ -29,7 +29,9 @@ fn main() {
2929
panic!("qaqaq{:?}", a);
3030
}
3131
assert!(a.is_empty(), "qaqaq{:?}", a);
32-
assert!(a.is_empty(), "qwqwq");
32+
if !a.is_empty() {
33+
panic!("qwqwq");
34+
}
3335
if a.len() == 3 {
3436
println!("qwq");
3537
println!("qwq");
@@ -44,21 +46,32 @@ fn main() {
4446
println!("qwq");
4547
}
4648
let b = vec![1, 2, 3];
47-
assert!(!b.is_empty(), "panic1");
48-
assert!(!(b.is_empty() && a.is_empty()), "panic2");
49-
assert!(!(a.is_empty() && !b.is_empty()), "panic3");
50-
assert!(!(b.is_empty() || a.is_empty()), "panic4");
51-
assert!(!(a.is_empty() || !b.is_empty()), "panic5");
49+
if b.is_empty() {
50+
panic!("panic1");
51+
}
52+
if b.is_empty() && a.is_empty() {
53+
panic!("panic2");
54+
}
55+
if a.is_empty() && !b.is_empty() {
56+
panic!("panic3");
57+
}
58+
if b.is_empty() || a.is_empty() {
59+
panic!("panic4");
60+
}
61+
if a.is_empty() || !b.is_empty() {
62+
panic!("panic5");
63+
}
5264
assert!(!a.is_empty(), "with expansion {}", one!());
5365
}
5466

5567
fn issue7730(a: u8) {
5668
// Suggestion should preserve comment
57-
// comment
58-
/* this is a
69+
if a > 2 {
70+
// comment
71+
/* this is a
5972
multiline
6073
comment */
61-
/// Doc comment
62-
// comment after `panic!`
63-
assert!(!(a > 2), "panic with comment");
74+
/// Doc comment
75+
panic!("panic with comment") // comment after `panic!`
76+
}
6477
}

tests/ui/manual_assert.edition2018.stderr

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -12,84 +12,6 @@ help: try instead
1212
LL | assert!(a.is_empty(), "qaqaq{:?}", a);
1313
|
1414

15-
error: only a `panic!` in `if`-then statement
16-
--> $DIR/manual_assert.rs:34:5
17-
|
18-
LL | / if !a.is_empty() {
19-
LL | | panic!("qwqwq");
20-
LL | | }
21-
| |_____^
22-
|
23-
help: try instead
24-
|
25-
LL | assert!(a.is_empty(), "qwqwq");
26-
|
27-
28-
error: only a `panic!` in `if`-then statement
29-
--> $DIR/manual_assert.rs:51:5
30-
|
31-
LL | / if b.is_empty() {
32-
LL | | panic!("panic1");
33-
LL | | }
34-
| |_____^
35-
|
36-
help: try instead
37-
|
38-
LL | assert!(!b.is_empty(), "panic1");
39-
|
40-
41-
error: only a `panic!` in `if`-then statement
42-
--> $DIR/manual_assert.rs:54:5
43-
|
44-
LL | / if b.is_empty() && a.is_empty() {
45-
LL | | panic!("panic2");
46-
LL | | }
47-
| |_____^
48-
|
49-
help: try instead
50-
|
51-
LL | assert!(!(b.is_empty() && a.is_empty()), "panic2");
52-
|
53-
54-
error: only a `panic!` in `if`-then statement
55-
--> $DIR/manual_assert.rs:57:5
56-
|
57-
LL | / if a.is_empty() && !b.is_empty() {
58-
LL | | panic!("panic3");
59-
LL | | }
60-
| |_____^
61-
|
62-
help: try instead
63-
|
64-
LL | assert!(!(a.is_empty() && !b.is_empty()), "panic3");
65-
|
66-
67-
error: only a `panic!` in `if`-then statement
68-
--> $DIR/manual_assert.rs:60:5
69-
|
70-
LL | / if b.is_empty() || a.is_empty() {
71-
LL | | panic!("panic4");
72-
LL | | }
73-
| |_____^
74-
|
75-
help: try instead
76-
|
77-
LL | assert!(!(b.is_empty() || a.is_empty()), "panic4");
78-
|
79-
80-
error: only a `panic!` in `if`-then statement
81-
--> $DIR/manual_assert.rs:63:5
82-
|
83-
LL | / if a.is_empty() || !b.is_empty() {
84-
LL | | panic!("panic5");
85-
LL | | }
86-
| |_____^
87-
|
88-
help: try instead
89-
|
90-
LL | assert!(!(a.is_empty() || !b.is_empty()), "panic5");
91-
|
92-
9315
error: only a `panic!` in `if`-then statement
9416
--> $DIR/manual_assert.rs:66:5
9517
|
@@ -103,22 +25,5 @@ help: try instead
10325
LL | assert!(!a.is_empty(), "with expansion {}", one!());
10426
|
10527

106-
error: only a `panic!` in `if`-then statement
107-
--> $DIR/manual_assert.rs:73:5
108-
|
109-
LL | / if a > 2 {
110-
LL | | // comment
111-
LL | | /* this is a
112-
LL | | multiline
113-
... |
114-
LL | | panic!("panic with comment") // comment after `panic!`
115-
LL | | }
116-
| |_____^
117-
|
118-
help: try instead
119-
|
120-
LL | assert!(!(a > 2), "panic with comment");
121-
|
122-
123-
error: aborting due to 9 previous errors
28+
error: aborting due to 2 previous errors
12429

tests/ui/manual_assert.edition2021.fixed

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// revisions: edition2018 edition2021
2-
// [edition2018] edition:2018
3-
// [edition2021] edition:2021
2+
//[edition2018] edition:2018
3+
//[edition2021] edition:2021
44
// run-rustfix
55

66
#![warn(clippy::manual_assert)]

tests/ui/manual_assert.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// revisions: edition2018 edition2021
2-
// [edition2018] edition:2018
3-
// [edition2021] edition:2021
2+
//[edition2018] edition:2018
3+
//[edition2021] edition:2021
44
// run-rustfix
55

66
#![warn(clippy::manual_assert)]

tests/ui/match_wild_err_arm.edition2021.stderr

Lines changed: 0 additions & 35 deletions
This file was deleted.

tests/ui/match_wild_err_arm.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// revisions: edition2018 edition2021
2-
// [edition2018] edition:2018
3-
// [edition2021] edition:2021
41
#![feature(exclusive_range_pattern)]
52
#![allow(clippy::match_same_arms)]
63
#![warn(clippy::match_wild_err_arm)]

tests/ui/match_wild_err_arm.edition2018.stderr renamed to tests/ui/match_wild_err_arm.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `Err(_)` matches all errors
2-
--> $DIR/match_wild_err_arm.rs:14:9
2+
--> $DIR/match_wild_err_arm.rs:11:9
33
|
44
LL | Err(_) => panic!("err"),
55
| ^^^^^^
@@ -8,23 +8,23 @@ LL | Err(_) => panic!("err"),
88
= note: `-D clippy::match-wild-err-arm` implied by `-D warnings`
99

1010
error: `Err(_)` matches all errors
11-
--> $DIR/match_wild_err_arm.rs:20:9
11+
--> $DIR/match_wild_err_arm.rs:17:9
1212
|
1313
LL | Err(_) => panic!(),
1414
| ^^^^^^
1515
|
1616
= note: match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable
1717

1818
error: `Err(_)` matches all errors
19-
--> $DIR/match_wild_err_arm.rs:26:9
19+
--> $DIR/match_wild_err_arm.rs:23:9
2020
|
2121
LL | Err(_) => {
2222
| ^^^^^^
2323
|
2424
= note: match each error separately or use the error output, or use `.expect(msg)` if the error case is unreachable
2525

2626
error: `Err(_e)` matches all errors
27-
--> $DIR/match_wild_err_arm.rs:34:9
27+
--> $DIR/match_wild_err_arm.rs:31:9
2828
|
2929
LL | Err(_e) => panic!(),
3030
| ^^^^^^^

tests/ui/uninlined_format_args_2021.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

tests/ui/uninlined_format_args_2018.fixed renamed to tests/ui/uninlined_format_args_panic.edition2018.fixed

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
// revisions: edition2018 edition2021
2+
//[edition2018] edition:2018
3+
//[edition2021] edition:2021
14
// run-rustfix
2-
// edition:2018
35

46
#![warn(clippy::uninlined_format_args)]
57

tests/ui/uninlined_format_args_2018.stderr renamed to tests/ui/uninlined_format_args_panic.edition2018.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: variables can be used directly in the `format!` string
2-
--> $DIR/uninlined_format_args_2018.rs:9:5
2+
--> $DIR/uninlined_format_args_panic.rs:11:5
33
|
44
LL | println!("val='{}'", var);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/uninlined_format_args_2021.fixed renamed to tests/ui/uninlined_format_args_panic.edition2021.fixed

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
// revisions: edition2018 edition2021
2+
//[edition2018] edition:2018
3+
//[edition2021] edition:2021
14
// run-rustfix
2-
// edition:2021
35

46
#![warn(clippy::uninlined_format_args)]
57

@@ -17,7 +19,11 @@ fn main() {
1719
if var > 0 {
1820
panic!("p3 {var}");
1921
}
20-
if var > 0 {
21-
panic!("p4 {var}");
22+
23+
#[allow(non_fmt_panics)]
24+
{
25+
if var > 0 {
26+
panic!("p4 {var}");
27+
}
2228
}
2329
}

tests/ui/uninlined_format_args_2021.stderr renamed to tests/ui/uninlined_format_args_panic.edition2021.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: variables can be used directly in the `format!` string
2-
--> $DIR/uninlined_format_args_2021.rs:9:5
2+
--> $DIR/uninlined_format_args_panic.rs:11:5
33
|
44
LL | println!("val='{}'", var);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -12,7 +12,7 @@ LL + println!("val='{var}'");
1212
|
1313

1414
error: variables can be used directly in the `format!` string
15-
--> $DIR/uninlined_format_args_2021.rs:12:9
15+
--> $DIR/uninlined_format_args_panic.rs:14:9
1616
|
1717
LL | panic!("p1 {}", var);
1818
| ^^^^^^^^^^^^^^^^^^^^
@@ -24,7 +24,7 @@ LL + panic!("p1 {var}");
2424
|
2525

2626
error: variables can be used directly in the `format!` string
27-
--> $DIR/uninlined_format_args_2021.rs:15:9
27+
--> $DIR/uninlined_format_args_panic.rs:17:9
2828
|
2929
LL | panic!("p2 {0}", var);
3030
| ^^^^^^^^^^^^^^^^^^^^^
@@ -36,7 +36,7 @@ LL + panic!("p2 {var}");
3636
|
3737

3838
error: variables can be used directly in the `format!` string
39-
--> $DIR/uninlined_format_args_2021.rs:18:9
39+
--> $DIR/uninlined_format_args_panic.rs:20:9
4040
|
4141
LL | panic!("p3 {var}", var = var);
4242
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/uninlined_format_args_2018.rs renamed to tests/ui/uninlined_format_args_panic.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
// revisions: edition2018 edition2021
2+
//[edition2018] edition:2018
3+
//[edition2021] edition:2021
14
// run-rustfix
2-
// edition:2018
35

46
#![warn(clippy::uninlined_format_args)]
57

0 commit comments

Comments
 (0)