Skip to content

Commit eb6c24d

Browse files
committed
Update lint to current clippy API
1 parent 45413ed commit eb6c24d

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

clippy_lints/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
902902
&write::WRITELN_EMPTY_STRING,
903903
&write::WRITE_LITERAL,
904904
&write::WRITE_WITH_NEWLINE,
905+
&xor_used_as_pow::XOR_USED_AS_POW,
905906
&zero_div_zero::ZERO_DIVIDED_BY_ZERO,
906907
]);
907908
// end register lints, do not remove this comment, it’s used in `update_lints`
@@ -1800,6 +1801,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
18001801
LintId::of(&unused_io_amount::UNUSED_IO_AMOUNT),
18011802
LintId::of(&unwrap::PANICKING_UNWRAP),
18021803
LintId::of(&vec_resize_to_zero::VEC_RESIZE_TO_ZERO),
1804+
LintId::of(&xor_used_as_pow::XOR_USED_AS_POW),
18031805
]);
18041806

18051807
store.register_group(true, "clippy::perf", Some("clippy_perf"), vec![

clippy_lints/src/xor_used_as_pow.rs

Lines changed: 12 additions & 10 deletions
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_ast::{BinOpKind, Expr, ExprKind, LitKind};
54
use rustc_errors::Applicability;
6-
use syntax::ast::{BinOpKind, Expr, ExprKind, LitKind};
5+
use rustc_lint::{EarlyContext, EarlyLintPass};
6+
use rustc_middle::lint::in_external_macro;
7+
use rustc_session::{declare_lint_pass, declare_tool_lint};
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)