Skip to content

Commit b8669df

Browse files
committed
Ensure type is copyable before emitting note suggesting adding manual deref.
drive-by: fix merge conflict; fix test expected error output post rebase.
1 parent 0d39584 commit b8669df

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/librustc_typeck/check/op.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,9 @@ 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],
210-
token::intern(name), trait_def_id,
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],
211+
Symbol::intern(name), trait_def_id,
211212
lhs_expr).is_ok() {
212213
err.span_note(
213214
lhs_expr.span,

src/test/compile-fail/binary-op-on-double-ref.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ fn main() {
1212
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
1313
let vr = v.iter().filter(|x| {
1414
x % 2 == 0
15-
//~^ ERROR binary operation `%` cannot be applied to type `&&_`
15+
//~^ ERROR binary operation `%` cannot be applied to type `&&{integer}`
1616
//~| NOTE this is a reference of type that `%` can be applied to
17-
//~| NOTE an implementation of `std::ops::Rem` might be missing for `&&_`
17+
//~| NOTE an implementation of `std::ops::Rem` might be missing for `&&{integer}`
1818
});
1919
println!("{:?}", vr);
2020
}

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)