Skip to content

Commit

Permalink
Show diff suggestion format on verbose replacement
Browse files Browse the repository at this point in the history
```
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;
   |
```
  • Loading branch information
estebank committed Jul 19, 2024
1 parent 3811f40 commit 75646df
Show file tree
Hide file tree
Showing 902 changed files with 8,599 additions and 5,767 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 @@ -1807,7 +1807,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

90 changes: 54 additions & 36 deletions src/tools/clippy/tests/ui/assign_ops2.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ LL | a += a + 1;
= help: to override `-D warnings` add `#[allow(clippy::misrefactored_assign_op)]`
help: did you mean `a = a + 1` or `a = a + a + 1`? Consider replacing it with
|
LL | a += 1;
| ~~~~~~
LL - a += a + 1;
LL + a += 1;
|
help: or
|
LL | a = a + a + 1;
| ~~~~~~~~~~~~~
LL - a += a + 1;
LL + a = a + a + 1;
|

error: variable appears on both sides of an assignment operation
--> tests/ui/assign_ops2.rs:11:5
Expand All @@ -23,12 +25,14 @@ LL | a += 1 + a;
|
help: did you mean `a = a + 1` or `a = a + 1 + a`? Consider replacing it with
|
LL | a += 1;
| ~~~~~~
LL - a += 1 + a;
LL + a += 1;
|
help: or
|
LL | a = a + 1 + a;
| ~~~~~~~~~~~~~
LL - a += 1 + a;
LL + a = a + 1 + a;
|

error: variable appears on both sides of an assignment operation
--> tests/ui/assign_ops2.rs:13:5
Expand All @@ -38,12 +42,14 @@ LL | a -= a - 1;
|
help: did you mean `a = a - 1` or `a = a - (a - 1)`? Consider replacing it with
|
LL | a -= 1;
| ~~~~~~
LL - a -= a - 1;
LL + a -= 1;
|
help: or
|
LL | a = a - (a - 1);
| ~~~~~~~~~~~~~~~
LL - a -= a - 1;
LL + a = a - (a - 1);
|

error: variable appears on both sides of an assignment operation
--> tests/ui/assign_ops2.rs:15:5
Expand All @@ -53,12 +59,14 @@ LL | a *= a * 99;
|
help: did you mean `a = a * 99` or `a = a * a * 99`? Consider replacing it with
|
LL | a *= 99;
| ~~~~~~~
LL - a *= a * 99;
LL + a *= 99;
|
help: or
|
LL | a = a * a * 99;
| ~~~~~~~~~~~~~~
LL - a *= a * 99;
LL + a = a * a * 99;
|

error: variable appears on both sides of an assignment operation
--> tests/ui/assign_ops2.rs:17:5
Expand All @@ -68,12 +76,14 @@ LL | a *= 42 * a;
|
help: did you mean `a = a * 42` or `a = a * 42 * a`? Consider replacing it with
|
LL | a *= 42;
| ~~~~~~~
LL - a *= 42 * a;
LL + a *= 42;
|
help: or
|
LL | a = a * 42 * a;
| ~~~~~~~~~~~~~~
LL - a *= 42 * a;
LL + a = a * 42 * a;
|

error: variable appears on both sides of an assignment operation
--> tests/ui/assign_ops2.rs:19:5
Expand All @@ -83,12 +93,14 @@ LL | a /= a / 2;
|
help: did you mean `a = a / 2` or `a = a / (a / 2)`? Consider replacing it with
|
LL | a /= 2;
| ~~~~~~
LL - a /= a / 2;
LL + a /= 2;
|
help: or
|
LL | a = a / (a / 2);
| ~~~~~~~~~~~~~~~
LL - a /= a / 2;
LL + a = a / (a / 2);
|

error: variable appears on both sides of an assignment operation
--> tests/ui/assign_ops2.rs:21:5
Expand All @@ -98,12 +110,14 @@ LL | a %= a % 5;
|
help: did you mean `a = a % 5` or `a = a % (a % 5)`? Consider replacing it with
|
LL | a %= 5;
| ~~~~~~
LL - a %= a % 5;
LL + a %= 5;
|
help: or
|
LL | a = a % (a % 5);
| ~~~~~~~~~~~~~~~
LL - a %= a % 5;
LL + a = a % (a % 5);
|

error: variable appears on both sides of an assignment operation
--> tests/ui/assign_ops2.rs:23:5
Expand All @@ -113,12 +127,14 @@ LL | a &= a & 1;
|
help: did you mean `a = a & 1` or `a = a & a & 1`? Consider replacing it with
|
LL | a &= 1;
| ~~~~~~
LL - a &= a & 1;
LL + a &= 1;
|
help: or
|
LL | a = a & a & 1;
| ~~~~~~~~~~~~~
LL - a &= a & 1;
LL + a = a & a & 1;
|

error: variable appears on both sides of an assignment operation
--> tests/ui/assign_ops2.rs:25:5
Expand All @@ -128,12 +144,14 @@ LL | a *= a * a;
|
help: did you mean `a = a * a` or `a = a * a * a`? Consider replacing it with
|
LL | a *= a;
| ~~~~~~
LL - a *= a * a;
LL + a *= a;
|
help: or
|
LL | a = a * a * a;
| ~~~~~~~~~~~~~
LL - a *= a * a;
LL + a = a * a * a;
|

error: manual implementation of an assign operation
--> tests/ui/assign_ops2.rs:63:5
Expand Down
Loading

0 comments on commit 75646df

Please sign in to comment.