Skip to content

Commit

Permalink
Auto merge of rust-lang#127541 - estebank:diff-suggestions, r=petroch…
Browse files Browse the repository at this point in the history
…enkov

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`
  • Loading branch information
bors committed Aug 15, 2024
2 parents c416a6f + 420364d commit e2838d4
Show file tree
Hide file tree
Showing 918 changed files with 9,169 additions and 6,138 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1828,7 +1828,7 @@ impl HumanEmitter {
for (complete, parts, highlights, _) in suggestions.iter().take(MAX_SUGGESTIONS) {
debug!(?complete, ?parts, ?highlights);

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

if let Some(span) = span.primary_span() {
Expand Down
31 changes: 19 additions & 12 deletions src/tools/clippy/tests/ui-toml/dbg_macro/dbg_macro.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ LL | if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n }
= help: to override `-D warnings` add `#[allow(clippy::dbg_macro)]`
help: remove the invocation before committing it to a version control system
|
LL | if let Some(n) = n.checked_sub(4) { n } else { n }
| ~~~~~~~~~~~~~~~~
LL - if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n }
LL + if let Some(n) = n.checked_sub(4) { n } else { n }
|

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

error: the `dbg!` macro is intended as a debugging tool
--> tests/ui-toml/dbg_macro/dbg_macro.rs:11:9
Expand All @@ -30,7 +32,8 @@ LL | dbg!(1)
|
help: remove the invocation before committing it to a version control system
|
LL | 1
LL - dbg!(1)
LL + 1
|

error: the `dbg!` macro is intended as a debugging tool
Expand All @@ -41,7 +44,8 @@ LL | dbg!(n * factorial(n - 1))
|
help: remove the invocation before committing it to a version control system
|
LL | n * factorial(n - 1)
LL - dbg!(n * factorial(n - 1))
LL + n * factorial(n - 1)
|

error: the `dbg!` macro is intended as a debugging tool
Expand All @@ -52,8 +56,9 @@ LL | dbg!(42);
|
help: remove the invocation before committing it to a version control system
|
LL | 42;
| ~~
LL - dbg!(42);
LL + 42;
|

error: the `dbg!` macro is intended as a debugging tool
--> tests/ui-toml/dbg_macro/dbg_macro.rs:19:14
Expand All @@ -63,8 +68,9 @@ LL | foo(3) + dbg!(factorial(4));
|
help: remove the invocation before committing it to a version control system
|
LL | foo(3) + factorial(4);
| ~~~~~~~~~~~~
LL - foo(3) + dbg!(factorial(4));
LL + foo(3) + factorial(4);
|

error: the `dbg!` macro is intended as a debugging tool
--> tests/ui-toml/dbg_macro/dbg_macro.rs:20:5
Expand All @@ -74,8 +80,9 @@ LL | dbg!(1, 2, 3, 4, 5);
|
help: remove the invocation before committing it to a version control system
|
LL | (1, 2, 3, 4, 5);
| ~~~~~~~~~~~~~~~
LL - dbg!(1, 2, 3, 4, 5);
LL + (1, 2, 3, 4, 5);
|

error: aborting due to 7 previous errors

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ LL | /// TestItemThingyOfCoolness might sound cool but is not on the list and sh
= help: to override `-D warnings` add `#[allow(clippy::doc_markdown)]`
help: try
|
LL | /// `TestItemThingyOfCoolness` might sound cool but is not on the list and should be linted.
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
LL - /// TestItemThingyOfCoolness might sound cool but is not on the list and should be linted.
LL + /// `TestItemThingyOfCoolness` might sound cool but is not on the list and should be linted.
|

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ LL | /// OAuth and LaTeX are inside Clippy's default list.
= help: to override `-D warnings` add `#[allow(clippy::doc_markdown)]`
help: try
|
LL | /// `OAuth` and LaTeX are inside Clippy's default list.
| ~~~~~~~
LL - /// OAuth and LaTeX are inside Clippy's default list.
LL + /// `OAuth` and LaTeX are inside Clippy's default list.
|

