Skip to content

Commit abe551e

Browse files
committed
Auto merge of #7762 - HKalbasi:master, r=Manishearth
Add lint `equatable_if_let` This is my attempt for #1716. There is a major false positive, which is people may implement `PartialEq` in a different way. It is unactionable at the moment so I put it into `nursery`. There is a trait `StructuralPartialEq` for solving this problem which is promising but it has several problems currently: * Integers and tuples doesn't implement it. * Some types wrongly implement it, like `Option<T>` when `T` doesn't implement it. I consider them bugs and against the propose of `StructuralPartialEq`. When they become fixed, this lint can become a useful lint with a single line change. changelog: New lint: [`equatable_if_let`]
2 parents 3311b36 + 388a3d0 commit abe551e

File tree

72 files changed

+572
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+572
-253
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2695,6 +2695,7 @@ Released 2018-09-13
26952695
[`enum_glob_use`]: https://rust-lang.github.io/rust-clippy/master/index.html#enum_glob_use
26962696
[`enum_variant_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names
26972697
[`eq_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#eq_op
2698+
[`equatable_if_let`]: https://rust-lang.github.io/rust-clippy/master/index.html#equatable_if_let
26982699
[`erasing_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#erasing_op
26992700
[`eval_order_dependence`]: https://rust-lang.github.io/rust-clippy/master/index.html#eval_order_dependence
27002701
[`excessive_precision`]: https://rust-lang.github.io/rust-clippy/master/index.html#excessive_precision

Diff for: clippy_lints/src/attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ fn check_deprecated_cfg_attr(cx: &EarlyContext<'_>, attr: &Attribute) {
563563
skip_item.path.segments.last().expect("empty path in attribute").ident.name == sym::skip;
564564
// Only lint outer attributes, because custom inner attributes are unstable
565565
// Tracking issue: https://github.com/rust-lang/rust/issues/54726
566-
if let AttrStyle::Outer = attr.style;
566+
if attr.style == AttrStyle::Outer;
567567
then {
568568
span_lint_and_sugg(
569569
cx,

Diff for: clippy_lints/src/casts/cast_precision_loss.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca
1212
}
1313

1414
let from_nbits = utils::int_ty_to_nbits(cast_from, cx.tcx);
15-
let to_nbits = if let ty::Float(FloatTy::F32) = cast_to.kind() {
15+
let to_nbits = if cast_to.kind() == &ty::Float(FloatTy::F32) {
1616
32
1717
} else {
1818
64

Diff for: clippy_lints/src/derive.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ impl<'tcx> Visitor<'tcx> for UnsafeVisitor<'_, 'tcx> {
393393

394394
if_chain! {
395395
if let Some(header) = kind.header();
396-
if let Unsafety::Unsafe = header.unsafety;
396+
if header.unsafety == Unsafety::Unsafe;
397397
then {
398398
self.has_unsafe = true;
399399
}
@@ -408,7 +408,7 @@ impl<'tcx> Visitor<'tcx> for UnsafeVisitor<'_, 'tcx> {
408408
}
409409

410410
if let ExprKind::Block(block, _) = expr.kind {
411-
if let BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) = block.rules {
411+
if block.rules == BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) {
412412
self.has_unsafe = true;
413413
}
414414
}

Diff for: clippy_lints/src/equatable_if_let.rs

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
use clippy_utils::diagnostics::span_lint_and_sugg;
2+
use clippy_utils::source::snippet_with_applicability;
3+
use clippy_utils::ty::implements_trait;
4+
use if_chain::if_chain;
5+
use rustc_errors::Applicability;
6+
use rustc_hir::{Expr, ExprKind, Pat, PatKind};
7+
use rustc_lint::{LateContext, LateLintPass};
8+
use rustc_middle::ty::Ty;
9+
use rustc_session::{declare_lint_pass, declare_tool_lint};
10+
11+
declare_clippy_lint! {
12+
/// ### What it does
13+
/// Checks for pattern matchings that can be expressed using equality.
14+
///
15+
/// ### Why is this bad?
16+
///
17+
/// * It reads better and has less cognitive load because equality won't cause binding.
18+
/// * It is a [Yoda condition](https://en.wikipedia.org/wiki/Yoda_conditions). Yoda conditions are widely
19+
/// criticized for increasing the cognitive load of reading the code.
20+
/// * Equality is a simple bool expression and can be merged with `&&` and `||` and
21+
/// reuse if blocks
22+
///
23+
/// ### Example
24+
/// ```rust,ignore
25+
/// if let Some(2) = x {
26+
/// do_thing();
27+
/// }
28+
/// ```
29+
/// Should be written
30+
/// ```rust,ignore
31+
/// if x == Some(2) {
32+
/// do_thing();
33+
/// }
34+
/// ```
35+
pub EQUATABLE_IF_LET,
36+
nursery,
37+
"using pattern matching instead of equality"
38+
}
39+
40+
declare_lint_pass!(PatternEquality => [EQUATABLE_IF_LET]);
41+
42+
/// detects if pattern matches just one thing
43+
fn unary_pattern(pat: &Pat<'_>) -> bool {
44+
fn array_rec(pats: &[Pat<'_>]) -> bool {
45+
pats.iter().all(unary_pattern)
46+
}
47+
match &pat.kind {
48+
PatKind::Slice(_, _, _) | PatKind::Range(_, _, _) | PatKind::Binding(..) | PatKind::Wild | PatKind::Or(_) => {
49+
false
50+
},
51+
PatKind::Struct(_, a, etc) => !etc && a.iter().all(|x| unary_pattern(x.pat)),
52+
PatKind::Tuple(a, etc) | PatKind::TupleStruct(_, a, etc) => !etc.is_some() && array_rec(a),
53+
PatKind::Ref(x, _) | PatKind::Box(x) => unary_pattern(x),
54+
PatKind::Path(_) | PatKind::Lit(_) => true,
55+
}
56+
}
57+
58+
fn is_structural_partial_eq(cx: &LateContext<'tcx>, ty: Ty<'tcx>, other: Ty<'tcx>) -> bool {
59+
if let Some(def_id) = cx.tcx.lang_items().eq_trait() {
60+
implements_trait(cx, ty, def_id, &[other.into()])
61+
} else {
62+
false
63+
}
64+
}
65+
66+
impl<'tcx> LateLintPass<'tcx> for PatternEquality {
67+
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
68+
if_chain! {
69+
if let ExprKind::Let(pat, exp, _) = expr.kind;
70+
if unary_pattern(pat);
71+
let exp_ty = cx.typeck_results().expr_ty(exp);
72+
let pat_ty = cx.typeck_results().pat_ty(pat);
73+
if is_structural_partial_eq(cx, exp_ty, pat_ty);
74+
then {
75+
76+
let mut applicability = Applicability::MachineApplicable;
77+
let pat_str = match pat.kind {
78+
PatKind::Struct(..) => format!(
79+
"({})",
80+
snippet_with_applicability(cx, pat.span, "..", &mut applicability),
81+
),
82+
_ => snippet_with_applicability(cx, pat.span, "..", &mut applicability).to_string(),
83+
};
84+
span_lint_and_sugg(
85+
cx,
86+
EQUATABLE_IF_LET,
87+
expr.span,
88+
"this pattern matching can be expressed using equality",
89+
"try",
90+
format!(
91+
"{} == {}",
92+
snippet_with_applicability(cx, exp.span, "..", &mut applicability),
93+
pat_str,
94+
),
95+
applicability,
96+
);
97+
}
98+
}
99+
}
100+
}

Diff for: clippy_lints/src/erasing_op.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'tcx> LateLintPass<'tcx> for ErasingOp {
4747
}
4848

4949
fn check(cx: &LateContext<'_>, e: &Expr<'_>, span: Span) {
50-
if let Some(Constant::Int(0)) = constant_simple(cx, cx.typeck_results(), e) {
50+
if constant_simple(cx, cx.typeck_results(), e) == Some(Constant::Int(0)) {
5151
span_lint(
5252
cx,
5353
ERASING_OP,

Diff for: clippy_lints/src/escape.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
9090
for trait_item in items {
9191
if trait_item.id.hir_id() == hir_id {
9292
// be sure we have `self` parameter in this function
93-
if let AssocItemKind::Fn { has_self: true } = trait_item.kind {
93+
if trait_item.kind == (AssocItemKind::Fn { has_self: true }) {
9494
trait_self_ty = Some(
9595
TraitRef::identity(cx.tcx, trait_item.id.def_id.to_def_id())
9696
.self_ty()

Diff for: clippy_lints/src/eta_reduction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
116116
if let Some(mut snippet) = snippet_opt(cx, callee.span) {
117117
if_chain! {
118118
if let ty::Closure(_, substs) = callee_ty.peel_refs().kind();
119-
if let ClosureKind::FnMut = substs.as_closure().kind();
119+
if substs.as_closure().kind() == ClosureKind::FnMut;
120120
if get_enclosing_loop_or_closure(cx.tcx, expr).is_some()
121121
|| UsedAfterExprVisitor::is_found(cx, callee);
122122

Diff for: clippy_lints/src/eval_order_dependence.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
141141
match typ.kind() {
142142
ty::FnDef(..) | ty::FnPtr(_) => {
143143
let sig = typ.fn_sig(self.cx.tcx);
144-
if let ty::Never = self.cx.tcx.erase_late_bound_regions(sig).output().kind() {
144+
if self.cx.tcx.erase_late_bound_regions(sig).output().kind() == &ty::Never {
145145
self.report_diverging_sub_expr(e);
146146
}
147147
},

Diff for: clippy_lints/src/identity_op.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use clippy_utils::source::snippet;
2-
use if_chain::if_chain;
32
use rustc_hir::{BinOp, BinOpKind, Expr, ExprKind};
43
use rustc_lint::{LateContext, LateLintPass};
54
use rustc_middle::ty;
@@ -62,16 +61,9 @@ impl<'tcx> LateLintPass<'tcx> for IdentityOp {
6261

6362
fn is_allowed(cx: &LateContext<'_>, cmp: BinOp, left: &Expr<'_>, right: &Expr<'_>) -> bool {
6463
// `1 << 0` is a common pattern in bit manipulation code
65-
if_chain! {
66-
if let BinOpKind::Shl = cmp.node;
67-
if let Some(Constant::Int(0)) = constant_simple(cx, cx.typeck_results(), right);
68-
if let Some(Constant::Int(1)) = constant_simple(cx, cx.typeck_results(), left);
69-
then {
70-
return true;
71-
}
72-
}
73-
74-
false
64+
cmp.node == BinOpKind::Shl
65+
&& constant_simple(cx, cx.typeck_results(), right) == Some(Constant::Int(0))
66+
&& constant_simple(cx, cx.typeck_results(), left) == Some(Constant::Int(1))
7567
}
7668

7769
#[allow(clippy::cast_possible_wrap)]

Diff for: clippy_lints/src/integer_division.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<'tcx> LateLintPass<'tcx> for IntegerDivision {
4848
fn is_integer_division<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) -> bool {
4949
if_chain! {
5050
if let hir::ExprKind::Binary(binop, left, right) = &expr.kind;
51-
if let hir::BinOpKind::Div = &binop.node;
51+
if binop.node == hir::BinOpKind::Div;
5252
then {
5353
let (left_ty, right_ty) = (cx.typeck_results().expr_ty(left), cx.typeck_results().expr_ty(right));
5454
return left_ty.is_integral() && right_ty.is_integral();

Diff for: clippy_lints/src/len_zero.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -455,14 +455,10 @@ fn is_empty_array(expr: &Expr<'_>) -> bool {
455455
fn has_is_empty(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
456456
/// Gets an `AssocItem` and return true if it matches `is_empty(self)`.
457457
fn is_is_empty(cx: &LateContext<'_>, item: &ty::AssocItem) -> bool {
458-
if let ty::AssocKind::Fn = item.kind {
459-
if item.ident.name.as_str() == "is_empty" {
460-
let sig = cx.tcx.fn_sig(item.def_id);
461-
let ty = sig.skip_binder();
462-
ty.inputs().len() == 1
463-
} else {
464-
false
465-
}
458+
if item.kind == ty::AssocKind::Fn && item.ident.name.as_str() == "is_empty" {
459+
let sig = cx.tcx.fn_sig(item.def_id);
460+
let ty = sig.skip_binder();
461+
ty.inputs().len() == 1
466462
} else {
467463
false
468464
}

Diff for: clippy_lints/src/lib.mods.rs

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ mod entry;
4949
mod enum_clike;
5050
mod enum_variants;
5151
mod eq_op;
52+
mod equatable_if_let;
5253
mod erasing_op;
5354
mod escape;
5455
mod eta_reduction;

Diff for: clippy_lints/src/lib.register_lints.rs

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ store.register_lints(&[
116116
enum_variants::MODULE_NAME_REPETITIONS,
117117
eq_op::EQ_OP,
118118
eq_op::OP_REF,
119+
equatable_if_let::EQUATABLE_IF_LET,
119120
erasing_op::ERASING_OP,
120121
escape::BOXED_LOCAL,
121122
eta_reduction::REDUNDANT_CLOSURE,

Diff for: clippy_lints/src/lib.register_nursery.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
88
LintId::of(copies::BRANCHES_SHARING_CODE),
99
LintId::of(disallowed_method::DISALLOWED_METHOD),
1010
LintId::of(disallowed_type::DISALLOWED_TYPE),
11+
LintId::of(equatable_if_let::EQUATABLE_IF_LET),
1112
LintId::of(fallible_impl_from::FALLIBLE_IMPL_FROM),
1213
LintId::of(floating_point_arithmetic::IMPRECISE_FLOPS),
1314
LintId::of(floating_point_arithmetic::SUBOPTIMAL_FLOPS),

Diff for: clippy_lints/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
485485
store.register_late_pass(|| Box::new(option_if_let_else::OptionIfLetElse));
486486
store.register_late_pass(|| Box::new(future_not_send::FutureNotSend));
487487
store.register_late_pass(|| Box::new(if_let_mutex::IfLetMutex));
488+
store.register_late_pass(|| Box::new(equatable_if_let::PatternEquality));
488489
store.register_late_pass(|| Box::new(mut_mutex_lock::MutMutexLock));
489490
store.register_late_pass(|| Box::new(match_on_vec_items::MatchOnVecItems));
490491
store.register_late_pass(|| Box::new(manual_async_fn::ManualAsyncFn));

Diff for: clippy_lints/src/loops/mut_range_bound.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
9292
fn consume(&mut self, _: &PlaceWithHirId<'tcx>, _: HirId) {}
9393

9494
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, diag_expr_id: HirId, bk: ty::BorrowKind) {
95-
if let ty::BorrowKind::MutBorrow = bk {
95+
if bk == ty::BorrowKind::MutBorrow {
9696
if let PlaceBase::Local(id) = cmt.place.base {
9797
if Some(id) == self.hir_id_low && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) {
9898
self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id));

Diff for: clippy_lints/src/loops/needless_range_loop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub(super) fn check<'tcx>(
9595
let mut take_expr = end;
9696

9797
if let ExprKind::Binary(ref op, left, right) = end.kind {
98-
if let BinOpKind::Add = op.node {
98+
if op.node == BinOpKind::Add {
9999
let start_equal_left = SpanlessEq::new(cx).eq_expr(start, left);
100100
let start_equal_right = SpanlessEq::new(cx).eq_expr(start, right);
101101

Diff for: clippy_lints/src/loops/never_loop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub(super) fn check(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
1414
NeverLoopResult::AlwaysBreak => {
1515
span_lint_and_then(cx, NEVER_LOOP, expr.span, "this loop never actually loops", |diag| {
1616
if_chain! {
17-
if let LoopSource::ForLoop = source;
17+
if source == LoopSource::ForLoop;
1818
if let Some((_, Node::Expr(parent_match))) = cx.tcx.hir().parent_iter(expr.hir_id).nth(1);
1919
if let Some(ForLoop { arg: iterator, pat, span: for_span, .. }) = ForLoop::hir(parent_match);
2020
then {

Diff for: clippy_lints/src/manual_async_fn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualAsyncFn {
4949
) {
5050
if_chain! {
5151
if let Some(header) = kind.header();
52-
if let IsAsync::NotAsync = header.asyncness;
52+
if header.asyncness == IsAsync::NotAsync;
5353
// Check that this function returns `impl Future`
5454
if let FnRetTy::Return(ret_ty) = decl.output;
5555
if let Some((trait_ref, output_lifetimes)) = future_trait_ref(cx, ret_ty);
@@ -178,7 +178,7 @@ fn desugared_async_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'tcx>)
178178
if args.len() == 1;
179179
if let Expr{kind: ExprKind::Closure(_, _, body_id, ..), ..} = args[0];
180180
let closure_body = cx.tcx.hir().body(body_id);
181-
if let Some(GeneratorKind::Async(AsyncGeneratorKind::Block)) = closure_body.generator_kind;
181+
if closure_body.generator_kind == Some(GeneratorKind::Async(AsyncGeneratorKind::Block));
182182
then {
183183
return Some(closure_body);
184184
}

Diff for: clippy_lints/src/methods/or_fun_call.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@ pub(super) fn check<'tcx>(
178178
hir::ExprKind::Index(..) | hir::ExprKind::MethodCall(..) => {
179179
check_general_case(cx, name, method_span, &args[0], &args[1], expr.span, None);
180180
},
181-
hir::ExprKind::Block(block, _) => {
182-
if let BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) = block.rules {
183-
if let Some(block_expr) = block.expr {
184-
if let hir::ExprKind::MethodCall(..) = block_expr.kind {
185-
check_general_case(cx, name, method_span, &args[0], &args[1], expr.span, None);
186-
}
181+
hir::ExprKind::Block(block, _)
182+
if block.rules == BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) =>
183+
{
184+
if let Some(block_expr) = block.expr {
185+
if let hir::ExprKind::MethodCall(..) = block_expr.kind {
186+
check_general_case(cx, name, method_span, &args[0], &args[1], expr.span, None);
187187
}
188188
}
189-
},
189+
}
190190
_ => (),
191191
}
192192
}

Diff for: clippy_lints/src/modulo_arithmetic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl<'tcx> LateLintPass<'tcx> for ModuloArithmetic {
128128
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
129129
match &expr.kind {
130130
ExprKind::Binary(op, lhs, rhs) | ExprKind::AssignOp(op, lhs, rhs) => {
131-
if let BinOpKind::Rem = op.node {
131+
if op.node == BinOpKind::Rem {
132132
let lhs_operand = analyze_operand(lhs, cx, expr);
133133
let rhs_operand = analyze_operand(rhs, cx, expr);
134134
if_chain! {

Diff for: clippy_lints/src/needless_bool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ fn check_comparison<'a, 'tcx>(
248248
if l_ty.is_bool() && r_ty.is_bool() {
249249
let mut applicability = Applicability::MachineApplicable;
250250

251-
if let BinOpKind::Eq = op.node {
251+
if op.node == BinOpKind::Eq {
252252
let expression_info = one_side_is_unary_not(left_side, right_side);
253253
if expression_info.one_side_is_unary_not {
254254
span_lint_and_sugg(

Diff for: clippy_lints/src/neg_multiply.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'tcx> LateLintPass<'tcx> for NegMultiply {
4646
fn check_mul(cx: &LateContext<'_>, span: Span, lit: &Expr<'_>, exp: &Expr<'_>) {
4747
if_chain! {
4848
if let ExprKind::Lit(ref l) = lit.kind;
49-
if let Constant::Int(1) = consts::lit_to_constant(&l.node, cx.typeck_results().expr_ty_opt(lit));
49+
if consts::lit_to_constant(&l.node, cx.typeck_results().expr_ty_opt(lit)) == Constant::Int(1);
5050
if cx.typeck_results().expr_ty(exp).is_integral();
5151
then {
5252
span_lint(cx, NEG_MULTIPLY, span, "negation by multiplying with `-1`");

Diff for: clippy_lints/src/new_without_default.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
6969
}) = item.kind
7070
{
7171
for assoc_item in items {
72-
if let hir::AssocItemKind::Fn { has_self: false } = assoc_item.kind {
72+
if assoc_item.kind == (hir::AssocItemKind::Fn { has_self: false }) {
7373
let impl_item = cx.tcx.hir().impl_item(assoc_item.id);
7474
if in_external_macro(cx.sess(), impl_item.span) {
7575
return;

Diff for: clippy_lints/src/non_send_fields_in_send_ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSendFieldInSendTy {
8181
if let Some(trait_ref) = &hir_impl.of_trait;
8282
if let Some(trait_id) = trait_ref.trait_def_id();
8383
if send_trait == trait_id;
84-
if let ImplPolarity::Positive = hir_impl.polarity;
84+
if hir_impl.polarity == ImplPolarity::Positive;
8585
if let Some(ty_trait_ref) = cx.tcx.impl_trait_ref(item.def_id);
8686
if let self_ty = ty_trait_ref.self_ty();
8787
if let ty::Adt(adt_def, impl_trait_substs) = self_ty.kind();

0 commit comments

Comments
 (0)