]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/booleans.rs
Use span_suggestion_with_applicability instead of span_suggestion
[rust.git] / clippy_lints / src / booleans.rs
index eda6a045cba4c90cf6791ac0b14828280b268480..85f6eeb19ef9f22294710dd27dfd218ed3aa6f83 100644 (file)
@@ -1,11 +1,12 @@
-use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use rustc::{declare_lint, lint_array};
-use rustc::hir::*;
-use rustc::hir::intravisit::*;
-use syntax::ast::{LitKind, NodeId, DUMMY_NODE_ID};
-use syntax::source_map::{dummy_spanned, Span, DUMMY_SP};
-use rustc_data_structures::thin_vec::ThinVec;
+use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
+use crate::rustc::{declare_tool_lint, lint_array};
+use crate::rustc::hir::*;
+use crate::rustc::hir::intravisit::*;
+use crate::syntax::ast::{LitKind, NodeId, DUMMY_NODE_ID};
+use crate::syntax::source_map::{dummy_spanned, Span, DUMMY_SP};
+use crate::rustc_data_structures::thin_vec::ThinVec;
 use crate::utils::{in_macro, paths, match_type, snippet_opt, span_lint_and_then, SpanlessEq, get_trait_def_id, implements_trait};
+use crate::rustc_errors::Applicability;
 
 /// **What it does:** Checks for boolean expressions that can be written more
 /// concisely.
@@ -118,7 +119,7 @@ fn run(&mut self, e: &'v Expr) -> Result<Bool, String> {
         }
         for (n, expr) in self.terminals.iter().enumerate() {
             if SpanlessEq::new(self.cx).ignore_fn().eq_expr(e, expr) {
-                #[allow(cast_possible_truncation)]
+                #[allow(clippy::cast_possible_truncation)]
                 return Ok(Bool::Term(n as u8));
             }
             let negated = match e.node {
@@ -150,14 +151,14 @@ fn run(&mut self, e: &'v Expr) -> Result<Bool, String> {
                 _ => continue,
             };
             if SpanlessEq::new(self.cx).ignore_fn().eq_expr(&negated, expr) {
-                #[allow(cast_possible_truncation)]
+                #[allow(clippy::cast_possible_truncation)]
                 return Ok(Bool::Not(Box::new(Bool::Term(n as u8))));
             }
         }
         let n = self.terminals.len();
         self.terminals.push(e);
         if n < 32 {
-            #[allow(cast_possible_truncation)]
+            #[allow(clippy::cast_possible_truncation)]
             Ok(Bool::Term(n as u8))
         } else {
             Err("too many literals".to_owned())
@@ -390,10 +391,11 @@ fn bool_expr(&self, e: &Expr) {
                                     "this expression can be optimized out by applying boolean operations to the \
                                      outer expression",
                                 );
-                                db.span_suggestion(
+                                db.span_suggestion_with_applicability(
                                     e.span,
                                     "it would look like the following",
                                     suggest(self.cx, suggestion, &h2q.terminals).0,
+                                    Applicability::Unspecified,
                                 );
                             },
                         );