error: item in documentation is missing backticks
--> tests/ui-toml/doc_valid_idents_replace/doc_markdown.rs:6:15
Expand All @@ -19,8 +20,9 @@ LL | /// OAuth and LaTeX are inside Clippy's default list.
|
help: try
|
LL | /// OAuth and `LaTeX` are inside Clippy's default list.
| ~~~~~~~
LL - /// OAuth and LaTeX are inside Clippy's default list.
LL + /// OAuth and `LaTeX` are inside Clippy's default list.
|

error: item in documentation is missing backticks
--> tests/ui-toml/doc_valid_idents_replace/doc_markdown.rs:9:5
Expand All @@ -30,8 +32,9 @@ LL | /// TestItemThingyOfCoolness might sound cool but is not on the list and sh
|
help: try
|
LL | /// `TestItemThingyOfCoolness` might sound cool but is not on the list and should be linted.
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
LL - /// TestItemThingyOfCoolness might sound cool but is not on the list and should be linted.
LL + /// `TestItemThingyOfCoolness` might sound cool but is not on the list and should be linted.
|

error: aborting due to 3 previous errors

Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ LL | | }
= help: to override `-D warnings` add `#[allow(clippy::large_enum_variant)]`
help: consider boxing the large fields to reduce the total size of the enum
|
LL | B(Box<[u8; 501]>),
| ~~~~~~~~~~~~~~
LL - B([u8; 501]),
LL + B(Box<[u8; 501]>),
|

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ LL | #![deny(clippy::index_refutable_slice)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: try using a slice pattern here
|
LL | if let Some([_, _, _, _, _, _, _, slice_7, ..]) = slice {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
LL - if let Some(slice) = slice {
LL + if let Some([_, _, _, _, _, _, _, slice_7, ..]) = slice {
|
help: and replace the index expressions here
|
LL | println!("{}", slice_7);
| ~~~~~~~
LL - println!("{}", slice[7]);
LL + println!("{}", slice_7);
|

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ LL | fn hash_slice<H: Hasher>(date: &[Self], states: &mut H) {
|
help: consider using the default names
|
LL | fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) {
| ~~~~ ~~~~~
LL - fn hash_slice<H: Hasher>(date: &[Self], states: &mut H) {
LL + fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) {
|

error: renamed function parameter of trait impl
--> tests/ui-toml/renamed_function_params/renamed_function_params.rs:80:18
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ LL | fn hash_slice<H: Hasher>(date: &[Self], states: &mut H) {
|
help: consider using the default names
|
LL | fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) {
| ~~~~ ~~~~~
LL - fn hash_slice<H: Hasher>(date: &[Self], states: &mut H) {
LL + fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) {
|

error: aborting due to 4 previous errors

75 changes: 45 additions & 30 deletions src/tools/clippy/tests/ui-toml/unwrap_used/unwrap_used.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ LL | let _ = boxed_slice.get(1).unwrap();
= help: to override `-D warnings` add `#[allow(clippy::get_unwrap)]`
help: using `[]` is clearer and more concise
|
LL | let _ = &boxed_slice[1];
| ~~~~~~~~~~~~~~~
LL - let _ = boxed_slice.get(1).unwrap();
LL + let _ = &boxed_slice[1];
|

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

error: used `unwrap()` on an `Option` value
--> tests/ui-toml/unwrap_used/unwrap_used.rs:39:17
Expand All @@ -50,8 +52,9 @@ LL | let _ = some_vec.get(0).unwrap();
|
help: using `[]` is clearer and more concise
|
LL | let _ = &some_vec[0];
| ~~~~~~~~~~~~
LL - let _ = some_vec.get(0).unwrap();
LL + let _ = &some_vec[0];
|

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

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

error: used `unwrap()` on an `Option` value
--> tests/ui-toml/unwrap_used/unwrap_used.rs:42:17
Expand All @@ -110,8 +115,9 @@ LL | let _ = some_btreemap.get(&1).unwrap();
|
help: using `[]` is clearer and more concise
|
LL | let _ = &some_btreemap[&1];
| ~~~~~~~~~~~~~~~~~~
LL - let _ = some_btreemap.get(&1).unwrap();
LL + let _ = &some_btreemap[&1];
|

error: used `unwrap()` on an `Option` value
--> tests/ui-toml/unwrap_used/unwrap_used.rs:43:17
Expand All @@ -130,8 +136,9 @@ LL | let _: u8 = *boxed_slice.get(1).unwrap();
|
help: using `[]` is clearer and more concise
|
LL | let _: u8 = boxed_slice[1];
| ~~~~~~~~~~~~~~
LL - let _: u8 = *boxed_slice.get(1).unwrap();
LL + let _: u8 = boxed_slice[1];
|

error: used `unwrap()` on an `Option` value
--> tests/ui-toml/unwrap_used/unwrap_used.rs:47:22
Expand All @@ -150,8 +157,9 @@ LL | *boxed_slice.get_mut(0).unwrap() = 1;
|
help: using `[]` is clearer and more concise
|
LL | boxed_slice[0] = 1;
| ~~~~~~~~~~~~~~
LL - *boxed_slice.get_mut(0).unwrap() = 1;
LL + boxed_slice[0] = 1;
|

error: used `unwrap()` on an `Option` value
--> tests/ui-toml/unwrap_used/unwrap_used.rs:52:10
Expand All @@ -170,8 +178,9 @@ LL | *some_slice.get_mut(0).unwrap() = 1;
|
help: using `[]` is clearer and more concise
|
LL | some_slice[0] = 1;
| ~~~~~~~~~~~~~
LL - *some_slice.get_mut(0).unwrap() = 1;
LL + some_slice[0] = 1;
|

error: used `unwrap()` on an `Option` value
--> tests/ui-toml/unwrap_used/unwrap_used.rs:53:10
Expand All @@ -190,8 +199,9 @@ LL | *some_vec.get_mut(0).unwrap() = 1;
|
help: using `[]` is clearer and more concise
|
LL | some_vec[0] = 1;
| ~~~~~~~~~~~
LL - *some_vec.get_mut(0).unwrap() = 1;
LL + some_vec[0] = 1;
|

error: used `unwrap()` on an `Option` value
--> tests/ui-toml/unwrap_used/unwrap_used.rs:54:10
Expand All @@ -210,8 +220,9 @@ LL | *some_vecdeque.get_mut(0).unwrap() = 1;
|
help: using `[]` is clearer and more concise
|
LL | some_vecdeque[0] = 1;
| ~~~~~~~~~~~~~~~~
LL - *some_vecdeque.get_mut(0).unwrap() = 1;
LL + some_vecdeque[0] = 1;
|

error: used `unwrap()` on an `Option` value
--> tests/ui-toml/unwrap_used/unwrap_used.rs:55:10
Expand All @@ -230,8 +241,9 @@ LL | let _ = some_vec.get(0..1).unwrap().to_vec();
|
help: using `[]` is clearer and more concise
|
LL | let _ = some_vec[0..1].to_vec();
| ~~~~~~~~~~~~~~
LL - let _ = some_vec.get(0..1).unwrap().to_vec();
LL + let _ = some_vec[0..1].to_vec();
|

error: used `unwrap()` on an `Option` value
--> tests/ui-toml/unwrap_used/unwrap_used.rs:67:17
Expand All @@ -250,8 +262,9 @@ LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec();
|
help: using `[]` is clearer and more concise
|
LL | let _ = some_vec[0..1].to_vec();
| ~~~~~~~~~~~~~~
LL - let _ = some_vec.get_mut(0..1).unwrap().to_vec();
LL + let _ = some_vec[0..1].to_vec();
|

error: used `unwrap()` on an `Option` value
--> tests/ui-toml/unwrap_used/unwrap_used.rs:68:17
Expand All @@ -270,8 +283,9 @@ LL | let _ = boxed_slice.get(1).unwrap();
|
help: using `[]` is clearer and more concise
|
LL | let _ = &boxed_slice[1];
| ~~~~~~~~~~~~~~~
LL - let _ = boxed_slice.get(1).unwrap();
LL + let _ = &boxed_slice[1];
|

error: called `.get().unwrap()` on a slice
--> tests/ui-toml/unwrap_used/unwrap_used.rs:93:17
Expand All @@ -281,8 +295,9 @@ LL | let _ = Box::new([0]).get(1).unwrap();
|
help: using `[]` is clearer and more concise
|
LL | let _ = &Box::new([0])[1];
| ~~~~~~~~~~~~~~~~~
LL - let _ = Box::new([0]).get(1).unwrap();
LL + let _ = &Box::new([0])[1];
|

error: aborting due to 28 previous errors

Loading

0 comments on commit e2838d4

Please sign in to comment.