//! This lint is **warn** by default
use if_chain::if_chain;
+use rustc_ast::ast;
use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint};
-use syntax::ast;
use crate::utils::sugg::Sugg;
use crate::utils::{snippet_block, snippet_block_with_applicability, span_lint_and_sugg, span_lint_and_then};
COLLAPSIBLE_IF,
block.span,
"this `else { if .. }` block can be collapsed",
- "try",
+ "collapse nested if block",
snippet_block_with_applicability(cx, else_.span, "..", Some(block.span), &mut applicability).into_owned(),
applicability,
);
if expr.span.ctxt() != inner.span.ctxt() {
return;
}
- span_lint_and_then(cx, COLLAPSIBLE_IF, expr.span, "this `if` statement can be collapsed", |db| {
+ span_lint_and_then(cx, COLLAPSIBLE_IF, expr.span, "this `if` statement can be collapsed", |diag| {
let lhs = Sugg::ast(cx, check, "..");
let rhs = Sugg::ast(cx, check_inner, "..");
- db.span_suggestion(
+ diag.span_suggestion(
expr.span,
- "try",
+ "collapse nested if block",
format!(
"if {} {}",
lhs.and(&rhs),