Skip to content

Commit c4e3558

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 36931ce commit c4e3558

Some content is hidden

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

41 files changed

+80
-80
lines changed

compiler/rustc_ast_lowering/src/expr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
260260

261261
fn lower_unop(&mut self, u: UnOp) -> hir::UnOp {
262262
match u {
263-
UnOp::Deref => hir::UnOp::UnDeref,
264-
UnOp::Not => hir::UnOp::UnNot,
265-
UnOp::Neg => hir::UnOp::UnNeg,
263+
UnOp::Deref => hir::UnOp::Deref,
264+
UnOp::Not => hir::UnOp::Not,
265+
UnOp::Neg => hir::UnOp::Neg,
266266
}
267267
}
268268

compiler/rustc_hir/src/hir.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1112,25 +1112,25 @@ pub type BinOp = Spanned<BinOpKind>;
11121112
#[derive(Copy, Clone, PartialEq, Encodable, Debug, HashStable_Generic)]
11131113
pub enum UnOp {
11141114
/// The `*` operator (deferencing).
1115-
UnDeref,
1115+
Deref,
11161116
/// The `!` operator (logical negation).
1117-
UnNot,
1117+
Not,
11181118
/// The `-` operator (negation).
1119-
UnNeg,
1119+
Neg,
11201120
}
11211121

11221122
impl UnOp {
11231123
pub fn as_str(self) -> &'static str {
11241124
match self {
1125-
Self::UnDeref => "*",
1126-
Self::UnNot => "!",
1127-
Self::UnNeg => "-",
1125+
Self::Deref => "*",
1126+
Self::Not => "!",
1127+
Self::Neg => "-",
11281128
}
11291129
}
11301130

11311131
/// Returns `true` if the unary operator takes its argument by value.
11321132
pub fn is_by_value(self) -> bool {
1133-
matches!(self, Self::UnNeg | Self::UnNot)
1133+
matches!(self, Self::Neg | Self::Not)
11341134
}
11351135
}
11361136

@@ -1477,7 +1477,7 @@ impl Expr<'_> {
14771477
// https://github.com/rust-lang/rfcs/blob/master/text/0803-type-ascription.md#type-ascription-and-temporaries
14781478
ExprKind::Type(ref e, _) => e.is_place_expr(allow_projections_from),
14791479

1480-
ExprKind::Unary(UnOp::UnDeref, _) => true,
1480+
ExprKind::Unary(UnOp::Deref, _) => true,
14811481

