Skip to content

Commit 141f9a5

Browse files
committed
Update lint to current clippy API
1 parent 5ef3fc2 commit 141f9a5

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

clippy_lints/src/xor_used_as_pow.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use crate::utils::{span_help_and_lint, span_lint_and_sugg};
1+
use crate::utils::{span_lint_and_help, span_lint_and_sugg};
22
use if_chain::if_chain;
3-
use rustc::lint::{in_external_macro, EarlyContext, EarlyLintPass, LintArray, LintPass};
4-
use rustc::{declare_lint_pass, declare_tool_lint};
3+
use rustc_session::{declare_lint_pass, declare_tool_lint};
4+
use rustc_ast::*;
5+
use rustc_middle::lint::in_external_macro;
6+
use rustc_lint::{EarlyContext, EarlyLintPass};
57
use rustc_errors::Applicability;
6-
use syntax::ast::{BinOpKind, Expr, ExprKind, LitKind};
78

89
declare_clippy_lint! {
910
/// **What it does:** Checks for use of `^` operator when exponentiation was intended.
@@ -33,12 +34,12 @@ impl EarlyLintPass for XorUsedAsPow {
3334
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
3435
if_chain! {
3536
if !in_external_macro(cx.sess, expr.span);
36-
if let ExprKind::Binary(op, left, right) = &expr.node;
37+
if let ExprKind::Binary(op, left, right) = &expr.kind;
3738
if BinOpKind::BitXor == op.node;
38-
if let ExprKind::Lit(lit) = &left.node;
39-
if let LitKind::Int(lhs, _) = lit.node;
40-
if let ExprKind::Lit(lit) = &right.node;
41-
if let LitKind::Int(rhs, _) = lit.node;
39+
if let ExprKind::Lit(lit) = &left.kind;
40+
if let LitKind::Int(lhs, _) = lit.kind;
41+
if let ExprKind::Lit(lit) = &right.kind;
42+
if let LitKind::Int(rhs, _) = lit.kind;
4243
then {
4344
if lhs == 2 {
4445
if rhs == 8 || rhs == 16 || rhs == 32 || rhs == 64 || rhs == 128 {
@@ -63,11 +64,12 @@ impl EarlyLintPass for XorUsedAsPow {
6364
)
6465
}
6566
} else {
66-
span_help_and_lint(
67+
span_lint_and_help(
6768
cx,
6869
XOR_USED_AS_POW,
6970
expr.span,
7071
"`^` is not an exponentiation operator but appears to have been used as one",
72+
None,
7173
"did you mean to use .pow()?"
7274
)
7375
}

0 commit comments

Comments
 (0)