Skip to content

Commit 851e9fa

Browse files
committed
Rework the suspicious formatting lints.
1 parent dfd4cf7 commit 851e9fa

23 files changed

+1607
-521
lines changed

clippy_lints/src/formatting.rs

Lines changed: 246 additions & 159 deletions
Large diffs are not rendered by default.

tests/ui/formatting.rs

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

tests/ui/formatting.stderr

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//@aux-build:../auxiliary/proc_macros.rs
2+
#![deny(clippy::possible_missing_comma)]
3+
4+
use proc_macros::{external, inline_macros, with_span};
5+
6+
#[rustfmt::skip]
7+
#[inline_macros]
8+
fn main() {
9+
{
10+
let x = 20;
11+
let y = &32;
12+
13+
let _ = [1, 2, *y]; //~ possible_missing_comma
14+
let _ = [1, 2, -x]; //~ possible_missing_comma
15+
let _ = [1, x - 2, -x]; //~ possible_missing_comma
16+
let _ = [1, 2, -x - 2]; //~ possible_missing_comma
17+
let _ = [1, 2 * x * 2, -x]; //~ possible_missing_comma
18+
19+
let _ = [
20+
1,
21+
x,
22+
-2 * x * 2, //~ possible_missing_comma
23+
-x, //~ possible_missing_comma
24+
];
25+
26+
let _ = (1, &x); //~ possible_missing_comma
27+
let _ = (1, x, -1); //~ possible_missing_comma
28+
29+
let _ = (1-x);
30+
let _ = (1- x);
31+
let _ = (1 -/* comment */x);
32+
let _ = (1, 2*y - 5);
33+
let _ = (1, 2 /x);
34+
let _ = (1, 2 <x);
35+
let _ = (1, 2 !=x);
36+
let _ = (1, 2 |x);
37+
let _ = (1, 2 <<x);
38+
39+
let _ = [
40+
1
41+
- x,
42+
x
43+
* y,
44+
];
45+
}
46+
47+
{
48+
let x = true;
49+
let y = false;
50+
51+
let _ = (y, &&x); //~ possible_missing_comma
52+
let _ = (y && x);
53+
let _ = (y&&x);
54+
}
55+
56+
with_span! {
57+
span
58+
let x = 0;
59+
let _ = (x -1);
60+
}
61+
62+
external! {
63+
let x = 0;
64+
let _ = (x -1);
65+
}
66+
67+
inline! {
68+
let x = 0;
69+
let _ = (x, -1); //~ possible_missing_comma
70+
let _ = (x, -$(@tt 1)); //~ possible_missing_comma
71+
let _ = ($(@expr x -1));
72+
let _ = (x $(@tt -)1);
73+
}
74+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//@aux-build:../auxiliary/proc_macros.rs
2+
#![deny(clippy::possible_missing_comma)]
3+
4+
use proc_macros::{external, inline_macros, with_span};
5+
6+
#[rustfmt::skip]
7+
#[inline_macros]
8+
fn main() {
9+
{
10+
let x = 20;
11+
let y = &32;
12+
13+
let _ = [1, 2 * y]; //~ possible_missing_comma
14+
let _ = [1, 2 - x]; //~ possible_missing_comma
15+
let _ = [1, x - 2 - x]; //~ possible_missing_comma
16+
let _ = [1, 2 - x - 2]; //~ possible_missing_comma
17+
let _ = [1, 2 * x * 2 - x]; //~ possible_missing_comma
18+
19+
let _ = [
20+
1,
21+
x
22+
- 2 * x * 2 //~ possible_missing_comma
23+
- x, //~ possible_missing_comma
24+
];
25+
26+
let _ = (1 & x); //~ possible_missing_comma
27+
let _ = (1, x - 1); //~ possible_missing_comma
28+
29+
let _ = (1-x);
30+
let _ = (1- x);
31+
let _ = (1 -/* comment */x);
32+
let _ = (1, 2*y - 5);
33+
let _ = (1, 2 /x);
34+
let _ = (1, 2 <x);
35+
let _ = (1, 2 !=x);
36+
let _ = (1, 2 |x);
37+
let _ = (1, 2 <<x);
38+
39+
let _ = [
40+
1
41+
- x,
42+
x
43+
* y,
44+
];
45+
}
46+
47+
{
48+
let x = true;
49+
let y = false;
50+
51+
let _ = (y && x); //~ possible_missing_comma
52+
let _ = (y && x);
53+
let _ = (y&&x);
54+
}
55+
56+
with_span! {
57+
span
58+
let x = 0;
59+
let _ = (x -1);
60+
}
61+
62+
external! {
63+
let x = 0;
64+
let _ = (x -1);
65+
}
66+
67+
inline! {
68+
let x = 0;
69+
let _ = (x - 1); //~ possible_missing_comma
70+
let _ = (x - $(@tt 1)); //~ possible_missing_comma
71+
let _ = ($(@expr x -1));
72+
let _ = (x $(@tt -)1);
73+
}
74+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//@aux-build:../auxiliary/proc_macros.rs
2+
#![deny(clippy::possible_missing_comma)]
3+
4+
use proc_macros::{external, inline_macros, with_span};
5+
6+
#[rustfmt::skip]
7+
#[inline_macros]
8+
fn main() {
9+
{
10+
let x = 20;
11+
let y = &32;
12+
13+
let _ = [1, 2 *y]; //~ possible_missing_comma
14+
let _ = [1, 2 -x]; //~ possible_missing_comma
15+
let _ = [1, x - 2 -x]; //~ possible_missing_comma
16+
let _ = [1, 2 -x - 2]; //~ possible_missing_comma
17+
let _ = [1, 2 * x * 2 -x]; //~ possible_missing_comma
18+
19+
let _ = [
20+
1,
21+
x
22+
-2 * x * 2 //~ possible_missing_comma
23+
-x, //~ possible_missing_comma
24+
];
25+
26+
let _ = (1 &x); //~ possible_missing_comma
27+
let _ = (1, x -1); //~ possible_missing_comma
28+
29+
let _ = (1-x);
30+
let _ = (1- x);
31+
let _ = (1 -/* comment */x);
32+
let _ = (1, 2*y - 5);
33+
let _ = (1, 2 /x);
34+
let _ = (1, 2 <x);
35+
let _ = (1, 2 !=x);
36+
let _ = (1, 2 |x);
37+
let _ = (1, 2 <<x);
38+
39+
let _ = [
40+
1
41+
- x,
42+
x
43+
* y,
44+
];
45+
}
46+
47+
{
48+
let x = true;
49+
let y = false;
50+
51+
let _ = (y &&x); //~ possible_missing_comma
52+
let _ = (y && x);
53+
let _ = (y&&x);
54+
}
55+
56+
with_span! {
57+
span
58+
let x = 0;
59+
let _ = (x -1);
60+
}
61+
62+
external! {
63+
let x = 0;
64+
let _ = (x -1);
65+
}
66+
67+
inline! {
68+
let x = 0;
69+
let _ = (x -1); //~ possible_missing_comma
70+
let _ = (x -$(@tt 1)); //~ possible_missing_comma
71+
let _ = ($(@expr x -1));
72+
let _ = (x $(@tt -)1);
73+
}
74+
}

0 commit comments

Comments
 (0)