You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Kind checker is not aware of bounds on overloaded operators #2587
fn check_copy_ex(cx: ctx, ex: @expr, implicit_copy: bool) {
if ty::expr_is_lval(cx.method_map, ex) &&
!cx.last_use_map.contains_key(ex.id) &&
!is_nullary_variant(cx, ex) {
let ty = ty::expr_ty(cx.tcx, ex);
check_copy(cx, ex.id, ty, ex.span, implicit_copy);
}
}
In the test case for #2548, the self argument is in last-use position, so this code doesn't count it as a copy. In cases of overloaded operators that require a copy bound, I'm not sure the last-use optimization is legal.
Here is the general sketch of a test case for this:
fn foo<T: copy>(+t: T) { ... }
fn bar<T>(+t: T) { ... }
fn main() {
let v = something_noncopyable();
foo::<SomethingNoncopyable>(move v); // BAD
let w = something_noncopyable();
bar(move w); // OK
a + b
}
However, you have to rewrite it to use (1) overloaded operators, not function calls and (2) actual types :)
Activity
eholk commentedon Aug 3, 2012
The problem seems to be here (in kind.rs):
In the test case for #2548, the self argument is in last-use position, so this code doesn't count it as a copy. In cases of overloaded operators that require a copy bound, I'm not sure the last-use optimization is legal.
make borrowck more conservative around rvalues.
catamorphism commentedon Sep 6, 2012
Reproduced again. I'll work on it.
nikomatsakis commentedon Sep 6, 2012
Here is the general sketch of a test case for this:
However, you have to rewrite it to use (1) overloaded operators, not function calls and (2) actual types :)
Another test for #2587
Auto merge of rust-lang#2587 - RalfJung:josh, r=RalfJung
Merge pull request rust-lang#2587 from GuillaumeGomez/gcc-backend-mis…
Merge rust-lang#2587