X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=clippy_lints%2Fsrc%2Fmisc.rs;h=6dbc33d87299fcfe076322aa9c1eb133afb7fd82;hb=2ff568d746e4641b992c0b74bea046e43a637997;hp=248b6e4229a4206949af7eb42fe24c2582245c29;hpb=5b255883f5bb92772a04e60d57fb2bffd037b890;p=rust.git diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 248b6e4229a..6dbc33d8729 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -1,14 +1,15 @@ use if_chain::if_chain; -use matches::matches; -use rustc::declare_lint_pass; -use rustc::hir::intravisit::FnKind; -use rustc::hir::*; -use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass}; use rustc::ty; +use rustc_ast::ast::LitKind; use rustc_errors::Applicability; -use rustc_session::declare_tool_lint; -use syntax::ast::LitKind; -use syntax::source_map::{ExpnKind, Span}; +use rustc_hir::intravisit::FnKind; +use rustc_hir::{ + def, BinOpKind, BindingAnnotation, Body, Expr, ExprKind, FnDecl, HirId, Mutability, PatKind, Stmt, StmtKind, Ty, + TyKind, UnOp, +}; +use rustc_lint::{LateContext, LateLintPass}; +use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_span::source_map::{ExpnKind, Span}; use crate::consts::{constant, Constant}; use crate::utils::sugg::Sugg; @@ -63,7 +64,7 @@ /// ``` pub CMP_NAN, correctness, - "comparisons to NAN, which will always return false, probably not intended" + "comparisons to `NAN`, which will always return false, probably not intended" } declare_clippy_lint! { @@ -194,7 +195,7 @@ /// ``` pub ZERO_PTR, style, - "using 0 as *{const, mut} T" + "using `0 as *{const, mut} T`" } declare_clippy_lint! { @@ -370,9 +371,9 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) { } } let (lint, msg) = if is_named_constant(cx, left) || is_named_constant(cx, right) { - (FLOAT_CMP_CONST, "strict comparison of f32 or f64 constant") + (FLOAT_CMP_CONST, "strict comparison of `f32` or `f64` constant") } else { - (FLOAT_CMP, "strict comparison of f32 or f64") + (FLOAT_CMP, "strict comparison of `f32` or `f64`") }; span_lint_and_then(cx, lint, expr.span, msg, |db| { let lhs = Sugg::hir(cx, left, ".."); @@ -388,7 +389,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) { ), Applicability::HasPlaceholders, // snippet ); - db.span_note(expr.span, "std::f32::EPSILON and std::f64::EPSILON are available."); + db.span_note(expr.span, "`std::f32::EPSILON` and `std::f64::EPSILON` are available."); }); } else if op == BinOpKind::Rem && is_integer_const(cx, right, 1) { span_lint(cx, MODULO_ONE, expr.span, "any number modulo 1 will be 0"); @@ -456,7 +457,7 @@ fn check_nan(cx: &LateContext<'_, '_>, expr: &Expr<'_>, cmp_expr: &Expr<'_>) { cx, CMP_NAN, cmp_expr.span, - "doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead", + "doomed comparison with `NAN`, use `std::{f32,f64}::is_nan()` instead", ); } } @@ -482,7 +483,7 @@ fn is_allowed<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) -> boo // Return true if `expr` is the result of `signum()` invoked on a float value. fn is_signum(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> bool { // The negation of a signum is still a signum - if let ExprKind::Unary(UnNeg, ref child_expr) = expr.kind { + if let ExprKind::Unary(UnOp::UnNeg, ref child_expr) = expr.kind { return is_signum(cx, &child_expr); } @@ -544,7 +545,7 @@ fn check_to_owned(cx: &LateContext<'_, '_>, expr: &Expr<'_>, other: &Expr<'_>) { } let other_gets_derefed = match other.kind { - ExprKind::Unary(UnDeref, _) => true, + ExprKind::Unary(UnOp::UnDeref, _) => true, _ => false, }; @@ -603,7 +604,7 @@ fn is_used(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> bool { /// Tests whether an expression is in a macro expansion (e.g., something /// generated by `#[derive(...)]` or the like). fn in_attributes_expansion(expr: &Expr<'_>) -> bool { - use syntax_pos::hygiene::MacroKind; + use rustc_span::hygiene::MacroKind; if expr.span.from_expansion() { let data = expr.span.ctxt().outer_expn_data();