Fix rebase fallout

This commit is contained in:
flip1995 2020-02-05 09:55:48 +01:00
parent 250c1842b1
commit c7979d3515
No known key found for this signature in database
GPG key ID: 693086869D506637
3 changed files with 37 additions and 36 deletions

View file

@ -3,9 +3,9 @@ use crate::utils::paths;
use crate::utils::sugg::Sugg; use crate::utils::sugg::Sugg;
use crate::utils::usage::is_unused; use crate::utils::usage::is_unused;
use crate::utils::{ use crate::utils::{
expr_block, get_arg_name, in_macro, is_allowed, is_expn_of, is_refutable, is_wild, match_qpath, match_type, expr_block, get_arg_name, in_macro, indent_of, is_allowed, is_expn_of, is_refutable, is_wild, match_qpath,
match_var, multispan_sugg, remove_blocks, snippet, snippet_block, snippet_with_applicability, span_lint_and_help, match_type, match_var, multispan_sugg, remove_blocks, snippet, snippet_block, snippet_with_applicability,
span_lint_and_note, span_lint_and_sugg, span_lint_and_then, walk_ptrs_ty, span_lint_and_help, span_lint_and_note, span_lint_and_sugg, span_lint_and_then, walk_ptrs_ty,
}; };
use if_chain::if_chain; use if_chain::if_chain;
use rustc::lint::in_external_macro; use rustc::lint::in_external_macro;
@ -836,7 +836,7 @@ fn check_match_single_binding(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[A
let mut snippet_body = if match_body.span.from_expansion() { let mut snippet_body = if match_body.span.from_expansion() {
Sugg::hir_with_macro_callsite(cx, match_body, "..").to_string() Sugg::hir_with_macro_callsite(cx, match_body, "..").to_string()
} else { } else {
snippet_block(cx, match_body.span, "..").to_owned().to_string() snippet_block(cx, match_body.span, "..", Some(expr.span)).to_string()
}; };
// Do we need to add ';' to suggestion ? // Do we need to add ';' to suggestion ?
@ -865,10 +865,11 @@ fn check_match_single_binding(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[A
"this match could be written as a `let` statement", "this match could be written as a `let` statement",
"consider using `let` statement", "consider using `let` statement",
format!( format!(
"let {} = {};\n{}", "let {} = {};\n{}{}",
snippet_with_applicability(cx, bind_names, "..", &mut applicability), snippet_with_applicability(cx, bind_names, "..", &mut applicability),
snippet_with_applicability(cx, matched_vars, "..", &mut applicability), snippet_with_applicability(cx, matched_vars, "..", &mut applicability),
snippet_body " ".repeat(indent_of(cx, expr.span).unwrap_or(0)),
snippet_body,
), ),
applicability, applicability,
); );

View file

@ -14,12 +14,12 @@ fn main() {
let c = 3; let c = 3;
// Lint // Lint
let (x, y, z) = (a, b, c); let (x, y, z) = (a, b, c);
{ {
println!("{} {} {}", x, y, z); println!("{} {} {}", x, y, z);
} }
// Lint // Lint
let (x, y, z) = (a, b, c); let (x, y, z) = (a, b, c);
println!("{} {} {}", x, y, z); println!("{} {} {}", x, y, z);
// Ok // Ok
match a { match a {
2 => println!("2"), 2 => println!("2"),
@ -35,29 +35,29 @@ println!("{} {} {}", x, y, z);
println!("whatever"); println!("whatever");
// Lint // Lint
{ {
let x = 29; let x = 29;
println!("x has a value of {}", x); println!("x has a value of {}", x);
} }
// Lint // Lint
{ {
let e = 5 * a; let e = 5 * a;
if e >= 5 { if e >= 5 {
println!("e is superior to 5"); println!("e is superior to 5");
}
} }
}
// Lint // Lint
let p = Point { x: 0, y: 7 }; let p = Point { x: 0, y: 7 };
let Point { x, y } = p; let Point { x, y } = p;
println!("Coords: ({}, {})", x, y); println!("Coords: ({}, {})", x, y);
// Lint // Lint
let Point { x: x1, y: y1 } = p; let Point { x: x1, y: y1 } = p;
println!("Coords: ({}, {})", x1, y1); println!("Coords: ({}, {})", x1, y1);
// Lint // Lint
let x = 5; let x = 5;
let ref r = x; let ref r = x;
println!("Got a reference to {}", r); println!("Got a reference to {}", r);
// Lint // Lint
let mut x = 5; let mut x = 5;
let ref mut mr = x; let ref mut mr = x;
println!("Got a mutable reference to {}", mr); println!("Got a mutable reference to {}", mr);
} }

View file

@ -12,9 +12,9 @@ LL | | }
help: consider using `let` statement help: consider using `let` statement
| |
LL | let (x, y, z) = (a, b, c); LL | let (x, y, z) = (a, b, c);
LL | { LL | {
LL | println!("{} {} {}", x, y, z); LL | println!("{} {} {}", x, y, z);
LL | } LL | }
| |
error: this match could be written as a `let` statement error: this match could be written as a `let` statement
@ -28,7 +28,7 @@ LL | | }
help: consider using `let` statement help: consider using `let` statement
| |
LL | let (x, y, z) = (a, b, c); LL | let (x, y, z) = (a, b, c);
LL | println!("{} {} {}", x, y, z); LL | println!("{} {} {}", x, y, z);
| |
error: this match could be replaced by its body itself error: this match could be replaced by its body itself
@ -53,9 +53,9 @@ LL | | }
help: consider using the match body instead help: consider using the match body instead
| |
LL | { LL | {
LL | let x = 29; LL | let x = 29;
LL | println!("x has a value of {}", x); LL | println!("x has a value of {}", x);
LL | } LL | }
| |
error: this match could be replaced by its body itself error: this match could be replaced by its body itself
@ -73,11 +73,11 @@ LL | | }
help: consider using the match body instead help: consider using the match body instead
| |
LL | { LL | {
LL | let e = 5 * a; LL | let e = 5 * a;
LL | if e >= 5 { LL | if e >= 5 {
LL | println!("e is superior to 5"); LL | println!("e is superior to 5");
LL | }
LL | } LL | }
LL | }
| |
error: this match could be written as a `let` statement error: this match could be written as a `let` statement
@ -91,7 +91,7 @@ LL | | }
help: consider using `let` statement help: consider using `let` statement
| |
LL | let Point { x, y } = p; LL | let Point { x, y } = p;
LL | println!("Coords: ({}, {})", x, y); LL | println!("Coords: ({}, {})", x, y);
| |
error: this match could be written as a `let` statement error: this match could be written as a `let` statement
@ -105,7 +105,7 @@ LL | | }
help: consider using `let` statement help: consider using `let` statement
| |
LL | let Point { x: x1, y: y1 } = p; LL | let Point { x: x1, y: y1 } = p;
LL | println!("Coords: ({}, {})", x1, y1); LL | println!("Coords: ({}, {})", x1, y1);
| |
error: this match could be written as a `let` statement error: this match could be written as a `let` statement
@ -119,7 +119,7 @@ LL | | }
help: consider using `let` statement help: consider using `let` statement
| |
LL | let ref r = x; LL | let ref r = x;
LL | println!("Got a reference to {}", r); LL | println!("Got a reference to {}", r);
| |
error: this match could be written as a `let` statement error: this match could be written as a `let` statement
@ -133,7 +133,7 @@ LL | | }
help: consider using `let` statement help: consider using `let` statement
| |
LL | let ref mut mr = x; LL | let ref mut mr = x;
LL | println!("Got a mutable reference to {}", mr); LL | println!("Got a mutable reference to {}", mr);
| |
error: aborting due to 9 previous errors error: aborting due to 9 previous errors