Skip to content

Commit a9dc677

Browse files
committed
Show diff suggestion format on verbose replacement
``` error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> $DIR/attempted-access-non-fatal.rs:7:15 | LL | let _ = 2.l; | ^ | help: if intended to be a floating point literal, consider adding a `0` after the period and a `f64` suffix | LL - let _ = 2.l; LL + let _ = 2.0f64; | ```
1 parent 3d68afc commit a9dc677

File tree

895 files changed

+8073
-5310
lines changed

Some content is hidden

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

895 files changed

+8073
-5310
lines changed

compiler/rustc_errors/src/emitter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,7 @@ impl HumanEmitter {
18071807
for (complete, parts, highlights, _) in suggestions.iter().take(MAX_SUGGESTIONS) {
18081808
debug!(?complete, ?parts, ?highlights);
18091809

1810-
let has_deletion = parts.iter().any(|p| p.is_deletion(sm));
1810+
let has_deletion = parts.iter().any(|p| p.is_deletion(sm) || p.is_replacement(sm));
18111811
let is_multiline = complete.lines().count() > 1;
18121812

18131813
if let Some(span) = span.primary_span() {

src/tools/clippy/tests/ui-toml/dbg_macro/dbg_macro.stderr

+19-12
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ LL | if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n }
88
= help: to override `-D warnings` add `#[allow(clippy::dbg_macro)]`
99
help: remove the invocation before committing it to a version control system
1010
|
11-
LL | if let Some(n) = n.checked_sub(4) { n } else { n }
12-
| ~~~~~~~~~~~~~~~~
11+
LL - if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n }
12+
LL + if let Some(n) = n.checked_sub(4) { n } else { n }
13+
|
1314

1415
error: the `dbg!` macro is intended as a debugging tool
1516
--> tests/ui-toml/dbg_macro/dbg_macro.rs:10:8
@@ -19,8 +20,9 @@ LL | if dbg!(n <= 1) {
1920
|
2021
help: remove the invocation before committing it to a version control system
2122
|
22-
LL | if n <= 1 {
23-
| ~~~~~~
23+
LL - if dbg!(n <= 1) {
24+
LL + if n <= 1 {
25+
|
2426

2527
error: the `dbg!` macro is intended as a debugging tool
2628
--> tests/ui-toml/dbg_macro/dbg_macro.rs:11:9
@@ -30,7 +32,8 @@ LL | dbg!(1)
3032
|
3133
help: remove the invocation before committing it to a version control system
3234
|
33-
LL | 1
35+
LL - dbg!(1)
36+
LL + 1
3437
|
3538

3639
error: the `dbg!` macro is intended as a debugging tool
@@ -41,7 +44,8 @@ LL | dbg!(n * factorial(n - 1))
4144
|
4245
help: remove the invocation before committing it to a version control system
4346
|
44-
LL | n * factorial(n - 1)
47+
LL - dbg!(n * factorial(n - 1))
48+
LL + n * factorial(n - 1)
4549
|
4650

4751
error: the `dbg!` macro is intended as a debugging tool
@@ -52,8 +56,9 @@ LL | dbg!(42);
5256
|
5357
help: remove the invocation before committing it to a version control system
5458
|
55-
LL | 42;
56-
| ~~
59+
LL - dbg!(42);
60+
LL + 42;
61+
|
5762

5863
error: the `dbg!` macro is intended as a debugging tool
5964
--> tests/ui-toml/dbg_macro/dbg_macro.rs:19:14
@@ -63,8 +68,9 @@ LL | foo(3) + dbg!(factorial(4));
6368
|
6469
help: remove the invocation before committing it to a version control system
6570
|
66-
LL | foo(3) + factorial(4);
67-
| ~~~~~~~~~~~~
71+
LL - foo(3) + dbg!(factorial(4));
72+
LL + foo(3) + factorial(4);
73+
|
6874

6975
error: the `dbg!` macro is intended as a debugging tool
7076
--> tests/ui-toml/dbg_macro/dbg_macro.rs:20:5
@@ -74,8 +80,9 @@ LL | dbg!(1, 2, 3, 4, 5);
7480
|
7581
help: remove the invocation before committing it to a version control system
7682
|
77-
LL | (1, 2, 3, 4, 5);
78-
| ~~~~~~~~~~~~~~~
83+
LL - dbg!(1, 2, 3, 4, 5);
84+
LL + (1, 2, 3, 4, 5);
85+
|
7986

8087
error: aborting due to 7 previous errors
8188

src/tools/clippy/tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ LL | /// TestItemThingyOfCoolness might sound cool but is not on the list and sh
88
= help: to override `-D warnings` add `#[allow(clippy::doc_markdown)]`
99
help: try
1010
|
11-
LL | /// `TestItemThingyOfCoolness` might sound cool but is not on the list and should be linted.
12-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
11+
LL - /// TestItemThingyOfCoolness might sound cool but is not on the list and should be linted.
12+
LL + /// `TestItemThingyOfCoolness` might sound cool but is not on the list and should be linted.
13+
|
1314

1415
error: aborting due to 1 previous error
1516

src/tools/clippy/tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr

+9-6
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ LL | /// OAuth and LaTeX are inside Clippy's default list.
88
= help: to override `-D warnings` add `#[allow(clippy::doc_markdown)]`
99
help: try
1010
|
11-
LL | /// `OAuth` and LaTeX are inside Clippy's default list.
12-
| ~~~~~~~
11+
LL - /// OAuth and LaTeX are inside Clippy's default list.
12+
LL + /// `OAuth` and LaTeX are inside Clippy's default list.
13+
|
1314

1415
error: item in documentation is missing backticks
1516
--> tests/ui-toml/doc_valid_idents_replace/doc_markdown.rs:6:15
@@ -19,8 +20,9 @@ LL | /// OAuth and LaTeX are inside Clippy's default list.
1920
|
2021
help: try
2122
|
22-
LL | /// OAuth and `LaTeX` are inside Clippy's default list.
23-
| ~~~~~~~
23+
LL - /// OAuth and LaTeX are inside Clippy's default list.
24+
LL + /// OAuth and `LaTeX` are inside Clippy's default list.
25+
|
2426

2527
error: item in documentation is missing backticks
2628
--> tests/ui-toml/doc_valid_idents_replace/doc_markdown.rs:9:5
@@ -30,8 +32,9 @@ LL | /// TestItemThingyOfCoolness might sound cool but is not on the list and sh
3032
|
3133
help: try
3234
|
33-
LL | /// `TestItemThingyOfCoolness` might sound cool but is not on the list and should be linted.
34-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
35+
LL - /// TestItemThingyOfCoolness might sound cool but is not on the list and should be linted.
36+
LL + /// `TestItemThingyOfCoolness` might sound cool but is not on the list and should be linted.
37+
|
3538

3639
error: aborting due to 3 previous errors
3740

src/tools/clippy/tests/ui-toml/enum_variant_size/enum_variant_size.stderr

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ LL | | }
1414
= help: to override `-D warnings` add `#[allow(clippy::large_enum_variant)]`
1515
help: consider boxing the large fields to reduce the total size of the enum
1616
|
17-
LL | B(Box<[u8; 501]>),
18-
| ~~~~~~~~~~~~~~
17+
LL - B([u8; 501]),
18+
LL + B(Box<[u8; 501]>),
19+
|
1920

2021
error: aborting due to 1 previous error
2122

src/tools/clippy/tests/ui-toml/max_suggested_slice_pattern_length/index_refutable_slice.stderr

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ LL | #![deny(clippy::index_refutable_slice)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
help: try using a slice pattern here
1313
|
14-
LL | if let Some([_, _, _, _, _, _, _, slice_7, ..]) = slice {
15-
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14+
LL - if let Some(slice) = slice {
15+
LL + if let Some([_, _, _, _, _, _, _, slice_7, ..]) = slice {
16+
|
1617
help: and replace the index expressions here
1718
|
18-
LL | println!("{}", slice_7);
19-
| ~~~~~~~
19+
LL - println!("{}", slice[7]);
20+
LL + println!("{}", slice_7);
21+
|
2022

2123
error: aborting due to 1 previous error
2224

src/tools/clippy/tests/ui-toml/renamed_function_params/renamed_function_params.default.stderr

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ LL | fn hash_slice<H: Hasher>(date: &[Self], states: &mut H) {
3333
|
3434
help: consider using the default names
3535
|
36-
LL | fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) {
37-
| ~~~~ ~~~~~
36+
LL - fn hash_slice<H: Hasher>(date: &[Self], states: &mut H) {
37+
LL + fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) {
38+
|
3839

3940
error: renamed function parameter of trait impl
4041
--> tests/ui-toml/renamed_function_params/renamed_function_params.rs:80:18

src/tools/clippy/tests/ui-toml/renamed_function_params/renamed_function_params.extend.stderr

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ LL | fn hash_slice<H: Hasher>(date: &[Self], states: &mut H) {
2727
|
2828
help: consider using the default names
2929
|
30-
LL | fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) {
31-
| ~~~~ ~~~~~
30+
LL - fn hash_slice<H: Hasher>(date: &[Self], states: &mut H) {
31+
LL + fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) {
32+
|
3233

3334
error: aborting due to 4 previous errors
3435

src/tools/clippy/tests/ui/assign_ops2.stderr

+54-36
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ LL | a += a + 1;
88
= help: to override `-D warnings` add `#[allow(clippy::misrefactored_assign_op)]`
99
help: did you mean `a = a + 1` or `a = a + a + 1`? Consider replacing it with
1010
|
11-
LL | a += 1;
12-
| ~~~~~~
11+
LL - a += a + 1;
12+
LL + a += 1;
13+
|
1314
help: or
1415
|
15-
LL | a = a + a + 1;
16-
| ~~~~~~~~~~~~~
16+
LL - a += a + 1;
17+
LL + a = a + a + 1;
18+
|
1719

1820
error: variable appears on both sides of an assignment operation
1921
--> tests/ui/assign_ops2.rs:11:5
@@ -23,12 +25,14 @@ LL | a += 1 + a;
2325
|
2426
help: did you mean `a = a + 1` or `a = a + 1 + a`? Consider replacing it with
2527
|
26-
LL | a += 1;
27-
| ~~~~~~
28+
LL - a += 1 + a;
29+
LL + a += 1;
30+
|
2831
help: or
2932
|
30-
LL | a = a + 1 + a;
31-
| ~~~~~~~~~~~~~
33+
LL - a += 1 + a;
34+
LL + a = a + 1 + a;
35+
|
3236

3337
error: variable appears on both sides of an assignment operation
3438
--> tests/ui/assign_ops2.rs:13:5
@@ -38,12 +42,14 @@ LL | a -= a - 1;
3842
|
3943
help: did you mean `a = a - 1` or `a = a - (a - 1)`? Consider replacing it with
4044
|
41-
LL | a -= 1;
42-
| ~~~~~~
45+
LL - a -= a - 1;
46+
LL + a -= 1;
47+
|
4348
help: or
4449
|
45-
LL | a = a - (a - 1);
46-
| ~~~~~~~~~~~~~~~
50+
LL - a -= a - 1;
51+
LL + a = a - (a - 1);
52+
|
4753

4854
error: variable appears on both sides of an assignment operation
4955
--> tests/ui/assign_ops2.rs:15:5
@@ -53,12 +59,14 @@ LL | a *= a * 99;
5359
|
5460
help: did you mean `a = a * 99` or `a = a * a * 99`? Consider replacing it with
5561
|
56-
LL | a *= 99;
57-
| ~~~~~~~
62+
LL - a *= a * 99;
63+
LL + a *= 99;
64+
|
5865
help: or
5966
|
60-
LL | a = a * a * 99;
61-
| ~~~~~~~~~~~~~~
67+
LL - a *= a * 99;
68+
LL + a = a * a * 99;
69+
|
6270

6371
error: variable appears on both sides of an assignment operation
6472
--> tests/ui/assign_ops2.rs:17:5
@@ -68,12 +76,14 @@ LL | a *= 42 * a;
6876
|
6977
help: did you mean `a = a * 42` or `a = a * 42 * a`? Consider replacing it with
7078
|
71-
LL | a *= 42;
72-
| ~~~~~~~
79+
LL - a *= 42 * a;
80+
LL + a *= 42;
81+
|
7382
help: or
7483
|
75-
LL | a = a * 42 * a;
76-
| ~~~~~~~~~~~~~~
84+
LL - a *= 42 * a;
85+
LL + a = a * 42 * a;
86+
|
7787

7888
error: variable appears on both sides of an assignment operation
7989
--> tests/ui/assign_ops2.rs:19:5
@@ -83,12 +93,14 @@ LL | a /= a / 2;
8393
|
8494
help: did you mean `a = a / 2` or `a = a / (a / 2)`? Consider replacing it with
8595
|
86-
LL | a /= 2;
87-
| ~~~~~~
96+
LL - a /= a / 2;
97+
LL + a /= 2;
98+
|
8899
help: or
89100
|
90-
LL | a = a / (a / 2);
91-
| ~~~~~~~~~~~~~~~
101+
LL - a /= a / 2;
102+
LL + a = a / (a / 2);
103+
|
92104

93105
error: variable appears on both sides of an assignment operation
94106
--> tests/ui/assign_ops2.rs:21:5
@@ -98,12 +110,14 @@ LL | a %= a % 5;
98110
|
99111
help: did you mean `a = a % 5` or `a = a % (a % 5)`? Consider replacing it with
100112
|
101-
LL | a %= 5;
102-
| ~~~~~~
113+
LL - a %= a % 5;
114+
LL + a %= 5;
115+
|
103116
help: or
104117
|
105-
LL | a = a % (a % 5);
106-
| ~~~~~~~~~~~~~~~
118+
LL - a %= a % 5;
119+
LL + a = a % (a % 5);
120+
|
107121

108122
error: variable appears on both sides of an assignment operation
109123
--> tests/ui/assign_ops2.rs:23:5
@@ -113,12 +127,14 @@ LL | a &= a & 1;
113127
|
114128
help: did you mean `a = a & 1` or `a = a & a & 1`? Consider replacing it with
115129
|
116-
LL | a &= 1;
117-
| ~~~~~~
130+
LL - a &= a & 1;
131+
LL + a &= 1;
132+
|
118133
help: or
119134
|
120-
LL | a = a & a & 1;
121-
| ~~~~~~~~~~~~~
135+
LL - a &= a & 1;
136+
LL + a = a & a & 1;
137+
|
122138

123139
error: variable appears on both sides of an assignment operation
124140
--> tests/ui/assign_ops2.rs:25:5
@@ -128,12 +144,14 @@ LL | a *= a * a;
128144
|
129145
help: did you mean `a = a * a` or `a = a * a * a`? Consider replacing it with
130146
|
131-
LL | a *= a;
132-
| ~~~~~~
147+
LL - a *= a * a;
148+
LL + a *= a;
149+
|
133150
help: or
134151
|
135-
LL | a = a * a * a;
136-
| ~~~~~~~~~~~~~
152+
LL - a *= a * a;
153+
LL + a = a * a * a;
154+
|
137155

138156
error: manual implementation of an assign operation
139157
--> tests/ui/assign_ops2.rs:63:5

0 commit comments

Comments
 (0)