14821482
ExprKind::Field(ref base, _) | ExprKind::Index(ref base, _) => {
14831483
allow_projections_from(base) || base.is_place_expr(allow_projections_from)

compiler/rustc_lint/src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ fn lint_literal<'tcx>(
472472
impl<'tcx> LateLintPass<'tcx> for TypeLimits {
473473
fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx hir::Expr<'tcx>) {
474474
match e.kind {
475-
hir::ExprKind::Unary(hir::UnOp::UnNeg, ref expr) => {
475+
hir::ExprKind::Unary(hir::UnOp::Neg, ref expr) => {
476476
// propagate negation, if the negation itself isn't negated
477477
if self.negated_expr_id != Some(e.hir_id) {
478478
self.negated_expr_id = Some(expr.hir_id);

compiler/rustc_middle/src/ty/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'tcx> Const<'tcx> {
5555

5656
let lit_input = match expr.kind {
5757
hir::ExprKind::Lit(ref lit) => Some(LitToConstInput { lit: &lit.node, ty, neg: false }),
58-
hir::ExprKind::Unary(hir::UnOp::UnNeg, ref expr) => match expr.kind {
58+
hir::ExprKind::Unary(hir::UnOp::Neg, ref expr) => match expr.kind {
5959
hir::ExprKind::Lit(ref lit) => {
6060
Some(LitToConstInput { lit: &lit.node, ty, neg: true })
6161
}

compiler/rustc_mir_build/src/thir/cx/expr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -299,23 +299,23 @@ fn make_mirror_unadjusted<'a, 'tcx>(
299299
}
300300
}
301301

302-
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref arg) => {
302+
hir::ExprKind::Unary(hir::UnOp::Deref, ref arg) => {
303303
if cx.typeck_results().is_method_call(expr) {
304304
overloaded_place(cx, expr, expr_ty, None, vec![arg.to_ref()], expr.span)
305305
} else {
306306
ExprKind::Deref { arg: arg.to_ref() }
307307
}
308308
}
309309

310-
hir::ExprKind::Unary(hir::UnOp::UnNot, ref arg) => {
310+
hir::ExprKind::Unary(hir::UnOp::Not, ref arg) => {
311311
if cx.typeck_results().is_method_call(expr) {
312312
overloaded_operator(cx, expr, vec![arg.to_ref()])
313313
} else {
314314
ExprKind::Unary { op: UnOp::Not, arg: arg.to_ref() }
315315
}
316316
}
317317

318-
hir::ExprKind::Unary(hir::UnOp::UnNeg, ref arg) => {
318+
hir::ExprKind::Unary(hir::UnOp::Neg, ref arg) => {
319319
if cx.typeck_results().is_method_call(expr) {
320320
overloaded_operator(cx, expr, vec![arg.to_ref()])
321321
} else if let hir::ExprKind::Lit(ref lit) = arg.kind {

compiler/rustc_mir_build/src/thir/pattern/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
866866
return *self.const_to_pat(value, expr.hir_id, expr.span, false).kind;
867867
}
868868
hir::ExprKind::Lit(ref lit) => (lit, false),
869-
hir::ExprKind::Unary(hir::UnOp::UnNeg, ref expr) => {
869+
hir::ExprKind::Unary(hir::UnOp::Neg, ref expr) => {
870870
let lit = match expr.kind {
871871
hir::ExprKind::Lit(ref lit) => lit,
872872
_ => span_bug!(expr.span, "not a literal: {:?}", expr),

compiler/rustc_passes/src/region.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ fn resolve_local<'tcx>(
664664

665665
match expr.kind {
666666
hir::ExprKind::AddrOf(_, _, ref subexpr)
667-
| hir::ExprKind::Unary(hir::UnOp::UnDeref, ref subexpr)
667+
| hir::ExprKind::Unary(hir::UnOp::Deref, ref subexpr)
668668
| hir::ExprKind::Field(ref subexpr, _)
669669
| hir::ExprKind::Index(ref subexpr, _) => {
670670
expr = &subexpr;

compiler/rustc_typeck/src/check/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
773773
if let hir::ExprKind::Lit(lit) = &expr.kind { lit.node.is_suffixed() } else { false }
774774
};
775775
let is_negative_int =
776-
|expr: &hir::Expr<'_>| matches!(expr.kind, hir::ExprKind::Unary(hir::UnOp::UnNeg, ..));
776+
|expr: &hir::Expr<'_>| matches!(expr.kind, hir::ExprKind::Unary(hir::UnOp::Neg, ..));
777777
let is_uint = |ty: Ty<'_>| matches!(ty.kind(), ty::Uint(..));
778778

779779
let in_const_context = self.tcx.hir().is_inside_const_context(expr.hir_id);

compiler/rustc_typeck/src/check/expr.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
323323
) -> Ty<'tcx> {
324324
let tcx = self.tcx;
325325
let expected_inner = match unop {
326-
hir::UnOp::UnNot | hir::UnOp::UnNeg => expected,
327-
hir::UnOp::UnDeref => NoExpectation,
326+
hir::UnOp::Not | hir::UnOp::Neg => expected,
327+
hir::UnOp::Deref => NoExpectation,
328328
};
329329
let mut oprnd_t = self.check_expr_with_expectation(&oprnd, expected_inner);
330330

331331
if !oprnd_t.references_error() {
332332
oprnd_t = self.structurally_resolved_type(expr.span, oprnd_t);
333333
match unop {
334-
hir::UnOp::UnDeref => {
334+
hir::UnOp::Deref => {
335335
if let Some(ty) = self.lookup_derefing(expr, oprnd, oprnd_t) {
336336
oprnd_t = ty;
337337
} else {
@@ -353,14 +353,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
353353
oprnd_t = tcx.ty_error();
354354
}
355355
}
356-
hir::UnOp::UnNot => {
356+
hir::UnOp::Not => {
357357
let result = self.check_user_unop(expr, oprnd_t, unop);
358358
// If it's builtin, we can reuse the type, this helps inference.
359359
if !(oprnd_t.is_integral() || *oprnd_t.kind() == ty::Bool) {
360360
oprnd_t = result;
361361
}
362362
}
363-
hir::UnOp::UnNeg => {
363+
hir::UnOp::Neg => {
364364
let result = self.check_user_unop(expr, oprnd_t, unop);
365365
// If it's builtin, we can reuse the type, this helps inference.
366366
if !oprnd_t.is_numeric() {

compiler/rustc_typeck/src/check/op.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
681681
format!("cannot apply unary operator `{}`", op.as_str()),
682682
);
683683
match actual.kind() {
684-
Uint(_) if op == hir::UnOp::UnNeg => {
684+
Uint(_) if op == hir::UnOp::Neg => {
685685
err.note("unsigned values cannot be negated");
686686

687687
if let hir::ExprKind::Unary(
@@ -711,9 +711,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
711711
Ref(_, ref lty, _) if *lty.kind() == Str => {}
712712
_ => {
713713
let missing_trait = match op {
714-
hir::UnOp::UnNeg => "std::ops::Neg",
715-
hir::UnOp::UnNot => "std::ops::Not",
716-
hir::UnOp::UnDeref => "std::ops::UnDerf",
714+
hir::UnOp::Neg => "std::ops::Neg",
715+
hir::UnOp::Not => "std::ops::Not",
716+
hir::UnOp::Deref => "std::ops::UnDerf",
717717
};
718718
suggest_impl_missing(&mut err, operand_ty, &missing_trait);
719719
}
@@ -782,9 +782,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
782782
span_bug!(span, "&& and || are not overloadable")
783783
}
784784
}
785-
} else if let Op::Unary(hir::UnOp::UnNot, _) = op {
785+
} else if let Op::Unary(hir::UnOp::Not, _) = op {
786786
(sym::not, lang.not_trait())
787-
} else if let Op::Unary(hir::UnOp::UnNeg, _) = op {
787+
} else if let Op::Unary(hir::UnOp::Neg, _) = op {
788788
(sym::neg, lang.neg_trait())
789789
} else {
790790
bug!("lookup_op_method: op not supported: {:?}", op)

compiler/rustc_typeck/src/check/place_op.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
203203

204204
while let hir::ExprKind::Field(ref expr, _)
205205
| hir::ExprKind::Index(ref expr, _)
206-
| hir::ExprKind::Unary(hir::UnOp::UnDeref, ref expr) = exprs.last().unwrap().kind
206+
| hir::ExprKind::Unary(hir::UnOp::Deref, ref expr) = exprs.last().unwrap().kind
207207
{
208208
exprs.push(&expr);
209209
}
@@ -216,7 +216,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
216216
debug!("convert_place_derefs_to_mutable: i={} expr={:?}", i, expr);
217217

218218
let mut source = self.node_ty(expr.hir_id);
219-
if matches!(expr.kind, hir::ExprKind::Unary(hir::UnOp::UnDeref, _)) {
219+
if matches!(expr.kind, hir::ExprKind::Unary(hir::UnOp::Deref, _)) {
220220
// Clear previous flag; after a pointer indirection it does not apply any more.
221221
inside_union = false;
222222
}
@@ -270,7 +270,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
270270
hir::ExprKind::Index(ref base_expr, ..) => {
271271
self.convert_place_op_to_mutable(PlaceOp::Index, expr, base_expr);
272272
}
273-
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref base_expr) => {
273+
hir::ExprKind::Unary(hir::UnOp::Deref, ref base_expr) => {
274274
self.convert_place_op_to_mutable(PlaceOp::Deref, expr, base_expr);
275275
}
276276
_ => {}

compiler/rustc_typeck/src/check/writeback.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
138138
// operating on scalars, we clear the overload.
139139
fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr<'_>) {
140140
match e.kind {
141-
hir::ExprKind::Unary(hir::UnOp::UnNeg | hir::UnOp::UnNot, ref inner) => {
141+
hir::ExprKind::Unary(hir::UnOp::Neg | hir::UnOp::Not, ref inner) => {
142142
let inner_ty = self.fcx.node_ty(inner.hir_id);
143143
let inner_ty = self.fcx.resolve_vars_if_possible(inner_ty);
144144

compiler/rustc_typeck/src/expr_use_visitor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
184184

185185
hir::ExprKind::Type(ref subexpr, _) => self.walk_expr(subexpr),
186186

187-
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref base) => {
187+
hir::ExprKind::Unary(hir::UnOp::Deref, ref base) => {
188188
// *base
189189
self.select_from_expr(base);
190190
}

compiler/rustc_typeck/src/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
303303

304304
let expr_ty = self.expr_ty(expr)?;
305305
match expr.kind {
306-
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref e_base) => {
306+
hir::ExprKind::Unary(hir::UnOp::Deref, ref e_base) => {
307307
if self.typeck_results.is_method_call(expr) {
308308
self.cat_overloaded_place(expr, e_base)
309309
} else {

src/librustdoc/clean/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ crate fn is_literal_expr(cx: &DocContext<'_>, hir_id: hir::HirId) -> bool {
316316
return true;
317317
}
318318

319-
if let hir::ExprKind::Unary(hir::UnOp::UnNeg, expr) = &expr.kind {
319+
if let hir::ExprKind::Unary(hir::UnOp::Neg, expr) = &expr.kind {
320320
if let hir::ExprKind::Lit(_) = &expr.kind {
321321
return true;
322322
}

src/tools/clippy/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() {

src/tools/clippy/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

src/tools/clippy/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,

src/tools/clippy/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, _) => {

src/tools/clippy/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
}

src/tools/clippy/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),

src/tools/clippy/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

src/tools/clippy/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
}

src/tools/clippy/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

src/tools/clippy/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);

0 commit comments

Comments
 (0)