Skip to content

Commit ffa9afe

Browse files
committed
Auto merge of #127541 - estebank:diff-suggestions, r=petrochenkov
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; | ``` before: ``` 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.0f64; | ~~~~ ``` r? `@oli-obk`
2 parents 6171d94 + f0845ad commit ffa9afe

File tree

1,017 files changed

+10364
-6943
lines changed

Some content is hidden

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

1,017 files changed

+10364
-6943
lines changed

compiler/rustc_errors/src/emitter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1982,7 +1982,7 @@ impl HumanEmitter {
19821982
{
19831983
debug!(?complete, ?parts, ?highlights);
19841984

1985-
let has_deletion = parts.iter().any(|p| p.is_deletion(sm));
1985+
let has_deletion = parts.iter().any(|p| p.is_deletion(sm) || p.is_replacement(sm));
19861986
let is_multiline = complete.lines().count() > 1;
19871987

19881988
if i == 0 {

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/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-toml/unwrap_used/unwrap_used.stderr

+45-30
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ LL | let _ = boxed_slice.get(1).unwrap();
88
= help: to override `-D warnings` add `#[allow(clippy::get_unwrap)]`
99
help: using `[]` is clearer and more concise
1010
|
11-
LL | let _ = &boxed_slice[1];
12-
| ~~~~~~~~~~~~~~~
11+
LL - let _ = boxed_slice.get(1).unwrap();
12+
LL + let _ = &boxed_slice[1];
13+
|
1314

1415
error: used `unwrap()` on an `Option` value
1516
--> tests/ui-toml/unwrap_used/unwrap_used.rs:38:17
@@ -30,8 +31,9 @@ LL | let _ = some_slice.get(0).unwrap();
3031
|
3132
help: using `[]` is clearer and more concise
3233
|
33-
LL | let _ = &some_slice[0];
34-
| ~~~~~~~~~~~~~~
34+
LL - let _ = some_slice.get(0).unwrap();
35+
LL + let _ = &some_slice[0];
36+
|
3537

3638
error: used `unwrap()` on an `Option` value
3739
--> tests/ui-toml/unwrap_used/unwrap_used.rs:39:17
@@ -50,8 +52,9 @@ LL | let _ = some_vec.get(0).unwrap();
5052
|
5153
help: using `[]` is clearer and more concise
5254
|
53-
LL | let _ = &some_vec[0];
54-
| ~~~~~~~~~~~~
55+
LL - let _ = some_vec.get(0).unwrap();
56+
LL + let _ = &some_vec[0];
57+
|
5558

5659
error: used `unwrap()` on an `Option` value
5760
--> tests/ui-toml/unwrap_used/unwrap_used.rs:40:17
@@ -70,8 +73,9 @@ LL | let _ = some_vecdeque.get(0).unwrap();
7073
|
7174
help: using `[]` is clearer and more concise
7275
|
73-
LL | let _ = &some_vecdeque[0];
74-
| ~~~~~~~~~~~~~~~~~
76+
LL - let _ = some_vecdeque.get(0).unwrap();
77+
LL + let _ = &some_vecdeque[0];
78+
|
7579

7680
error: used `unwrap()` on an `Option` value
7781
--> tests/ui-toml/unwrap_used/unwrap_used.rs:41:17
@@ -90,8 +94,9 @@ LL | let _ = some_hashmap.get(&1).unwrap();
9094
|
9195
help: using `[]` is clearer and more concise
9296
|
93-
LL | let _ = &some_hashmap[&1];
94-
| ~~~~~~~~~~~~~~~~~
97+
LL - let _ = some_hashmap.get(&1).unwrap();
98+
LL + let _ = &some_hashmap[&1];
99+
|
95100

96101
error: used `unwrap()` on an `Option` value
97102
--> tests/ui-toml/unwrap_used/unwrap_used.rs:42:17
@@ -110,8 +115,9 @@ LL | let _ = some_btreemap.get(&1).unwrap();
110115
|
111116
help: using `[]` is clearer and more concise
112117
|
113-
LL | let _ = &some_btreemap[&1];
114-
| ~~~~~~~~~~~~~~~~~~
118+
LL - let _ = some_btreemap.get(&1).unwrap();
119+
LL + let _ = &some_btreemap[&1];
120+
|
115121

116122
error: used `unwrap()` on an `Option` value
117123
--> tests/ui-toml/unwrap_used/unwrap_used.rs:43:17
@@ -130,8 +136,9 @@ LL | let _: u8 = *boxed_slice.get(1).unwrap();
130136
|
131137
help: using `[]` is clearer and more concise
132138
|
133-
LL | let _: u8 = boxed_slice[1];
134-
| ~~~~~~~~~~~~~~
139+
LL - let _: u8 = *boxed_slice.get(1).unwrap();
140+
LL + let _: u8 = boxed_slice[1];
141+
|
135142

