Skip to content

Commit

Permalink
Ensure type is copyable before emitting note suggesting adding manual…
Browse files Browse the repository at this point in the history
… deref.
  • Loading branch information
pnkfelix committed Dec 26, 2016
1 parent 73bb063 commit 98218b3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/librustc_typeck/check/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
lhs_ty);

if let TypeVariants::TyRef(_, ref ty_mut) = lhs_ty.sty {
if self.lookup_op_method(expr, ty_mut.ty, vec![rhs_ty_var],
if !self.infcx.type_moves_by_default(ty_mut.ty, lhs_expr.span) &&
self.lookup_op_method(expr, ty_mut.ty, vec![rhs_ty_var],
token::intern(name), trait_def_id,
lhs_expr).is_ok() {
err.span_note(
Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/str-concat-on-double-ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ fn main() {
let b: &str = &"2";
let c = a + b;
//~^ ERROR binary operation `+` cannot be applied to type `&std::string::String`
//~| NOTE this is a reference of type that `+` can be applied to
//~| NOTE an implementation of `std::ops::Add` might be missing for `&std::string::String`
println!("{:?}", c);
}

0 comments on commit 98218b3

Please sign in to comment.