Skip to content

Commit 9b5de39

Browse files
author
Jorge Aparicio
committed
Address Niko's comments
1 parent d15d152 commit 9b5de39

File tree

1 file changed

+5
-4
lines changed
  • src/librustc_typeck/check

1 file changed

+5
-4
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3356,14 +3356,15 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
33563356
trait_did: Option<ast::DefId>,
33573357
ex: &ast::Expr,
33583358
rhs_expr: &ast::Expr,
3359-
rhs_t: Ty<'tcx>) -> Ty<'tcx> {
3359+
rhs_t: Ty<'tcx>,
3360+
op: ast::UnOp) -> Ty<'tcx> {
33603361
lookup_op_method(fcx, ex, rhs_t, token::intern(mname),
33613362
trait_did, rhs_expr, None, || {
33623363
fcx.type_error_message(ex.span, |actual| {
33633364
format!("cannot apply unary operator `{}` to type `{}`",
33643365
op_str, actual)
33653366
}, rhs_t, None);
3366-
}, AutorefArgs::No)
3367+
}, if ast_util::is_by_value_unop(op) { AutorefArgs::No } else { AutorefArgs::Yes })
33673368
}
33683369

33693370
// Check field access expressions
@@ -3803,7 +3804,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
38033804
oprnd_t.sty == ty::ty_bool) {
38043805
oprnd_t = check_user_unop(fcx, "!", "not",
38053806
tcx.lang_items.not_trait(),
3806-
expr, &**oprnd, oprnd_t);
3807+
expr, &**oprnd, oprnd_t, unop);
38073808
}
38083809
}
38093810
ast::UnNeg => {
@@ -3813,7 +3814,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
38133814
ty::type_is_fp(oprnd_t)) {
38143815
oprnd_t = check_user_unop(fcx, "-", "neg",
38153816
tcx.lang_items.neg_trait(),
3816-
expr, &**oprnd, oprnd_t);
3817+
expr, &**oprnd, oprnd_t, unop);
38173818
}
38183819
}
38193820
}

0 commit comments

Comments
 (0)