136143
error: used `unwrap()` on an `Option` value
137144
--> tests/ui-toml/unwrap_used/unwrap_used.rs:47:22
@@ -150,8 +157,9 @@ LL | *boxed_slice.get_mut(0).unwrap() = 1;
150157
|
151158
help: using `[]` is clearer and more concise
152159
|
153-
LL | boxed_slice[0] = 1;
154-
| ~~~~~~~~~~~~~~
160+
LL - *boxed_slice.get_mut(0).unwrap() = 1;
161+
LL + boxed_slice[0] = 1;
162+
|
155163

156164
error: used `unwrap()` on an `Option` value
157165
--> tests/ui-toml/unwrap_used/unwrap_used.rs:52:10
@@ -170,8 +178,9 @@ LL | *some_slice.get_mut(0).unwrap() = 1;
170178
|
171179
help: using `[]` is clearer and more concise
172180
|
173-
LL | some_slice[0] = 1;
174-
| ~~~~~~~~~~~~~
181+
LL - *some_slice.get_mut(0).unwrap() = 1;
182+
LL + some_slice[0] = 1;
183+
|
175184

176185
error: used `unwrap()` on an `Option` value
177186
--> tests/ui-toml/unwrap_used/unwrap_used.rs:53:10
@@ -190,8 +199,9 @@ LL | *some_vec.get_mut(0).unwrap() = 1;
190199
|
191200
help: using `[]` is clearer and more concise
192201
|
193-
LL | some_vec[0] = 1;
194-
| ~~~~~~~~~~~
202+
LL - *some_vec.get_mut(0).unwrap() = 1;
203+
LL + some_vec[0] = 1;
204+
|
195205

196206
error: used `unwrap()` on an `Option` value
197207
--> tests/ui-toml/unwrap_used/unwrap_used.rs:54:10
@@ -210,8 +220,9 @@ LL | *some_vecdeque.get_mut(0).unwrap() = 1;
210220
|
211221
help: using `[]` is clearer and more concise
212222
|
213-
LL | some_vecdeque[0] = 1;
214-
| ~~~~~~~~~~~~~~~~
223+
LL - *some_vecdeque.get_mut(0).unwrap() = 1;
224+
LL + some_vecdeque[0] = 1;
225+
|
215226

216227
error: used `unwrap()` on an `Option` value
217228
--> tests/ui-toml/unwrap_used/unwrap_used.rs:55:10
@@ -230,8 +241,9 @@ LL | let _ = some_vec.get(0..1).unwrap().to_vec();
230241
|
231242
help: using `[]` is clearer and more concise
232243
|
233-
LL | let _ = some_vec[0..1].to_vec();
234-
| ~~~~~~~~~~~~~~
244+
LL - let _ = some_vec.get(0..1).unwrap().to_vec();
245+
LL + let _ = some_vec[0..1].to_vec();
246+
|
235247

236248
error: used `unwrap()` on an `Option` value
237249
--> tests/ui-toml/unwrap_used/unwrap_used.rs:67:17
@@ -250,8 +262,9 @@ LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec();
250262
|
251263
help: using `[]` is clearer and more concise
252264
|
253-
LL | let _ = some_vec[0..1].to_vec();
254-
| ~~~~~~~~~~~~~~
265+
LL - let _ = some_vec.get_mut(0..1).unwrap().to_vec();
266+
LL + let _ = some_vec[0..1].to_vec();
267+
|
255268

256269
error: used `unwrap()` on an `Option` value
257270
--> tests/ui-toml/unwrap_used/unwrap_used.rs:68:17
@@ -270,8 +283,9 @@ LL | let _ = boxed_slice.get(1).unwrap();
270283
|
271284
help: using `[]` is clearer and more concise
272285
|
273-
LL | let _ = &boxed_slice[1];
274-
| ~~~~~~~~~~~~~~~
286+
LL - let _ = boxed_slice.get(1).unwrap();
287+
LL + let _ = &boxed_slice[1];
288+
|
275289

276290
error: called `.get().unwrap()` on a slice
277291
--> tests/ui-toml/unwrap_used/unwrap_used.rs:94:17
@@ -281,8 +295,9 @@ LL | let _ = Box::new([0]).get(1).unwrap();
281295
|
282296
help: using `[]` is clearer and more concise
283297
|
284-
LL | let _ = &Box::new([0])[1];
285-
| ~~~~~~~~~~~~~~~~~
298+
LL - let _ = Box::new([0]).get(1).unwrap();
299+
LL + let _ = &Box::new([0])[1];
300+
|
286301

287302
error: aborting due to 28 previous errors
288303

0 commit comments

Comments
 (0)