Skip to content

Rename HIR UnOp variants #81913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ impl<'hir> LoweringContext<'_, 'hir> {

fn lower_unop(&mut self, u: UnOp) -> hir::UnOp {
match u {
UnOp::Deref => hir::UnOp::UnDeref,
UnOp::Not => hir::UnOp::UnNot,
UnOp::Neg => hir::UnOp::UnNeg,
UnOp::Deref => hir::UnOp::Deref,
UnOp::Not => hir::UnOp::Not,
UnOp::Neg => hir::UnOp::Neg,
}
}

Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,25 +1112,25 @@ pub type BinOp = Spanned<BinOpKind>;
#[derive(Copy, Clone, PartialEq, Encodable, Debug, HashStable_Generic)]
pub enum UnOp {
/// The `*` operator (deferencing).
UnDeref,
Deref,
/// The `!` operator (logical negation).
UnNot,
Not,
/// The `-` operator (negation).
UnNeg,
Neg,
}

impl UnOp {
pub fn as_str(self) -> &'static str {
match self {
Self::UnDeref => "*",
Self::UnNot => "!",
Self::UnNeg => "-",
Self::Deref => "*",
Self::Not => "!",
Self::Neg => "-",
}
}

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

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

ExprKind::Unary(UnOp::UnDeref, _) => true,
ExprKind::Unary(UnOp::Deref, _) => true,

