Skip to content

Commit 98218b3

Browse files
committed
Ensure type is copyable before emitting note suggesting adding manual deref.
1 parent 73bb063 commit 98218b3

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/librustc_typeck/check/op.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
206206
lhs_ty);
207207

208208
if let TypeVariants::TyRef(_, ref ty_mut) = lhs_ty.sty {
209-
if self.lookup_op_method(expr, ty_mut.ty, vec![rhs_ty_var],
209+
if !self.infcx.type_moves_by_default(ty_mut.ty, lhs_expr.span) &&
210+
self.lookup_op_method(expr, ty_mut.ty, vec![rhs_ty_var],
210211
token::intern(name), trait_def_id,
211212
lhs_expr).is_ok() {
212213
err.span_note(

src/test/compile-fail/str-concat-on-double-ref.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ fn main() {
1313
let b: &str = &"2";
1414
let c = a + b;
1515
//~^ ERROR binary operation `+` cannot be applied to type `&std::string::String`
16-
//~| NOTE this is a reference of type that `+` can be applied to
1716
//~| NOTE an implementation of `std::ops::Add` might be missing for `&std::string::String`
1817
println!("{:?}", c);
1918
}

0 commit comments

Comments
 (0)