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"),
@ -37,27 +37,27 @@ println!("{} {} {}", x, y, z);
{ {
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);
} }