Skip to content

Commit 34b373d

Browse files
committed
Rename HIR UnOp variants
This renames the variants in HIR UnOp from enum UnOp { UnDeref, UnNot, UnNeg, } to enum UnOp { Deref, Not, Neg, } Motivations: - This is more consistent with the rest of the code base where most enum variants don't have a prefix. - These variants are never used without the `UnOp` prefix so the extra `Un` prefix doesn't help with readability. E.g. we don't have any `UnDeref`s in the code, we only have `UnOp::UnDeref`. - MIR `UnOp` type variants don't have a prefix so this is more consistent with MIR types. - "un" prefix reads like "inverse" or "reverse", so as a beginner in rustc code base when I see "UnDeref" what comes to my mind is something like "&*" instead of just "*".
1 parent a5d442c commit 34b373d

26 files changed

+43
-43
lines changed

clippy_lints/src/arithmetic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for Arithmetic {
9191
match op.node {
9292
hir::BinOpKind::Div | hir::BinOpKind::Rem => match &r.kind {
9393
hir::ExprKind::Lit(_lit) => (),
94-
hir::ExprKind::Unary(hir::UnOp::UnNeg, expr) => {
94+
hir::ExprKind::Unary(hir::UnOp::Neg, expr) => {
9595
if let hir::ExprKind::Lit(lit) = &expr.kind {
9696
if let rustc_ast::ast::LitKind::Int(1, _) = lit.node {
9797
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
@@ -114,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for Arithmetic {
114114
self.expr_span = Some(expr.span);
115115
}
116116
},
117-
hir::ExprKind::Unary(hir::UnOp::UnNeg, arg) => {
117+
hir::ExprKind::Unary(hir::UnOp::Neg, arg) => {
118118
let ty = cx.typeck_results().expr_ty(arg);
119119
if constant_simple(cx, cx.typeck_results(), expr).is_none() {
120120
if ty.is_integral() {

clippy_lints/src/assertions_on_constants.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ enum AssertKind {
112112
fn match_assert_with_message<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<AssertKind> {
113113
if_chain! {
114114
if let ExprKind::If(ref cond, ref then, _) = expr.kind;
115-
if let ExprKind::Unary(UnOp::UnNot, ref expr) = cond.kind;
115+
if let ExprKind::Unary(UnOp::Not, ref expr) = cond.kind;
116116
// bind the first argument of the `assert!` macro
117117
if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.typeck_results(), expr);
118118
// block

clippy_lints/src/booleans.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
110110
// prevent folding of `cfg!` macros and the like
111111
if !e.span.from_expansion() {
112112
match &e.kind {
113-
ExprKind::Unary(UnOp::UnNot, inner) => return Ok(Bool::Not(box self.run(inner)?)),
113+
ExprKind::Unary(UnOp::Not, inner) => return Ok(Bool::Not(box self.run(inner)?)),
114114
ExprKind::Binary(binop, lhs, rhs) => match &binop.node {
115115
BinOpKind::Or => {
116116
return Ok(Bool::Or(self.extract(BinOpKind::Or, &[lhs, rhs], Vec::new())?));
@@ -454,7 +454,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
454454
ExprKind::Binary(binop, _, _) if binop.node == BinOpKind::Or || binop.node == BinOpKind::And => {
455455
self.bool_expr(e)
456456
},
457-
ExprKind::Unary(UnOp::UnNot, inner) => {
457+
ExprKind::Unary(UnOp::Not, inner) => {
458458
if self.cx.typeck_results().node_types()[inner.hir_id].is_bool() {
459459
self.bool_expr(e);
460460
} else {
@@ -482,7 +482,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NotSimplificationVisitor<'a, 'tcx> {
482482
type Map = Map<'tcx>;
483483

484484
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
485-
if let ExprKind::Unary(UnOp::UnNot, inner) = &expr.kind {
485+
if let ExprKind::Unary(UnOp::Not, inner) = &expr.kind {
486486
if let Some(suggestion) = simplify_not(self.cx, inner) {
487487
span_lint_and_sugg(
488488
self.cx,

clippy_lints/src/bytecount.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn check_arg(name: Symbol, arg: Symbol, needle: &Expr<'_>) -> bool {
101101

102102
fn get_path_name(expr: &Expr<'_>) -> Option<Symbol> {
103103
match expr.kind {
104-
ExprKind::Box(ref e) | ExprKind::AddrOf(BorrowKind::Ref, _, ref e) | ExprKind::Unary(UnOp::UnDeref, ref e) => {
104+
ExprKind::Box(ref e) | ExprKind::AddrOf(BorrowKind::Ref, _, ref e) | ExprKind::Unary(UnOp::Deref, ref e) => {
105105
get_path_name(e)
106106
},
107107
ExprKind::Block(ref b, _) => {

clippy_lints/src/collapsible_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ fn addr_adjusted_binding(mut expr: &Expr<'_>, cx: &LateContext<'_>) -> Option<Hi
186186
Res::Local(binding_id) => break Some(binding_id),
187187
_ => break None,
188188
},
189-
ExprKind::Unary(UnOp::UnDeref, e) if cx.typeck_results().expr_ty(e).is_ref() => expr = e,
189+
ExprKind::Unary(UnOp::Deref, e) if cx.typeck_results().expr_ty(e).is_ref() => expr = e,
190190
_ => break None,
191191
}
192192
}

clippy_lints/src/consts.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
242242
self.expr(value).map(|v| Constant::Repeat(Box::new(v), n))
243243
},
244244
ExprKind::Unary(op, ref operand) => self.expr(operand).and_then(|o| match op {
245-
UnOp::UnNot => self.constant_not(&o, self.typeck_results.expr_ty(e)),
246-
UnOp::UnNeg => self.constant_negate(&o, self.typeck_results.expr_ty(e)),
247-
UnOp::UnDeref => Some(if let Constant::Ref(r) = o { *r } else { o }),
245+
UnOp::Not => self.constant_not(&o, self.typeck_results.expr_ty(e)),
246+
UnOp::Neg => self.constant_negate(&o, self.typeck_results.expr_ty(e)),
247+
UnOp::Deref => Some(if let Constant::Ref(r) = o { *r } else { o }),
248248
}),
249249
ExprKind::If(ref cond, ref then, ref otherwise) => self.ifthenelse(cond, then, *otherwise),
250250
ExprKind::Binary(op, ref left, ref right) => self.binop(op, left, right),

clippy_lints/src/entry.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ declare_lint_pass!(HashMapPass => [MAP_ENTRY]);
5555
impl<'tcx> LateLintPass<'tcx> for HashMapPass {
5656
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
5757
if let ExprKind::If(ref check, ref then_block, ref else_block) = expr.kind {
58-
if let ExprKind::Unary(UnOp::UnNot, ref check) = check.kind {
58+
if let ExprKind::Unary(UnOp::Not, ref check) = check.kind {
5959
if let Some((ty, map, key)) = check_cond(cx, check) {
6060
// in case of `if !m.contains_key(&k) { m.insert(k, v); }`
6161
// we can give a better error message

clippy_lints/src/floating_point_arithmetic.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn get_specialized_log_method(cx: &LateContext<'_>, base: &Expr<'_>) -> Option<&
129129
fn prepare_receiver_sugg<'a>(cx: &LateContext<'_>, mut expr: &'a Expr<'a>) -> Sugg<'a> {
130130
let mut suggestion = Sugg::hir(cx, expr, "..");
131131

132-
if let ExprKind::Unary(UnOp::UnNeg, inner_expr) = &expr.kind {
132+
if let ExprKind::Unary(UnOp::Neg, inner_expr) = &expr.kind {
133133
expr = &inner_expr;
134134
}
135135

@@ -541,12 +541,12 @@ fn is_zero(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
541541
/// If the two expressions are not negations of each other, then it
542542
/// returns None.
543543
fn are_negated<'a>(cx: &LateContext<'_>, expr1: &'a Expr<'a>, expr2: &'a Expr<'a>) -> Option<(bool, &'a Expr<'a>)> {
544-
if let ExprKind::Unary(UnOp::UnNeg, expr1_negated) = &expr1.kind {
544+
if let ExprKind::Unary(UnOp::Neg, expr1_negated) = &expr1.kind {
545545
if eq_expr_value(cx, expr1_negated, expr2) {
546546
return Some((false, expr2));
547547
}
548548
}
549-
if let ExprKind::Unary(UnOp::UnNeg, expr2_negated) = &expr2.kind {
549+
if let ExprKind::Unary(UnOp::Neg, expr2_negated) = &expr2.kind {
550550
if eq_expr_value(cx, expr1, expr2_negated) {
551551
return Some((true, expr1));
552552
}

clippy_lints/src/functions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
644644
}
645645
}
646646
},
647-
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref ptr) => self.check_arg(ptr),
647+
hir::ExprKind::Unary(hir::UnOp::Deref, ref ptr) => self.check_arg(ptr),
648648
_ => (),
649649
}
650650

clippy_lints/src/map_clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for MapClone {
7070
},
7171
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, .., name, None) => {
7272
match closure_expr.kind {
73-
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref inner) => {
73+
hir::ExprKind::Unary(hir::UnOp::Deref, ref inner) => {
7474
if ident_eq(name, inner) {
7575
if let ty::Ref(.., Mutability::Not) = cx.typeck_results().expr_ty(inner).kind() {
7676
lint(cx, e.span, args[0].span, true);

clippy_lints/src/methods/manual_saturating_arithmetic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ fn is_min_or_max<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>) -> Option<M
148148
}
149149

150150
if ty.is_signed() {
151-
if let hir::ExprKind::Unary(hir::UnOp::UnNeg, val) = &expr.kind {
151+
if let hir::ExprKind::Unary(hir::UnOp::Neg, val) = &expr.kind {
152152
return check_lit(val, true);
153153
}
154154
}
@@ -163,7 +163,7 @@ enum Sign {
163163
}
164164

165165
fn lit_sign(expr: &hir::Expr<'_>) -> Option<Sign> {
166-
if let hir::ExprKind::Unary(hir::UnOp::UnNeg, inner) = &expr.kind {
166+
if let hir::ExprKind::Unary(hir::UnOp::Neg, inner) = &expr.kind {
167167
if let hir::ExprKind::Lit(..) = &inner.kind {
168168
return Some(Sign::Neg);
169169
}

clippy_lints/src/methods/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2619,7 +2619,7 @@ fn lint_get_unwrap<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, get_args:
26192619
if_chain! {
26202620
if needs_ref;
26212621
if let Some(parent) = get_parent_expr(cx, expr);
2622-
if let hir::ExprKind::Unary(hir::UnOp::UnDeref, _) = parent.kind;
2622+
if let hir::ExprKind::Unary(hir::UnOp::Deref, _) = parent.kind;
26232623
then {
26242624
needs_ref = false;
26252625
span = parent.span;
@@ -3063,7 +3063,7 @@ fn lint_filter_map<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, is_f
30633063
// in `filter(|x| ..)`, replace `*x` with `x`
30643064
let a_path = if_chain! {
30653065
if !is_filter_param_ref;
3066-
if let ExprKind::Unary(UnOp::UnDeref, expr_path) = a.kind;
3066+
if let ExprKind::Unary(UnOp::Deref, expr_path) = a.kind;
30673067
then { expr_path } else { a }
30683068
};
30693069
// let the filter closure arg and the map closure arg be equal
@@ -3708,8 +3708,8 @@ fn lint_option_as_ref_deref<'tcx>(
37083708
},
37093709
hir::ExprKind::AddrOf(hir::BorrowKind::Ref, m, ref inner) if same_mutability(m) => {
37103710
if_chain! {
3711-
if let hir::ExprKind::Unary(hir::UnOp::UnDeref, ref inner1) = inner.kind;
3712-
if let hir::ExprKind::Unary(hir::UnOp::UnDeref, ref inner2) = inner1.kind;
3711+
if let hir::ExprKind::Unary(hir::UnOp::Deref, ref inner1) = inner.kind;
3712+
if let hir::ExprKind::Unary(hir::UnOp::Deref, ref inner2) = inner1.kind;
37133713
if let hir::ExprKind::Path(ref qpath) = inner2.kind;
37143714
if let hir::def::Res::Local(local_id) = cx.qpath_res(qpath, inner2.hir_id);
37153715
then {
@@ -4065,7 +4065,7 @@ fn lint_filetype_is_file(cx: &LateContext<'_>, expr: &hir::Expr<'_>, args: &[hir
40654065
if_chain! {
40664066
if let Some(parent) = get_parent_expr(cx, expr);
40674067
if let hir::ExprKind::Unary(op, _) = parent.kind;
4068-
if op == hir::UnOp::UnNot;
4068+
if op == hir::UnOp::Not;
40694069
then {
40704070
lint_unary = "!";
40714071
verb = "denies";

clippy_lints/src/misc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ fn is_allowed<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> bool {
502502
// Return true if `expr` is the result of `signum()` invoked on a float value.
503503
fn is_signum(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
504504
// The negation of a signum is still a signum
505-
if let ExprKind::Unary(UnOp::UnNeg, ref child_expr) = expr.kind {
505+
if let ExprKind::Unary(UnOp::Neg, ref child_expr) = expr.kind {
506506
return is_signum(cx, &child_expr);
507507
}
508508

@@ -586,7 +586,7 @@ fn check_to_owned(cx: &LateContext<'_>, expr: &Expr<'_>, other: &Expr<'_>, left:
586586
return;
587587
}
588588

589-
let other_gets_derefed = matches!(other.kind, ExprKind::Unary(UnOp::UnDeref, _));
589+
let other_gets_derefed = matches!(other.kind, ExprKind::Unary(UnOp::Deref, _));
590590

591591
let lint_span = if other_gets_derefed {
592592
expr.span.to(other.span)

clippy_lints/src/needless_bool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ struct ExpressionInfoWithSpan {
195195
}
196196

197197
fn is_unary_not(e: &Expr<'_>) -> (bool, Span) {
198-
if let ExprKind::Unary(UnOp::UnNot, operand) = e.kind {
198+
if let ExprKind::Unary(UnOp::Not, operand) = e.kind {
199199
return (true, operand.span);
200200
}
201201
(false, e.span)

clippy_lints/src/neg_cmp_op_on_partial_ord.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for NoNegCompOpForPartialOrd {
5050
if_chain! {
5151

5252
if !in_external_macro(cx.sess(), expr.span);
53-
if let ExprKind::Unary(UnOp::UnNot, ref inner) = expr.kind;
53+
if let ExprKind::Unary(UnOp::Not, ref inner) = expr.kind;
5454
if let ExprKind::Binary(ref op, ref left, _) = inner.kind;
5555
if let BinOpKind::Le | BinOpKind::Ge | BinOpKind::Lt | BinOpKind::Gt = op.node;
5656

clippy_lints/src/neg_multiply.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ impl<'tcx> LateLintPass<'tcx> for NegMultiply {
3232
if BinOpKind::Mul == op.node {
3333
match (&left.kind, &right.kind) {
3434
(&ExprKind::Unary(..), &ExprKind::Unary(..)) => {},
35-
(&ExprKind::Unary(UnOp::UnNeg, ref lit), _) => check_mul(cx, e.span, lit, right),
36-
(_, &ExprKind::Unary(UnOp::UnNeg, ref lit)) => check_mul(cx, e.span, lit, left),
35+
(&ExprKind::Unary(UnOp::Neg, ref lit), _) => check_mul(cx, e.span, lit, right),
36+
(_, &ExprKind::Unary(UnOp::Neg, ref lit)) => check_mul(cx, e.span, lit, left),
3737
_ => {},
3838
}
3939
}

clippy_lints/src/non_copy_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
383383
needs_check_adjustment = false;
384384
break;
385385
},
386-
ExprKind::Unary(UnOp::UnDeref, _) => {
386+
ExprKind::Unary(UnOp::Deref, _) => {
387387
// `*e` => desugared to `*Deref::deref(&e)`,
388388
// meaning `e` must be referenced.
389389
// no need to go further up since a method call is involved now.

clippy_lints/src/option_if_let_else.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn detect_option_if_let_else<'tcx>(
181181
};
182182
let cond_expr = match &cond_expr.kind {
183183
// Pointer dereferencing happens automatically, so we can omit it in the suggestion
184-
ExprKind::Unary(UnOp::UnDeref, expr) | ExprKind::AddrOf(_, _, expr) => expr,
184+
ExprKind::Unary(UnOp::Deref, expr) | ExprKind::AddrOf(_, _, expr) => expr,
185185
_ => cond_expr,
186186
};
187187
Some(OptionIfLetElseOccurence {

clippy_lints/src/shadow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ fn is_self_shadow(name: Symbol, expr: &Expr<'_>) -> bool {
389389
ExprKind::Block(ref block, _) => {
390390
block.stmts.is_empty() && block.expr.as_ref().map_or(false, |e| is_self_shadow(name, e))
391391
},
392-
ExprKind::Unary(op, ref inner) => (UnOp::UnDeref == op) && is_self_shadow(name, inner),
392+
ExprKind::Unary(op, ref inner) => (UnOp::Deref == op) && is_self_shadow(name, inner),
393393
ExprKind::Path(QPath::Resolved(_, ref path)) => path_eq_name(name, path),
394394
_ => false,
395395
}

clippy_lints/src/suspicious_trait_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl<'tcx> Visitor<'tcx> for BinaryExprVisitor {
194194
fn visit_expr(&mut self, expr: &'tcx hir::Expr<'_>) {
195195
match expr.kind {
196196
hir::ExprKind::Binary(..)
197-
| hir::ExprKind::Unary(hir::UnOp::UnNot | hir::UnOp::UnNeg, _)
197+
| hir::ExprKind::Unary(hir::UnOp::Not | hir::UnOp::Neg, _)
198198
| hir::ExprKind::AssignOp(..) => self.nb_binops += 1,
199199
_ => {},
200200
}

clippy_lints/src/transmute.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ impl<'tcx> LateLintPass<'tcx> for Transmute {
586586
let mut expr = &args[0];
587587
let mut arg = sugg::Sugg::hir(cx, expr, "..");
588588

589-
if let ExprKind::Unary(UnOp::UnNeg, inner_expr) = &expr.kind {
589+
if let ExprKind::Unary(UnOp::Neg, inner_expr) = &expr.kind {
590590
expr = &inner_expr;
591591
}
592592

clippy_lints/src/types.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1706,13 +1706,13 @@ impl<'tcx> LateLintPass<'tcx> for Casts {
17061706
}
17071707

17081708
fn is_unary_neg(expr: &Expr<'_>) -> bool {
1709-
matches!(expr.kind, ExprKind::Unary(UnOp::UnNeg, _))
1709+
matches!(expr.kind, ExprKind::Unary(UnOp::Neg, _))
17101710
}
17111711

17121712
fn get_numeric_literal<'e>(expr: &'e Expr<'e>) -> Option<&'e Lit> {
17131713
match expr.kind {
17141714
ExprKind::Lit(ref lit) => Some(lit),
1715-
ExprKind::Unary(UnOp::UnNeg, e) => {
1715+
ExprKind::Unary(UnOp::Neg, e) => {
17161716
if let ExprKind::Lit(ref lit) = e.kind {
17171717
Some(lit)
17181718
} else {
@@ -2868,7 +2868,7 @@ declare_lint_pass!(RefToMut => [CAST_REF_TO_MUT]);
28682868
impl<'tcx> LateLintPass<'tcx> for RefToMut {
28692869
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
28702870
if_chain! {
2871-
if let ExprKind::Unary(UnOp::UnDeref, e) = &expr.kind;
2871+
if let ExprKind::Unary(UnOp::Deref, e) = &expr.kind;
28722872
if let ExprKind::Cast(e, t) = &e.kind;
28732873
if let TyKind::Ptr(MutTy { mutbl: Mutability::Mut, .. }) = t.kind;
28742874
if let ExprKind::Cast(e, t) = &e.kind;

clippy_lints/src/unwrap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ fn collect_unwrap_info<'tcx>(
108108
},
109109
_ => (),
110110
}
111-
} else if let ExprKind::Unary(UnOp::UnNot, expr) = &expr.kind {
111+
} else if let ExprKind::Unary(UnOp::Not, expr) = &expr.kind {
112112
return collect_unwrap_info(cx, expr, branch, !invert);
113113
} else {
114114
if_chain! {

clippy_lints/src/utils/higher.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ pub fn extract_assert_macro_args<'tcx>(e: &'tcx Expr<'tcx>) -> Option<Vec<&'tcx
243243
// macros with unique arg: `{debug_}assert!` (e.g., `debug_assert!(some_condition)`)
244244
if_chain! {
245245
if let ExprKind::If(ref clause, _, _) = matchexpr.kind;
246-
if let ExprKind::Unary(UnOp::UnNot, condition) = clause.kind;
246+
if let ExprKind::Unary(UnOp::Not, condition) = clause.kind;
247247
then {
248248
return Some(vec![condition]);
249249
}

clippy_lints/src/utils/internal_lints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ impl InterningDefinedSymbol {
10011001
// SymbolStr might be de-referenced: `&*symbol.as_str()`
10021002
let call = if_chain! {
10031003
if let ExprKind::AddrOf(_, _, e) = expr.kind;
1004-
if let ExprKind::Unary(UnOp::UnDeref, e) = e.kind;
1004+
if let ExprKind::Unary(UnOp::Deref, e) = e.kind;
10051005
then { e } else { expr }
10061006
};
10071007
if_chain! {

tests/ui/suspicious_arithmetic_impl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl Add for Bar {
117117
type Output = Bar;
118118

119119
fn add(self, other: Self) -> Self {
120-
Bar(self.0 & !other.0) // OK: UnNot part of BiExpr as child node
120+
Bar(self.0 & !other.0) // OK: Not part of BiExpr as child node
121121
}
122122
}
123123

@@ -126,7 +126,7 @@ impl Sub for Bar {
126126

127127
fn sub(self, other: Self) -> Self {
128128
if self.0 <= other.0 {
129-
Bar(-(self.0 & other.0)) // OK: UnNeg part of BiExpr as parent node
129+
Bar(-(self.0 & other.0)) // OK: Neg part of BiExpr as parent node
130130
} else {
131131
Bar(0)
132132
}

0 commit comments

Comments
 (0)