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
use std;
import std::unsafe;
fn f(addr: @mutable int) -> ~int {
let i = ~100;
let a: int = unsafe::reinterpret_cast(i);
log a;
*addr = a;
// Since i is not a temporary it gets copied, which is not what you expect
ret i;
}
fn main() {
let addr = @mutable 0;
let i <- f(addr);
let expected = *addr;
let actual: int = unsafe::reinterpret_cast(i);
log expected;
log actual;
assert expected == actual;
}
It should not always perform a move. Consider returning foo.x, moving out of a data structure is invalid. Whether it moves should definitely depend on the type. For uniques, returning something that can't be moved is (if I understand correctly) an error. For other types, it should continue to implicitly copy.
Uniques don't have to be moved. They are allowed to be copied; they just don't like it. What approach can we take to make returning more likely to be a move? Is it true that it's always safe to do a move when returning a local?
Activity
marijnh commentedon Sep 30, 2011
It should not always perform a move. Consider returning
foo.x
, moving out of a data structure is invalid. Whether it moves should definitely depend on the type. For uniques, returning something that can't be moved is (if I understand correctly) an error. For other types, it should continue to implicitly copy.brson commentedon Sep 30, 2011
Uniques don't have to be moved. They are allowed to be copied; they just don't like it. What approach can we take to make returning more likely to be a move? Is it true that it's always safe to do a move when returning a local?
marijnh commentedon Sep 30, 2011
The optimization proposed in https://github.com/graydon/rust/issues/925 would help here.
marijnh commentedon Nov 22, 2011
This has been fixed by #1177
Avx512f avx512vl (rust-lang#995)
Use 2's complement when computing the relative discriminant to avoid …