]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/misc_early.rs
rustup https://github.com/rust-lang/rust/pull/67455
[rust.git] / clippy_lints / src / misc_early.rs
index 43a5e5c1b4b1b6e4942ab8d6f9a50c0e77b086ee..7f70de01daaacbbd7970640e29a4cbf981c421b5 100644 (file)
@@ -3,10 +3,11 @@
     span_lint_and_then,
 };
 use if_chain::if_chain;
+use rustc::declare_lint_pass;
 use rustc::lint::{in_external_macro, EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
-use rustc::{declare_lint_pass, declare_tool_lint};
 use rustc_data_structures::fx::FxHashMap;
 use rustc_errors::Applicability;
+use rustc_session::declare_tool_lint;
 use syntax::ast::*;
 use syntax::source_map::Span;
 use syntax::visit::{walk_expr, FnKind, Visitor};
@@ -253,6 +254,7 @@ struct ReturnVisitor {
 }
 
 impl ReturnVisitor {
+    #[must_use]
     fn new() -> Self {
         Self { found_return: false }
     }
@@ -436,7 +438,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
                     );
                 }
             },
-            ExprKind::Lit(ref lit) => self.check_lit(cx, lit),
+            ExprKind::Lit(ref lit) => Self::check_lit(cx, lit),
             _ => (),
         }
     }
@@ -468,7 +470,7 @@ fn check_block(&mut self, cx: &EarlyContext<'_>, block: &Block) {
 }
 
 impl MiscEarlyLints {
-    fn check_lit(self, cx: &EarlyContext<'_>, lit: &Lit) {
+    fn check_lit(cx: &EarlyContext<'_>, lit: &Lit) {
         // We test if first character in snippet is a number, because the snippet could be an expansion
         // from a built-in macro like `line!()` or a proc-macro like `#[wasm_bindgen]`.
         // Note that this check also covers special case that `line!()` is eagerly expanded by compiler.
@@ -481,8 +483,8 @@ fn check_lit(self, cx: &EarlyContext<'_>, lit: &Lit) {
 
         if let LitKind::Int(value, lit_int_type) = lit.kind {
             let suffix = match lit_int_type {
-                LitIntType::Signed(ty) => ty.ty_to_string(),
-                LitIntType::Unsigned(ty) => ty.ty_to_string(),
+                LitIntType::Signed(ty) => ty.name_str(),
+                LitIntType::Unsigned(ty) => ty.name_str(),
                 LitIntType::Unsuffixed => "",
             };
 
@@ -542,8 +544,8 @@ fn check_lit(self, cx: &EarlyContext<'_>, lit: &Lit) {
                     },
                 );
             }
-        } else if let LitKind::Float(_, float_ty) = lit.kind {
-            let suffix = float_ty.ty_to_string();
+        } else if let LitKind::Float(_, LitFloatType::Suffixed(float_ty)) = lit.kind {
+            let suffix = float_ty.name_str();
             let maybe_last_sep_idx = lit_snip.len() - suffix.len() - 1;
             if lit_snip.as_bytes()[maybe_last_sep_idx] != b'_' {
                 span_lint_and_sugg(