ExprKind::Field(ref base, _) | ExprKind::Index(ref base, _) => {
allow_projections_from(base) || base.is_place_expr(allow_projections_from)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ fn lint_literal<'tcx>(
impl<'tcx> LateLintPass<'tcx> for TypeLimits {
fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx hir::Expr<'tcx>) {
match e.kind {
hir::ExprKind::Unary(hir::UnOp::UnNeg, ref expr) => {
hir::ExprKind::Unary(hir::UnOp::Neg, ref expr) => {
// propagate negation, if the negation itself isn't negated
if self.negated_expr_id != Some(e.hir_id) {
self.negated_expr_id = Some(expr.hir_id);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<'tcx> Const<'tcx> {

let lit_input = match expr.kind {
hir::ExprKind::Lit(ref lit) => Some(LitToConstInput { lit: &lit.node, ty, neg: false }),
hir::ExprKind::Unary(hir::UnOp::UnNeg, ref expr) => match expr.kind {
hir::ExprKind::Unary(hir::UnOp::Neg, ref expr) => match expr.kind {
hir::ExprKind::Lit(ref lit) => {
Some(LitToConstInput { lit: &lit.node, ty, neg: true })
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir_build/src/thir/cx/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,23 +299,23 @@ fn make_mirror_unadjusted<'a, 'tcx>(
}
}

hir::ExprKind::Unary(hir::UnOp::UnDeref, ref arg) => {
hir::ExprKind::Unary(hir::UnOp::Deref, ref arg) => {
if cx.typeck_results().is_method_call(expr) {
overloaded_place(cx, expr, expr_ty, None, vec![arg.to_ref()], expr.span)
} else {
ExprKind::Deref { arg: arg.to_ref() }
}
}

hir::ExprKind::Unary(hir::UnOp::UnNot, ref arg) => {
hir::ExprKind::Unary(hir::UnOp::Not, ref arg) => {
if cx.typeck_results().is_method_call(expr) {
overloaded_operator(cx, expr, vec![arg.to_ref()])
} else {
ExprKind::Unary { op: UnOp::Not, arg: arg.to_ref() }
}
}

hir::ExprKind::Unary(hir::UnOp::UnNeg, ref arg) => {
hir::ExprKind::Unary(hir::UnOp::Neg, ref arg) => {
if cx.typeck_results().is_method_call(expr) {
overloaded_operator(cx, expr, vec![arg.to_ref()])
} else if let hir::ExprKind::Lit(ref lit) = arg.kind {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/thir/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
return *self.const_to_pat(value, expr.hir_id, expr.span, false).kind;
}
hir::ExprKind::Lit(ref lit) => (lit, false),
hir::ExprKind::Unary(hir::UnOp::UnNeg, ref expr) => {
hir::ExprKind::Unary(hir::UnOp::Neg, ref expr) => {
let lit = match expr.kind {
hir::ExprKind::Lit(ref lit) => lit,
_ => span_bug!(expr.span, "not a literal: {:?}", expr),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ fn resolve_local<'tcx>(

match expr.kind {
hir::ExprKind::AddrOf(_, _, ref subexpr)
| hir::ExprKind::Unary(hir::UnOp::UnDeref, ref subexpr)
| hir::ExprKind::Unary(hir::UnOp::Deref, ref subexpr)
| hir::ExprKind::Field(ref subexpr, _)
| hir::ExprKind::Index(ref subexpr, _) => {
expr = &subexpr;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let hir::ExprKind::Lit(lit) = &expr.kind { lit.node.is_suffixed() } else { false }
};
let is_negative_int =
|expr: &hir::Expr<'_>| matches!(expr.kind, hir::ExprKind::Unary(hir::UnOp::UnNeg, ..));
|expr: &hir::Expr<'_>| matches!(expr.kind, hir::ExprKind::Unary(hir::UnOp::Neg, ..));
let is_uint = |ty: Ty<'_>| matches!(ty.kind(), ty::Uint(..));

let in_const_context = self.tcx.hir().is_inside_const_context(expr.hir_id);
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_typeck/src/check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,15 +323,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
) -> Ty<'tcx> {
let tcx = self.tcx;
let expected_inner = match unop {
hir::UnOp::UnNot | hir::UnOp::UnNeg => expected,
hir::UnOp::UnDeref => NoExpectation,
hir::UnOp::Not | hir::UnOp::Neg => expected,
hir::UnOp::Deref => NoExpectation,
};
let mut oprnd_t = self.check_expr_with_expectation(&oprnd, expected_inner);

if !oprnd_t.references_error() {
oprnd_t = self.structurally_resolved_type(expr.span, oprnd_t);
match unop {
hir::UnOp::UnDeref => {
hir::UnOp::Deref => {
if let Some(ty) = self.lookup_derefing(expr, oprnd, oprnd_t) {
oprnd_t = ty;
} else {
Expand All @@ -353,14 +353,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
oprnd_t = tcx.ty_error();
}
}
hir::UnOp::UnNot => {
hir::UnOp::Not => {
let result = self.check_user_unop(expr, oprnd_t, unop);
// If it's builtin, we can reuse the type, this helps inference.
if !(oprnd_t.is_integral() || *oprnd_t.kind() == ty::Bool) {
oprnd_t = result;
}
}
hir::UnOp::UnNeg => {
hir::UnOp::Neg => {
let result = self.check_user_unop(expr, oprnd_t, unop);
// If it's builtin, we can reuse the type, this helps inference.
if !oprnd_t.is_numeric() {
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_typeck/src/check/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
format!("cannot apply unary operator `{}`", op.as_str()),
);
match actual.kind() {
Uint(_) if op == hir::UnOp::UnNeg => {
Uint(_) if op == hir::UnOp::Neg => {
err.note("unsigned values cannot be negated");

if let hir::ExprKind::Unary(
Expand Down Expand Up @@ -711,9 +711,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Ref(_, ref lty, _) if *lty.kind() == Str => {}
_ => {
let missing_trait = match op {
hir::UnOp::UnNeg => "std::ops::Neg",
hir::UnOp::UnNot => "std::ops::Not",
hir::UnOp::UnDeref => "std::ops::UnDerf",
hir::UnOp::Neg => "std::ops::Neg",
hir::UnOp::Not => "std::ops::Not",
hir::UnOp::Deref => "std::ops::UnDerf",
};
suggest_impl_missing(&mut err, operand_ty, &missing_trait);
}
Expand Down Expand Up @@ -782,9 +782,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
span_bug!(span, "&& and || are not overloadable")
}
}
} else if let Op::Unary(hir::UnOp::UnNot, _) = op {
} else if let Op::Unary(hir::UnOp::Not, _) = op {
(sym::not, lang.not_trait())
} else if let Op::Unary(hir::UnOp::UnNeg, _) = op {
} else if let Op::Unary(hir::UnOp::Neg, _) = op {
(sym::neg, lang.neg_trait())
} else {
bug!("lookup_op_method: op not supported: {:?}", op)
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_typeck/src/check/place_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

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

let mut source = self.node_ty(expr.hir_id);
if matches!(expr.kind, hir::ExprKind::Unary(hir::UnOp::UnDeref, _)) {
if matches!(expr.kind, hir::ExprKind::Unary(hir::UnOp::Deref, _)) {
// Clear previous flag; after a pointer indirection it does not apply any more.
inside_union = false;
}
Expand Down Expand Up @@ -270,7 +270,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
hir::ExprKind::Index(ref base_expr, ..) => {
self.convert_place_op_to_mutable(PlaceOp::Index, expr, base_expr);
}
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref base_expr) => {
hir::ExprKind::Unary(hir::UnOp::Deref, ref base_expr) => {
self.convert_place_op_to_mutable(PlaceOp::Deref, expr, base_expr);
}
_ => {}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
// operating on scalars, we clear the overload.
fn fix_scalar_builtin_expr(&mut self, e: &hir::Expr<'_>) {
match e.kind {
hir::ExprKind::Unary(hir::UnOp::UnNeg | hir::UnOp::UnNot, ref inner) => {
hir::ExprKind::Unary(hir::UnOp::Neg | hir::UnOp::Not, ref inner) => {
let inner_ty = self.fcx.node_ty(inner.hir_id);
let inner_ty = self.fcx.resolve_vars_if_possible(inner_ty);

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {

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

hir::ExprKind::Unary(hir::UnOp::UnDeref, ref base) => {
hir::ExprKind::Unary(hir::UnOp::Deref, ref base) => {
// *base
self.select_from_expr(base);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {

let expr_ty = self.expr_ty(expr)?;
match expr.kind {
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref e_base) => {
hir::ExprKind::Unary(hir::UnOp::Deref, ref e_base) => {
if self.typeck_results.is_method_call(expr) {
self.cat_overloaded_place(expr, e_base)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ crate fn is_literal_expr(cx: &DocContext<'_>, hir_id: hir::HirId) -> bool {
return true;
}

if let hir::ExprKind::Unary(hir::UnOp::UnNeg, expr) = &expr.kind {
if let hir::ExprKind::Unary(hir::UnOp::Neg, expr) = &expr.kind {
if let hir::ExprKind::Lit(_) = &expr.kind {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_lints/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for Arithmetic {
match op.node {
hir::BinOpKind::Div | hir::BinOpKind::Rem => match &r.kind {
hir::ExprKind::Lit(_lit) => (),
hir::ExprKind::Unary(hir::UnOp::UnNeg, expr) => {
hir::ExprKind::Unary(hir::UnOp::Neg, expr) => {
if let hir::ExprKind::Lit(lit) = &expr.kind {
if let rustc_ast::ast::LitKind::Int(1, _) = lit.node {
span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected");
Expand All @@ -114,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for Arithmetic {
self.expr_span = Some(expr.span);
}
},
hir::ExprKind::Unary(hir::UnOp::UnNeg, arg) => {
hir::ExprKind::Unary(hir::UnOp::Neg, arg) => {
let ty = cx.typeck_results().expr_ty(arg);
if constant_simple(cx, cx.typeck_results(), expr).is_none() {
if ty.is_integral() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ enum AssertKind {
fn match_assert_with_message<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<AssertKind> {
if_chain! {
if let ExprKind::If(ref cond, ref then, _) = expr.kind;
if let ExprKind::Unary(UnOp::UnNot, ref expr) = cond.kind;
if let ExprKind::Unary(UnOp::Not, ref expr) = cond.kind;
// bind the first argument of the `assert!` macro
if let Some((Constant::Bool(is_true), _)) = constant(cx, cx.typeck_results(), expr);
// block
Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl<'a, 'tcx, 'v> Hir2Qmm<'a, 'tcx, 'v> {
// prevent folding of `cfg!` macros and the like
if !e.span.from_expansion() {
match &e.kind {
ExprKind::Unary(UnOp::UnNot, inner) => return Ok(Bool::Not(box self.run(inner)?)),
ExprKind::Unary(UnOp::Not, inner) => return Ok(Bool::Not(box self.run(inner)?)),
ExprKind::Binary(binop, lhs, rhs) => match &binop.node {
BinOpKind::Or => {
return Ok(Bool::Or(self.extract(BinOpKind::Or, &[lhs, rhs], Vec::new())?));
Expand Down Expand Up @@ -454,7 +454,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
ExprKind::Binary(binop, _, _) if binop.node == BinOpKind::Or || binop.node == BinOpKind::And => {
self.bool_expr(e)
},
ExprKind::Unary(UnOp::UnNot, inner) => {
ExprKind::Unary(UnOp::Not, inner) => {
if self.cx.typeck_results().node_types()[inner.hir_id].is_bool() {
self.bool_expr(e);
} else {
Expand Down Expand Up @@ -482,7 +482,7 @@ impl<'a, 'tcx> Visitor<'tcx> for NotSimplificationVisitor<'a, 'tcx> {
type Map = Map<'tcx>;

fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if let ExprKind::Unary(UnOp::UnNot, inner) = &expr.kind {
if let ExprKind::Unary(UnOp::Not, inner) = &expr.kind {
if let Some(suggestion) = simplify_not(self.cx, inner) {
span_lint_and_sugg(
self.cx,
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/bytecount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn check_arg(name: Symbol, arg: Symbol, needle: &Expr<'_>) -> bool {

fn get_path_name(expr: &Expr<'_>) -> Option<Symbol> {
match expr.kind {
ExprKind::Box(ref e) | ExprKind::AddrOf(BorrowKind::Ref, _, ref e) | ExprKind::Unary(UnOp::UnDeref, ref e) => {
ExprKind::Box(ref e) | ExprKind::AddrOf(BorrowKind::Ref, _, ref e) | ExprKind::Unary(UnOp::Deref, ref e) => {
get_path_name(e)
},
ExprKind::Block(ref b, _) => {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/collapsible_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fn addr_adjusted_binding(mut expr: &Expr<'_>, cx: &LateContext<'_>) -> Option<Hi
Res::Local(binding_id) => break Some(binding_id),
_ => break None,
},
ExprKind::Unary(UnOp::UnDeref, e) if cx.typeck_results().expr_ty(e).is_ref() => expr = e,
ExprKind::Unary(UnOp::Deref, e) if cx.typeck_results().expr_ty(e).is_ref() => expr = e,
_ => break None,
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/clippy_lints/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
self.expr(value).map(|v| Constant::Repeat(Box::new(v), n))
},
ExprKind::Unary(op, ref operand) => self.expr(operand).and_then(|o| match op {
UnOp::UnNot => self.constant_not(&o, self.typeck_results.expr_ty(e)),
UnOp::UnNeg => self.constant_negate(&o, self.typeck_results.expr_ty(e)),
UnOp::UnDeref => Some(if let Constant::Ref(r) = o { *r } else { o }),
UnOp::Not => self.constant_not(&o, self.typeck_results.expr_ty(e)),
UnOp::Neg => self.constant_negate(&o, self.typeck_results.expr_ty(e)),
UnOp::Deref => Some(if let Constant::Ref(r) = o { *r } else { o }),
}),
ExprKind::If(ref cond, ref then, ref otherwise) => self.ifthenelse(cond, then, *otherwise),
ExprKind::Binary(op, ref left, ref right) => self.binop(op, left, right),
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ declare_lint_pass!(HashMapPass => [MAP_ENTRY]);
impl<'tcx> LateLintPass<'tcx> for HashMapPass {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
if let ExprKind::If(ref check, ref then_block, ref else_block) = expr.kind {
if let ExprKind::Unary(UnOp::UnNot, ref check) = check.kind {
if let ExprKind::Unary(UnOp::Not, ref check) = check.kind {
if let Some((ty, map, key)) = check_cond(cx, check) {
// in case of `if !m.contains_key(&k) { m.insert(k, v); }`
// we can give a better error message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fn get_specialized_log_method(cx: &LateContext<'_>, base: &Expr<'_>) -> Option<&
fn prepare_receiver_sugg<'a>(cx: &LateContext<'_>, mut expr: &'a Expr<'a>) -> Sugg<'a> {
let mut suggestion = Sugg::hir(cx, expr, "..");

if let ExprKind::Unary(UnOp::UnNeg, inner_expr) = &expr.kind {
if let ExprKind::Unary(UnOp::Neg, inner_expr) = &expr.kind {
expr = &inner_expr;
}

Expand Down Expand Up @@ -541,12 +541,12 @@ fn is_zero(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
/// If the two expressions are not negations of each other, then it
/// returns None.
fn are_negated<'a>(cx: &LateContext<'_>, expr1: &'a Expr<'a>, expr2: &'a Expr<'a>) -> Option<(bool, &'a Expr<'a>)> {
if let ExprKind::Unary(UnOp::UnNeg, expr1_negated) = &expr1.kind {
if let ExprKind::Unary(UnOp::Neg, expr1_negated) = &expr1.kind {
if eq_expr_value(cx, expr1_negated, expr2) {
return Some((false, expr2));
}
}
if let ExprKind::Unary(UnOp::UnNeg, expr2_negated) = &expr2.kind {
if let ExprKind::Unary(UnOp::Neg, expr2_negated) = &expr2.kind {
if eq_expr_value(cx, expr1, expr2_negated) {
return Some((true, expr1));
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
}
}
},
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref ptr) => self.check_arg(ptr),
hir::ExprKind::Unary(hir::UnOp::Deref, ref ptr) => self.check_arg(ptr),
_ => (),
}

Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/map_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for MapClone {
},
hir::PatKind::Binding(hir::BindingAnnotation::Unannotated, .., name, None) => {
match closure_expr.kind {
hir::ExprKind::Unary(hir::UnOp::UnDeref, ref inner) => {
hir::ExprKind::Unary(hir::UnOp::Deref, ref inner) => {
if ident_eq(name, inner) {
if let ty::Ref(.., Mutability::Not) = cx.typeck_results().expr_ty(inner).kind() {
lint(cx, e.span, args[0].span, true);
Expand Down
Loading