Skip to content

Commit

Permalink
Fix rebase and clippy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Dec 13, 2021
1 parent d8af82e commit 1c3747e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 55 deletions.
11 changes: 8 additions & 3 deletions clippy_lints/src/needless_late_init.rs
Expand Up @@ -73,7 +73,7 @@ fn contains_assign_expr<'tcx>(cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'tcx>) ->
seen
}

#[derive(Debug)]
#[derive(Debug, Clone)]
struct LocalAssign {
lhs_id: HirId,
lhs_span: Span,
Expand Down Expand Up @@ -154,9 +154,14 @@ fn assignment_suggestions<'tcx>(
assignments.push(assign);
}

let suggestions = assignments
let suggestions = assignments.clone()
.into_iter()
.map(|assignment| Some((assignment.span, snippet_opt(cx, assignment.rhs_span)?)))
.map(|assignment| Some((assignment.span.until(assignment.rhs_span), String::new())))
.chain(
assignments
.into_iter()
.map(|assignment| Some((assignment.rhs_span.shrink_to_hi().with_hi(assignment.span.hi()), String::new())))
)
.collect::<Option<Vec<(Span, String)>>>()?;

let applicability = if suggestions.len() > 1 {
Expand Down
38 changes: 0 additions & 38 deletions tests/ui/needless_late_init_fixable.fixed

This file was deleted.

2 changes: 0 additions & 2 deletions tests/ui/needless_late_init_fixable.rs
@@ -1,5 +1,3 @@
// run-rustfix

#![allow(unused, clippy::assign_op_pattern)]

fn main() {
Expand Down
26 changes: 14 additions & 12 deletions tests/ui/needless_late_init_fixable.stderr
@@ -1,5 +1,5 @@
error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:6:5
--> $DIR/needless_late_init_fixable.rs:4:5
|
LL | let a;
| ^^^^^^
Expand All @@ -11,7 +11,7 @@ LL | let a = "zero";
| ~~~~~

error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:9:5
--> $DIR/needless_late_init_fixable.rs:7:5
|
LL | let b;
| ^^^^^^
Expand All @@ -22,7 +22,7 @@ LL | let b = 1;
| ~~~~~

error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:10:5
--> $DIR/needless_late_init_fixable.rs:8:5
|
LL | let c;
| ^^^^^^
Expand All @@ -33,7 +33,7 @@ LL | let c = 2;
| ~~~~~

error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:14:5
--> $DIR/needless_late_init_fixable.rs:12:5
|
LL | let d: usize;
| ^^^^^^^^^^^^^
Expand All @@ -44,7 +44,7 @@ LL | let d: usize = 1;
| ~~~~~~~~~~~~

error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:17:5
--> $DIR/needless_late_init_fixable.rs:15:5
|
LL | let mut e;
| ^^^^^^^^^^
Expand All @@ -55,7 +55,7 @@ LL | let mut e = 1;
| ~~~~~~~~~

error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:21:5
--> $DIR/needless_late_init_fixable.rs:19:5
|
LL | let f;
| ^^^^^^
Expand All @@ -66,11 +66,12 @@ LL | let f = match 1 {
| +++++++
help: remove the assignments from the `match` arms
|
LL | 1 => "three",
| ~~~~~~~
LL - 1 => f = "three",
LL + 1 => "three",
|

error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:27:5
--> $DIR/needless_late_init_fixable.rs:25:5
|
LL | let g: usize;
| ^^^^^^^^^^^^^
Expand All @@ -81,15 +82,16 @@ LL | let g: usize = if true {
| ++++++++++++++
help: remove the assignments from the branches
|
LL | 5
|
LL - g = 5;
LL + 5
|
help: add a semicolon after the `if` expression
|
LL | };
| +

error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:34:5
--> $DIR/needless_late_init_fixable.rs:32:5
|
LL | let h;
| ^^^^^^
Expand Down

0 comments on commit 1c3747e

Please sign in to comment.