about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-05-08 12:23:24 +0000
committerbors <bors@rust-lang.org>2024-05-08 12:23:24 +0000
commit30b3b73aa67f686db7370e490bf830ab2ddca8d6 (patch)
treecb06aebd77cdb472051036ad8fcb44cbec3b13ab /tests
parentbefb659145a734e51a3708ff84315ae07123c880 (diff)
parent362ef42b68567bfa963f53cce1dc7419b0d64ef6 (diff)
downloadrust-30b3b73aa67f686db7370e490bf830ab2ddca8d6.tar.gz
rust-30b3b73aa67f686db7370e490bf830ab2ddca8d6.zip
Auto merge of #12777 - roife:merge-fixes-needless-late-init, r=Alexendoo
fix: merge multiple suggestions into a single multi-span suggestion in `needless_late_init`

See https://github.com/rust-lang/rust-analyzer/issues/17163#issuecomment-2097840922.

Currently, the fix for `needless_late_init` would modify multiple parts in the file. However, these modifications are exported as separate suggestions instead of a unified 'multi-part suggestion'.

Consequently, rust-analyzer is unable to perform the fix correctly when applying suggestions automatically, as only one suggestion is processed at a time. This PR addresses this issue by merge all modifications into a single multi-part suggestion.

changelog: [`needless_late_init`]: merge multiple fixes into a single multi-span fix.
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/needless_late_init.stderr177
1 files changed, 81 insertions, 96 deletions
diff --git a/tests/ui/needless_late_init.stderr b/tests/ui/needless_late_init.stderr
index 1695784030d..ce64861fa40 100644
--- a/tests/ui/needless_late_init.stderr
+++ b/tests/ui/needless_late_init.stderr
@@ -8,10 +8,11 @@ LL |     a = "zero";
    |
    = note: `-D clippy::needless-late-init` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::needless_late_init)]`
-help: declare `a` here
+help: move the declaration `a` here
+   |
+LL ~     
+LL ~     let a = "zero";
    |
-LL |     let a = "zero";
-   |     ~~~~~
 
 error: unneeded late initialization
   --> tests/ui/needless_late_init.rs:30:5
@@ -22,10 +23,12 @@ LL |     let c;
 LL |     b = 1;
    |     ^^^^^ initialised here
    |
-help: declare `b` here
+help: move the declaration `b` here
+   |
+LL ~     
+LL |     let c;
+LL ~     let b = 1;
    |
-LL |     let b = 1;
-   |     ~~~~~
 
 error: unneeded late initialization
   --> tests/ui/needless_late_init.rs:31:5
@@ -36,10 +39,12 @@ LL |     b = 1;
 LL |     c = 2;
    |     ^^^^^ initialised here
    |
-help: declare `c` here
+help: move the declaration `c` here
+   |
+LL ~     
+LL |     b = 1;
+LL ~     let c = 2;
    |
-LL |     let c = 2;
-   |     ~~~~~
 
 error: unneeded late initialization
   --> tests/ui/needless_late_init.rs:35:5
@@ -49,10 +54,11 @@ LL |     let d: usize;
 LL |     d = 1;
    |     ^^^^^ initialised here
    |
-help: declare `d` here
+help: move the declaration `d` here
+   |
+LL ~     
+LL ~     let d: usize = 1;
    |
-LL |     let d: usize = 1;
-   |     ~~~~~~~~~~~~
 
 error: unneeded late initialization
   --> tests/ui/needless_late_init.rs:38:5
@@ -62,10 +68,11 @@ LL |     let e;
 LL |     e = format!("{}", d);
    |     ^^^^^^^^^^^^^^^^^^^^ initialised here
    |
-help: declare `e` here
+help: move the declaration `e` here
+   |
+LL ~     
+LL ~     let e = format!("{}", d);
    |
-LL |     let e = format!("{}", d);
-   |     ~~~~~
 
 error: unneeded late initialization
   --> tests/ui/needless_late_init.rs:43:5
@@ -73,20 +80,17 @@ error: unneeded late initialization
 LL |     let a;
    |     ^^^^^^
    |
-help: declare `a` here
-   |
-LL |     let a = match n {
-   |     +++++++
-help: remove the assignments from the `match` arms
+help: move the declaration `a` here and remove the assignments from the `match` arms
    |
+LL ~     
+LL |     let n = 1;
+LL ~     let a = match n {
 LL ~         1 => "one",
 LL |         _ => {
 LL ~             "two"
+LL |         },
+LL ~     };
    |
-help: add a semicolon after the `match` expression
-   |
-LL |     };
-   |      +
 
 error: unneeded late initialization
   --> tests/ui/needless_late_init.rs:52:5
@@ -94,20 +98,15 @@ error: unneeded late initialization
 LL |     let b;
    |     ^^^^^^
    |
-help: declare `b` here
-   |
-LL |     let b = if n == 3 {
-   |     +++++++
-help: remove the assignments from the branches
+help: move the declaration `b` here and remove the assignments from the branches
    |
+LL ~     
+LL ~     let b = if n == 3 {
 LL ~         "four"
 LL |     } else {
 LL ~         "five"
+LL ~     };
    |
-help: add a semicolon after the `if` expression
-   |
-LL |     };
-   |      +
 
 error: unneeded late initialization
   --> tests/ui/needless_late_init.rs:59:5
@@ -115,20 +114,16 @@ error: unneeded late initialization
 LL |     let d;
    |     ^^^^^^
    |
-help: declare `d` here
-   |
-LL |     let d = if true {
-   |     +++++++
-help: remove the assignments from the branches
+help: move the declaration `d` here and remove the assignments from the branches
    |
+LL ~     
+LL ~     let d = if true {
+LL |         let temp = 5;
 LL ~         temp
 LL |     } else {
 LL ~         15
+LL ~     };
    |
-help: add a semicolon after the `if` expression
-   |
-LL |     };
-   |      +
 
 error: unneeded late initialization
   --> tests/ui/needless_late_init.rs:67:5
@@ -136,20 +131,15 @@ error: unneeded late initialization
 LL |     let e;
    |     ^^^^^^
    |
-help: declare `e` here
-   |
-LL |     let e = if true {
-   |     +++++++
-help: remove the assignments from the branches
+help: move the declaration `e` here and remove the assignments from the branches
    |
+LL ~     
+LL ~     let e = if true {
 LL ~         format!("{} {}", a, b)
 LL |     } else {
 LL ~         format!("{}", n)
+LL ~     };
    |
-help: add a semicolon after the `if` expression
-   |
-LL |     };
-   |      +
 
 error: unneeded late initialization
   --> tests/ui/needless_late_init.rs:74:5
@@ -157,14 +147,11 @@ error: unneeded late initialization
 LL |     let f;
    |     ^^^^^^
    |
-help: declare `f` here
-   |
-LL |     let f = match 1 {
-   |     +++++++
-help: remove the assignments from the `match` arms
+help: move the declaration `f` here and remove the assignments from the `match` arms
    |
-LL -         1 => f = "three",
-LL +         1 => "three",
+LL ~     
+LL ~     let f = match 1 {
+LL ~         1 => "three",
    |
 
 error: unneeded late initialization
@@ -173,19 +160,15 @@ error: unneeded late initialization
 LL |     let g: usize;
    |     ^^^^^^^^^^^^^
    |
-help: declare `g` here
-   |
-LL |     let g: usize = if true {
-   |     ++++++++++++++
-help: remove the assignments from the branches
-   |
-LL -         g = 5;
-LL +         5
+help: move the declaration `g` here and remove the assignments from the branches
    |
-help: add a semicolon after the `if` expression
+LL ~     
+LL ~     let g: usize = if true {
+LL ~         5
+LL |     } else {
+LL |         panic!();
+LL ~     };
    |
-LL |     };
-   |      +
 
 error: unneeded late initialization
   --> tests/ui/needless_late_init.rs:88:5
@@ -196,10 +179,12 @@ LL |     let y = SignificantDrop;
 LL |     x = 1;
    |     ^^^^^ initialised here
    |
-help: declare `x` here
+help: move the declaration `x` here
+   |
+LL ~     
+LL |     let y = SignificantDrop;
+LL ~     let x = 1;
    |
-LL |     let x = 1;
-   |     ~~~~~
 
 error: unneeded late initialization
   --> tests/ui/needless_late_init.rs:92:5
@@ -210,10 +195,12 @@ LL |     let y = 1;
 LL |     x = SignificantDrop;
    |     ^^^^^^^^^^^^^^^^^^^ initialised here
    |
-help: declare `x` here
+help: move the declaration `x` here
+   |
+LL ~     
+LL |     let y = 1;
+LL ~     let x = SignificantDrop;
    |
-LL |     let x = SignificantDrop;
-   |     ~~~~~
 
 error: unneeded late initialization
   --> tests/ui/needless_late_init.rs:96:5
@@ -224,10 +211,14 @@ LL |     let x;
 LL |     x = SignificantDrop;
    |     ^^^^^^^^^^^^^^^^^^^ initialised here
    |
-help: declare `x` here
+help: move the declaration `x` here
+   |
+LL ~     
+LL |     // types that should be considered insignificant
+ ...
+LL |     let y = Box::new(4);
+LL ~     let x = SignificantDrop;
    |
-LL |     let x = SignificantDrop;
-   |     ~~~~~
 
 error: unneeded late initialization
   --> tests/ui/needless_late_init.rs:115:5
@@ -235,20 +226,17 @@ error: unneeded late initialization
 LL |     let a;
    |     ^^^^^^
    |
-help: declare `a` here
-   |
-LL |     let a = match n {
-   |     +++++++
-help: remove the assignments from the `match` arms
+help: move the declaration `a` here and remove the assignments from the `match` arms
    |
+LL ~     
+LL |     let n = 1;
+LL ~     let a = match n {
 LL ~         1 => f().await,
 LL |         _ => {
 LL ~             "two"
+LL |         },
+LL ~     };
    |
-help: add a semicolon after the `match` expression
-   |
-LL |     };
-   |      +
 
 error: unneeded late initialization
   --> tests/ui/needless_late_init.rs:132:5
@@ -256,20 +244,17 @@ error: unneeded late initialization
 LL |     let a;
    |     ^^^^^^
    |
-help: declare `a` here
-   |
-LL |     let a = match n {
-   |     +++++++
-help: remove the assignments from the `match` arms
+help: move the declaration `a` here and remove the assignments from the `match` arms
    |
+LL ~     
+LL |     let n = 1;
+LL ~     let a = match n {
 LL ~         1 => f(),
 LL |         _ => {
 LL ~             "two"
+LL |         },
+LL ~     };
    |
-help: add a semicolon after the `match` expression
-   |
-LL |     };
-   |      +
 
 error: aborting due to 16 previous errors