Fix indents

This commit is contained in:
Vitaly _Vi Shukela
2018-09-18 18:07:54 +03:00
committed by flip1995
parent 2781cac839
commit 3eccccb367
26 changed files with 253 additions and 235 deletions

View File

@@ -418,12 +418,14 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
NONMINIMAL_BOOL,
e.span,
"this boolean expression can be simplified",
|db| { db.span_suggestions_with_applicability(
|db| {
db.span_suggestions_with_applicability(
e.span,
"try",
suggestions,
Applicability::Unspecified,
); },
);
},
);
};
if improvements.is_empty() {

View File

@@ -134,11 +134,14 @@ fn check_collapsible_no_if_let(cx: &EarlyContext<'_>, expr: &ast::Expr, check: &
span_lint_and_then(cx, COLLAPSIBLE_IF, expr.span, "this if statement can be collapsed", |db| {
let lhs = Sugg::ast(cx, check, "..");
let rhs = Sugg::ast(cx, check_inner, "..");
db.span_suggestion_with_applicability(expr.span,
db.span_suggestion_with_applicability(
expr.span,
"try",
format!("if {} {}",
format!(
"if {} {}",
lhs.and(&rhs),
snippet_block(cx, content.span, "..")),
snippet_block(cx, content.span, ".."),
),
Applicability::Unspecified,
);
});

View File

@@ -133,7 +133,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EqOp {
right.span,
"use the right value directly",
rsnip,
Applicability::Unspecified,);
Applicability::Unspecified,
);
},
)
}

View File

@@ -239,10 +239,12 @@ fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr
variant,
snippet(cx, binding.pat.span, "_"),
snippet(cx, var_arg.span, "_"));
db.span_suggestion_with_applicability(stmt.span,
db.span_suggestion_with_applicability(
stmt.span,
"try this",
suggestion,
Applicability::Unspecified);
Applicability::Unspecified,
);
}
});
}

View File

@@ -295,12 +295,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
l.pat.span,
"`ref` on an entire `let` pattern is discouraged, take a reference with `&` instead",
|db| {
db.span_suggestion_with_applicability(s.span,
db.span_suggestion_with_applicability(
s.span,
"try",
format!("let {name}{tyopt} = {initref};",
format!(
"let {name}{tyopt} = {initref};",
name=snippet(cx, i.span, "_"),
tyopt=tyopt,
initref=initref),
initref=initref,
),
Applicability::Unspecified,
);
}
@@ -323,9 +326,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
db.span_suggestion_with_applicability(
s.span,
"replace it with",
format!("if {} {{ {}; }}",
format!(
"if {} {{ {}; }}",
sugg,
&snippet(cx, b.span, "..")),
&snippet(cx, b.span, ".."),
),
Applicability::Unspecified,
);
});

View File

@@ -151,13 +151,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
let end = Sugg::hir(cx, y, "y");
if let Some(is_wrapped) = &snippet_opt(cx, expr.span) {
if is_wrapped.starts_with('(') && is_wrapped.ends_with(')') {
db.span_suggestion_with_applicability(expr.span,
db.span_suggestion_with_applicability(
expr.span,
"use",
format!("({}..={})", start, end),
Applicability::Unspecified,
);
} else {
db.span_suggestion_with_applicability(expr.span,
db.span_suggestion_with_applicability(
expr.span,
"use",
format!("{}..={}", start, end),
Applicability::Unspecified,
@@ -182,7 +184,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|db| {
let start = start.map_or(String::new(), |x| Sugg::hir(cx, x, "x").to_string());
let end = Sugg::hir(cx, y, "y");
db.span_suggestion_with_applicability(expr.span,
db.span_suggestion_with_applicability(
expr.span,
"use",
format!("{}..{}", start, end),
Applicability::Unspecified,

View File

@@ -189,9 +189,11 @@ fn check_suspicious_swap(cx: &LateContext<'_, '_>, block: &Block) {
db.span_suggestion_with_applicability(
span,
"try",
format!("std::mem::swap({}, {})",
format!(
"std::mem::swap({}, {})",
lhs,
rhs),
rhs,
),
Applicability::Unspecified,
);
db.note("or maybe you should use `std::mem::replace`?");