span_lint_and_then, SpanlessEq,
};
use if_chain::if_chain;
-use rustc::declare_lint_pass;
-use rustc::hir::intravisit::*;
-use rustc::hir::*;
-use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
+use rustc::hir::map::Map;
use rustc_errors::Applicability;
-use rustc_session::declare_tool_lint;
+use rustc_hir::intravisit;
+use rustc_hir::intravisit::*;
+use rustc_hir::*;
+use rustc_lint::{LateContext, LateLintPass};
+use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::Span;
use syntax::ast::LitKind;
// prevent folding of `cfg!` macros and the like
if !e.span.from_expansion() {
match &e.kind {
- ExprKind::Unary(UnNot, inner) => return Ok(Bool::Not(box self.run(inner)?)),
+ ExprKind::Unary(UnOp::UnNot, inner) => return Ok(Bool::Not(box self.run(inner)?)),
ExprKind::Binary(binop, lhs, rhs) => match &binop.node {
BinOpKind::Or => return Ok(Bool::Or(self.extract(BinOpKind::Or, &[lhs, rhs], Vec::new())?)),
BinOpKind::And => return Ok(Bool::And(self.extract(BinOpKind::And, &[lhs, rhs], Vec::new())?)),
}
},
Or(v) => {
- for (index, inner) in v.iter().enumerate() {
+ for (index, inner) in v.iter().rev().enumerate() {
if index > 0 {
self.output.push_str(" || ");
}
}
impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
+ type Map = Map<'tcx>;
+
fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
if in_macro(e.span) {
return;
ExprKind::Binary(binop, _, _) if binop.node == BinOpKind::Or || binop.node == BinOpKind::And => {
self.bool_expr(e)
},
- ExprKind::Unary(UnNot, inner) => {
+ ExprKind::Unary(UnOp::UnNot, inner) => {
if self.cx.tables.node_types()[inner.hir_id].is_bool() {
self.bool_expr(e);
} else {
_ => walk_expr(self, e),
}
}
- fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+ fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}
}
impl<'a, 'tcx> Visitor<'tcx> for NotSimplificationVisitor<'a, 'tcx> {
+ type Map = Map<'tcx>;
+
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
- if let ExprKind::Unary(UnNot, inner) = &expr.kind {
+ if let ExprKind::Unary(UnOp::UnNot, inner) = &expr.kind {
if let Some(suggestion) = simplify_not(self.cx, inner) {
span_lint_and_sugg(
self.cx,
walk_expr(self, expr);
}
- fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+ fn nested_visit_map(&mut self) -> NestedVisitorMap<'_, Self::Map> {
NestedVisitorMap::None
}
}