Fix rebase and clippy tests

This commit is contained in:
Esteban Kuber
2021-11-16 22:06:25 +00:00
parent d8af82e4bb
commit 1c3747e7dd
4 changed files with 22 additions and 55 deletions

View File

@@ -73,7 +73,7 @@ fn contains_assign_expr<'tcx>(cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'tcx>) ->
seen seen
} }
#[derive(Debug)] #[derive(Debug, Clone)]
struct LocalAssign { struct LocalAssign {
lhs_id: HirId, lhs_id: HirId,
lhs_span: Span, lhs_span: Span,
@@ -154,9 +154,14 @@ fn assignment_suggestions<'tcx>(
assignments.push(assign); assignments.push(assign);
} }
let suggestions = assignments let suggestions = assignments.clone()
.into_iter() .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)>>>()?; .collect::<Option<Vec<(Span, String)>>>()?;
let applicability = if suggestions.len() > 1 { let applicability = if suggestions.len() > 1 {

View File

@@ -1,38 +0,0 @@
// run-rustfix
#![allow(unused, clippy::assign_op_pattern)]
fn main() {
let a = "zero";
let b = 1;
let c = 2;
let d: usize = 1;
let mut e = 1;
e = 2;
let f = match 1 {
1 => "three",
_ => return,
}; // has semi
let g: usize = if true {
5
} else {
panic!();
};
let h = format!("{}", e);
println!("{}", a);
}

View File

@@ -1,5 +1,3 @@
// run-rustfix
#![allow(unused, clippy::assign_op_pattern)] #![allow(unused, clippy::assign_op_pattern)]
fn main() { fn main() {

View File

@@ -1,5 +1,5 @@
error: unneeded late initalization error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:6:5 --> $DIR/needless_late_init_fixable.rs:4:5
| |
LL | let a; LL | let a;
| ^^^^^^ | ^^^^^^
@@ -11,7 +11,7 @@ LL | let a = "zero";
| ~~~~~ | ~~~~~
error: unneeded late initalization error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:9:5 --> $DIR/needless_late_init_fixable.rs:7:5
| |
LL | let b; LL | let b;
| ^^^^^^ | ^^^^^^
@@ -22,7 +22,7 @@ LL | let b = 1;
| ~~~~~ | ~~~~~
error: unneeded late initalization error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:10:5 --> $DIR/needless_late_init_fixable.rs:8:5
| |
LL | let c; LL | let c;
| ^^^^^^ | ^^^^^^
@@ -33,7 +33,7 @@ LL | let c = 2;
| ~~~~~ | ~~~~~
error: unneeded late initalization error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:14:5 --> $DIR/needless_late_init_fixable.rs:12:5
| |
LL | let d: usize; LL | let d: usize;
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
@@ -44,7 +44,7 @@ LL | let d: usize = 1;
| ~~~~~~~~~~~~ | ~~~~~~~~~~~~
error: unneeded late initalization error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:17:5 --> $DIR/needless_late_init_fixable.rs:15:5
| |
LL | let mut e; LL | let mut e;
| ^^^^^^^^^^ | ^^^^^^^^^^
@@ -55,7 +55,7 @@ LL | let mut e = 1;
| ~~~~~~~~~ | ~~~~~~~~~
error: unneeded late initalization error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:21:5 --> $DIR/needless_late_init_fixable.rs:19:5
| |
LL | let f; LL | let f;
| ^^^^^^ | ^^^^^^
@@ -66,11 +66,12 @@ LL | let f = match 1 {
| +++++++ | +++++++
help: remove the assignments from the `match` arms help: remove the assignments from the `match` arms
| |
LL | 1 => "three", LL - 1 => f = "three",
| ~~~~~~~ LL + 1 => "three",
|
error: unneeded late initalization error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:27:5 --> $DIR/needless_late_init_fixable.rs:25:5
| |
LL | let g: usize; LL | let g: usize;
| ^^^^^^^^^^^^^ | ^^^^^^^^^^^^^
@@ -81,7 +82,8 @@ LL | let g: usize = if true {
| ++++++++++++++ | ++++++++++++++
help: remove the assignments from the branches help: remove the assignments from the branches
| |
LL | 5 LL - g = 5;
LL + 5
| |
help: add a semicolon after the `if` expression help: add a semicolon after the `if` expression
| |
@@ -89,7 +91,7 @@ LL | };
| + | +
error: unneeded late initalization error: unneeded late initalization
--> $DIR/needless_late_init_fixable.rs:34:5 --> $DIR/needless_late_init_fixable.rs:32:5
| |
LL | let h; LL | let h;
| ^^^^^^ | ^^^^^^