Idea: provide functions for 'exhaustive' and 'random' modification of vecs.
- two functions, "return all edits" and "return a random edit" <--
+ two functions, "return all edits" and "return a random edit" = move-
leaning toward this model or two functions, "return the number of
possible edits" and "return edit #n"
/// Consumes the vector and returns its contents
pub fn unwrap<A>(d: DVec<A>) -> ~[A] {
- let DVec_({data: v}) <- d;
+ let DVec_({data: v}) = move d;
move v
}
/// Overwrite the current contents
fn set(w: ~[A]) {
self.check_not_borrowed();
- self.data <- w;
+ self.data = move w;
}
/// Remove and return the last element
fn pop() -> A {
do self.check_out |v| {
- let mut v <- v;
+ let mut v = move v;
let result = v.pop();
self.give_back(move v);
move result
let data_ptr: *() = cast::reinterpret_cast(&data);
if data_ptr.is_null() { fail ~"Recursive use of dvec"; }
log(error, ~"a");
- self.data <- ~[move t];
+ self.data = move ~[move t];
self.data.push_all_move(move data);
log(error, ~"b");
}
/// Appends elements from `from_idx` to `to_idx` (exclusive)
fn push_slice(ts: &[const A], from_idx: uint, to_idx: uint) {
do self.swap |v| {
- let mut v <- v;
+ let mut v = move v;
let new_len = vec::len(v) + to_idx - from_idx;
vec::reserve(&mut v, new_len);
let mut i = from_idx;
none { v }
Some(h) {
let len = v.len() + h;
- let mut v <- v;
+ let mut v = move v;
vec::reserve(v, len);
v
}
impl BytesWriter: Writer {
fn write(v: &[const u8]) {
do self.bytes.swap |bytes| {
- let mut bytes <- bytes;
+ let mut bytes = move bytes;
let v_len = v.len();
let bytes_len = bytes.len();
pub pure fn foldl<A,B,IA:BaseIter<A>>(self: &IA, b0: B,
blk: fn(&B, &A) -> B)
-> B {
- let mut b <- b0;
+ let mut b = move b0;
for self.each |a| {
b = blk(&b, a);
}
pub pure fn while_some<T>(x: Option<T>, blk: fn(v: T) -> Option<T>) {
//! Applies a function zero or more times until the result is none.
- let mut opt <- x;
+ let mut opt = move x;
while opt.is_some() {
opt = blk(unwrap(move opt));
}
const SPIN_COUNT: uint = 0;
macro_rules! move_it (
- { $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
+ { $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
)
#[doc(hidden)]
let p = unsafe { &*p_ };
assert ptr::addr_of(&(p.header)) == header;
assert p.payload.is_none();
- p.payload <- Some(move payload);
+ p.payload = move Some(move payload);
let old_state = swap_state_rel(&mut p.header.state, Full);
match old_state {
Empty => {
-> (uint, Option<T>, ~[RecvPacketBuffered<T, Tb>])
{
let ready = wait_many(endpoints.map(|p| p.header()));
- let mut remaining <- endpoints;
+ let mut remaining = move endpoints;
let port = remaining.swap_remove(ready);
let result = try_recv(move port);
(ready, move result, move remaining)
// FIXME(#3724) make this a by-move method on the exclusive
pub fn unwrap_exclusive<T: Send>(arc: Exclusive<T>) -> T {
- let Exclusive { x: x } <- arc;
+ let Exclusive { x: x } = move arc;
let inner = unsafe { unwrap_shared_mutable_state(move x) };
- let ExData { data: data, _ } <- inner;
+ let ExData { data: data, _ } = move inner;
move data
}
/// Concatenate two strings together
#[inline(always)]
pub pure fn append(lhs: ~str, rhs: &str) -> ~str {
- let mut v <- lhs;
+ let mut v = move lhs;
unsafe {
push_str_no_overallocate(&mut v, rhs);
}
use rt::rust_closure;
macro_rules! move_it (
- { $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
+ { $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
)
type TaskSet = send_map::linear::LinearMap<*rust_task,()>;
if coalesce_this.is_some() {
// Needed coalesce. Our next ancestor becomes our old
// ancestor's next ancestor. ("next = old_next->next;")
- *list <- option::unwrap(move coalesce_this);
+ *list = move option::unwrap(move coalesce_this);
} else {
// No coalesce; restore from tmp. ("next = old_next;")
- *list <- tmp_list;
+ *list = move tmp_list;
}
return early_break;
}
// If this trips, more likely the problem is 'blk' failed inside.
let tmp_arc = option::swap_unwrap(parent_group);
let result = do access_group(&tmp_arc) |tg_opt| { blk(tg_opt) };
- *parent_group <- Some(move tmp_arc);
+ *parent_group = move Some(move tmp_arc);
move result
}
}
if tmp.is_some() {
let ancestor_arc = option::unwrap(move tmp);
let result = ancestor_arc.clone();
- **ancestors <- Some(move ancestor_arc);
+ **ancestors = move Some(move ancestor_arc);
AncestorList(Some(move result))
} else {
AncestorList(None)
*/
#[inline(always)]
pub fn replace<T>(dest: &mut T, src: T) -> T {
- let mut tmp <- src;
+ let mut tmp = move src;
swap(dest, &mut tmp);
move tmp
}
let mut rr;
{
let vv = raw::to_ptr(vv);
- rr <- *vv;
+ rr = move *vv;
for uint::range(1, ln) |i| {
- let r <- *ptr::offset(vv, i);
+ let r = move *ptr::offset(vv, i);
v.push(move r);
}
}
do as_imm_buf(v) |p, ln| {
for uint::range(0, ln) |i| {
- let x <- *ptr::offset(p, i);
+ let x = move *ptr::offset(p, i);
f(i, move x);
}
}
unsafe {
do as_imm_buf(rhs) |p, len| {
for uint::range(0, len) |i| {
- let x <- *ptr::offset(p, i);
+ let x = move *ptr::offset(p, i);
push(v, move x);
}
}
unsafe {
// This loop is optimized out for non-drop types.
for uint::range(newlen, oldlen) |i| {
- let _dropped <- *ptr::offset(p, i);
+ let _dropped = move *ptr::offset(p, i);
}
raw::set_len(v, newlen);
}
// last_written < next_to_read < ln
if *ptr::mut_offset(p, next_to_read) ==
*ptr::mut_offset(p, last_written) {
- let _dropped <- *ptr::mut_offset(p, next_to_read);
+ let _dropped = move *ptr::mut_offset(p, next_to_read);
} else {
last_written += 1;
// last_written <= next_to_read < ln
if next_to_read != last_written {
- *ptr::mut_offset(p, last_written) <-
+ *ptr::mut_offset(p, last_written) = move
*ptr::mut_offset(p, next_to_read);
}
}
// Appending
#[inline(always)]
pub pure fn append<T: Copy>(lhs: ~[T], rhs: &[const T]) -> ~[T] {
- let mut v <- lhs;
+ let mut v = move lhs;
unsafe {
v.push_all(rhs);
}
#[inline(always)]
pub pure fn append_one<T>(lhs: ~[T], x: T) -> ~[T] {
- let mut v <- lhs;
+ let mut v = move lhs;
unsafe { v.push(move x); }
move v
}
/// Reverse the order of elements in a vector, in place
pub fn reverse<T>(v: &[mut T]) {
- let mut i: uint = 0u;
+ let mut i: uint = 0;
let ln = len::<T>(v);
- while i < ln / 2u { v[i] <-> v[ln - i - 1u]; i += 1u; }
+ while i < ln / 2 { v[i] <-> v[ln - i - 1]; i += 1; }
}
/// Returns a vector with the order of elements reversed
* guaranteed to deadlock.
*/
fn unwrap<T: Const Send>(rc: ARC<T>) -> T {
- let ARC { x: x } <- rc;
+ let ARC { x: x } = move rc;
unsafe { unwrap_shared_mutable_state(move x) }
}
*/
// FIXME(#3724) make this a by-move method on the arc
pub fn unwrap_mutex_arc<T: Send>(arc: MutexARC<T>) -> T {
- let MutexARC { x: x } <- arc;
+ let MutexARC { x: x } = move arc;
let inner = unsafe { unwrap_shared_mutable_state(move x) };
- let MutexARCInner { failed: failed, data: data, _ } <- inner;
+ let MutexARCInner { failed: failed, data: data, _ } = move inner;
if failed {
fail ~"Can't unwrap poisoned MutexARC - another task failed inside!"
}
fn downgrade(token: RWWriteMode/&a<T>) -> RWReadMode/&a<T> {
// The rwlock should assert that the token belongs to us for us.
let state = unsafe { get_shared_immutable_state(&self.x) };
- let RWWriteMode((data, t, _poison)) <- token;
+ let RWWriteMode((data, t, _poison)) = move token;
// Let readers in
let new_token = (&state.lock).downgrade(move t);
// Whatever region the input reference had, it will be safe to use
*/
// FIXME(#3724) make this a by-move method on the arc
pub fn unwrap_rw_arc<T: Const Send>(arc: RWARC<T>) -> T {
- let RWARC { x: x, _ } <- arc;
+ let RWARC { x: x, _ } = move arc;
let inner = unsafe { unwrap_shared_mutable_state(move x) };
- let RWARCInner { failed: failed, data: data, _ } <- inner;
+ let RWARCInner { failed: failed, data: data, _ } = move inner;
if failed {
fail ~"Can't unwrap poisoned RWARC - another task failed inside!"
}
entry.next = new_chains[idx];
new_chains[idx] = Some(entry);
}
- self.chains <- new_chains;
+ self.chains = move new_chains;
}
pure fn each_entry(blk: fn(@Entry<K,V>) -> bool) {
pub fn merge_sort<T: Copy>(le: Le<T>, v: &[const T]) -> ~[T] {
type Slice = (uint, uint);
- return merge_sort_(le, v, (0u, len(v)));
+ return merge_sort_(le, v, (0, len(v)));
fn merge_sort_<T: Copy>(le: Le<T>, v: &[const T], slice: Slice)
-> ~[T] {
let end = slice.second();
let v_len = end - begin;
- if v_len == 0u { return ~[]; }
- if v_len == 1u { return ~[v[begin]]; }
+ if v_len == 0 { return ~[]; }
+ if v_len == 1 { return ~[v[begin]]; }
- let mid = v_len / 2u + begin;
+ let mid = v_len / 2 + begin;
let a = (begin, mid);
let b = (mid, end);
return merge(le, merge_sort_(le, v, a), merge_sort_(le, v, b));
fn merge<T: Copy>(le: Le<T>, a: &[T], b: &[T]) -> ~[T] {
let mut rs = vec::with_capacity(len(a) + len(b));
let a_len = len(a);
- let mut a_ix = 0u;
+ let mut a_ix = 0;
let b_len = len(b);
- let mut b_ix = 0u;
+ let mut b_ix = 0;
while a_ix < a_len && b_ix < b_len {
if le(&a[a_ix], &b[b_ix]) {
rs.push(a[a_ix]);
- a_ix += 1u;
- } else { rs.push(b[b_ix]); b_ix += 1u; }
+ a_ix += 1;
+ } else { rs.push(b[b_ix]); b_ix += 1; }
}
rs = vec::append(rs, vec::slice(a, a_ix, a_len));
rs = vec::append(rs, vec::slice(b, b_ix, b_len));
while i < right {
if compare_func(&arr[i], &pivot_value) {
arr[i] <-> arr[storage_index];
- storage_index += 1u;
+ storage_index += 1;
}
- i += 1u;
+ i += 1;
}
arr[storage_index] <-> arr[right];
return storage_index;
fn qsort<T: Copy>(compare_func: Le<T>, arr: &[mut T], left: uint,
right: uint) {
if right > left {
- let pivot = (left + right) / 2u;
+ let pivot = (left + right) / 2;
let new_pivot = part::<T>(compare_func, arr, left, right, pivot);
- if new_pivot != 0u {
+ if new_pivot != 0 {
// Need to do this check before recursing due to overflow
- qsort::<T>(compare_func, arr, left, new_pivot - 1u);
+ qsort::<T>(compare_func, arr, left, new_pivot - 1);
}
- qsort::<T>(compare_func, arr, new_pivot + 1u, right);
+ qsort::<T>(compare_func, arr, new_pivot + 1, right);
}
}
* This is an unstable sort.
*/
pub fn quick_sort<T: Copy>(compare_func: Le<T>, arr: &[mut T]) {
- if len::<T>(arr) == 0u { return; }
- qsort::<T>(compare_func, arr, 0u, len::<T>(arr) - 1u);
+ if len::<T>(arr) == 0 { return; }
+ qsort::<T>(compare_func, arr, 0, len::<T>(arr) - 1);
}
fn qsort3<T: Copy Ord Eq>(arr: &[mut T], left: int, right: int) {
fn check_sort(v1: &[mut int], v2: &[mut int]) {
let len = vec::len::<int>(v1);
quick_sort3::<int>(v1);
- let mut i = 0u;
+ let mut i = 0;
while i < len {
log(debug, v2[i]);
assert (v2[i] == v1[i]);
- i += 1u;
+ i += 1;
}
}
let len = vec::len::<int>(v1);
pure fn leual(a: &int, b: &int) -> bool { *a <= *b }
quick_sort::<int>(leual, v1);
- let mut i = 0u;
+ let mut i = 0;
while i < len {
log(debug, v2[i]);
assert (v2[i] == v1[i]);
- i += 1u;
+ i += 1;
}
}
pub pure fn le(a: &int, b: &int) -> bool { *a <= *b }
let f = le;
let v3 = merge_sort::<int>(f, v1);
- let mut i = 0u;
+ let mut i = 0;
while i < len {
log(debug, v3[i]);
assert (v3[i] == v2[i]);
- i += 1u;
+ i += 1;
}
}
#[test]
fn test_mutex_lock() {
// Unsafely achieve shared state, and do the textbook
- // "load tmp <- ptr; inc tmp; store ptr <- tmp" dance.
+ // "load tmp = move ptr; inc tmp; store ptr <- tmp" dance.
let (c,p) = pipes::stream();
let m = ~Mutex();
let m2 = ~m.clone();
+// xfail-pretty
// Microbenchmarks for various functions in core and std
extern mod std;
use pipes::{Port, Chan, SharedChan};
macro_rules! move_out (
- { $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
+ { $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
)
enum request {
use pipes::{Port, PortSet, Chan};
macro_rules! move_out (
- { $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
+ { $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
)
enum request {
count: uint,
+num_chan: pipe,
+num_port: pipe) {
- let mut num_chan <- Some(move num_chan);
- let mut num_port <- Some(move num_port);
+ let mut num_chan = move Some(move num_chan);
+ let mut num_port = move Some(move num_port);
// Send/Receive lots of messages.
for uint::range(0u, count) |j| {
//error!("task %?, iter %?", i, j);
fn macros() {
#macro[
[#move_out[x],
- unsafe { let y <- *ptr::addr_of(&x); move y }]
+ unsafe { let y = move *ptr::addr_of(&x); move y }]
];
}
count: uint,
+num_chan: ring::client::num,
+num_port: ring::server::num) {
- let mut num_chan <- Some(move num_chan);
- let mut num_port <- Some(move num_port);
+ let mut num_chan = move Some(move num_chan);
+ let mut num_port = move Some(move num_port);
// Send/Receive lots of messages.
for uint::range(0, count) |j| {
//error!("task %?, iter %?", i, j);
count: uint,
+num_chan: pipe,
+num_port: pipe) {
- let mut num_chan <- Some(move num_chan);
- let mut num_port <- Some(move num_port);
+ let mut num_chan = move Some(move num_chan);
+ let mut num_port = move Some(move num_port);
// Send/Receive lots of messages.
for uint::range(0u, count) |j| {
//error!("task %?, iter %?", i, j);
// This stuff should go in libcore::pipes
macro_rules! move_it (
- { $x:expr } => { let t <- *ptr::addr_of(&($x)); move t }
+ { $x:expr } => { let t = move *ptr::addr_of(&($x)); move t }
)
macro_rules! follow (
use to_bytes::IterBytes;
macro_rules! move_out (
- { $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
+ { $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
)
trait word_reader {
let mut x = @{x: 17, y: 2};
let y = @{x: 5, y: 5};
- force(|| x <- y );
+ force(|| x = move y );
}
let x = Some(~1);
match x { //~ NOTE loan of immutable local variable granted here
Some(ref _y) => {
- let _a <- x; //~ ERROR moving out of immutable local variable prohibited due to outstanding loan
+ let _a = move x; //~ ERROR moving out of immutable local variable prohibited due to outstanding loan
}
_ => {}
}
let x = Some(~1);
match x {
Some(ref y) => {
- let _b <- *y; //~ ERROR moving out of dereference of immutable & pointer
+ let _b = move *y; //~ ERROR moving out of dereference of immutable & pointer
}
_ => {}
}
fn foo(x: *~int) -> ~int {
- let y <- *x; //~ ERROR dereference of unsafe pointer requires unsafe function or block
+ let y = move *x; //~ ERROR dereference of unsafe pointer requires unsafe function or block
return y;
}
// Create a cycle!
match *x { //~ NOTE loan of immutable local variable granted here
node(ref y) => {
- y.a <- x; //~ ERROR moving out of immutable local variable prohibited due to outstanding loan
+ y.a = move x; //~ ERROR moving out of immutable local variable prohibited due to outstanding loan
}
empty => {}
};
}
}
-fn main() { let x <- foo(10); let y = x; log(error, x); }
+fn main() { let x = move foo(10); let y = x; log(error, x); }
let mut res = foo(x);
let mut v = ~[mut];
- v <- ~[mut (move res)] + v; //~ ERROR instantiating a type parameter with an incompatible type (needs `copy`, got `owned`, missing `copy`)
+ v = move ~[mut (move res)] + v; //~ ERROR instantiating a type parameter with an incompatible type (needs `copy`, got `owned`, missing `copy`)
assert (v.len() == 2);
}
loop {
loop {
loop {
- x <- y; //~ ERROR use of moved variable
+// tjc: Not sure why it prints the same error twice
+ x = move y; //~ ERROR use of moved variable
//~^ NOTE move of variable occurred here
+ //~^^ ERROR use of moved variable
+ //~^^^ NOTE move of variable occurred here
copy x;
}
let mut x: int;
loop {
log(debug, y);
- while true { while true { while true { x <- y; copy x; } } }
+// tjc: not sure why it prints the same error twice
+ while true { while true { while true { x = move y; copy x; } } }
//~^ ERROR use of moved variable: `y`
//~^^ NOTE move of variable occurred here
+ //~^^^ ERROR use of moved variable: `y`
+ //~^^^^ NOTE move of variable occurred here
}
}
fn main() {
let x = @5;
- let y <- x; //~ NOTE move of variable occurred here
+ let y = move x; //~ NOTE move of variable occurred here
log(debug, *x); //~ ERROR use of moved variable: `x`
copy y;
}
}
}
-fn main() { let x <- foo(10); let y = x; log(error, x); }
+fn main() { let x = move foo(10); let y = x; log(error, x); }
//~^ ERROR obsolete syntax: fixed-length vector
}
+fn obsolete_moves() {
+ let mut x = 0;
+ let y <- x;
+ //~^ ERROR obsolete syntax: initializer-by-move
+ y <- x;
+ //~^ ERROR obsolete syntax: binary move
+}
+
fn main() { }
}
fn main() {
- let i <- ~r { b: true };
+ let i = move ~r { b: true };
let j = i;
log(debug, i);
}
\ No newline at end of file
fn main() {
let i1 = @mut 0;
let i2 = @mut 1;
- let r1 <- ~[~r { i: i1 }];
- let r2 <- ~[~r { i: i2 }];
+ let r1 = move ~[~r { i: i1 }];
+ let r2 = move ~[~r { i: i2 }];
f(r1, r2);
log(debug, (r2, *i1));
log(debug, (r1, *i2));
fn main() {
// This can't make sense as it would copy the classes
- let i <- ~[r(0)];
- let j <- ~[r(1)];
+ let i = move ~[r(0)];
+ let j = move ~[r(1)];
let k = i + j;
log(debug, j);
}
fn main() {
@0;
- let r <- r(0);
+ let r = move r(0);
}
\ No newline at end of file
fn main() {
@0;
- let r <- r(0);
+ let r = move r(0);
fail;
}
\ No newline at end of file
fn bar(x: *~int) -> ~int {
unsafe {
- let y <- *x;
+ let y = move *x;
return y;
}
}
let mut values = ~[];
x.values <-> values;
values.push(v);
- x.values <- values;
+ x.values <-> values;
}
fn iter_ints(x: &ints, f: fn(x: &int) -> bool) {
#[legacy_exports];
//
use a2::b1::*;
- // <-\
+ // = move\
export word_traveler; // |
}
// |
#[legacy_exports];
// |
use a2::b2::*;
- // <-\ -\ |
+ // = move\ -\ |
export word_traveler; // | | |
} // | | |
}
#[legacy_exports];
// | | |
use a1::b2::*;
- // | <-/ -/
+ // | = move/ -/
export word_traveler; // |
}
// |
fn test_box() {
let i = @mut 0;
{
- let a <- @r(i);
+ let a = move @r(i);
}
assert *i == 1;
}
fn test_rec() {
let i = @mut 0;
{
- let a <- {x: r(i)};
+ let a = move {x: r(i)};
}
assert *i == 1;
}
let i = @mut 0;
{
- let a <- t0(r(i));
+ let a = move t0(r(i));
}
assert *i == 1;
}
fn test_tup() {
let i = @mut 0;
{
- let a <- (r(i), 0);
+ let a = move (r(i), 0);
}
assert *i == 1;
}
fn test_unique() {
let i = @mut 0;
{
- let a <- ~r(i);
+ let a = move ~r(i);
}
assert *i == 1;
}
fn test_box_rec() {
let i = @mut 0;
{
- let a <- @{
+ let a = move @{
x: r(i)
};
}
}
fn foldl<A,B,IA:iterable<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B {
- let mut b <- b0;
+ let mut b = move b0;
do self.iter |a| {
- b <- blk(b, a);
+ b = move blk(b, a);
}
move b
}
let p = p.unwrap();
let p = unsafe { uniquify(p) };
assert (*p).payload.is_none();
- (*p).payload <- Some(move payload);
+ (*p).payload = move Some(move payload);
let old_state = swap_state_rel(&mut (*p).state, full);
match old_state {
empty => {
let addr : *pipes::send_packet<pong> = match p {
ping(x) => { cast::transmute(ptr::addr_of(&x)) }
};
- let liberated_value <- *addr;
+ let liberated_value = move *addr;
cast::forget(move p);
move liberated_value
}
let addr : *pipes::send_packet<ping> = match p {
pong(x) => { cast::transmute(ptr::addr_of(&x)) }
};
- let liberated_value <- *addr;
+ let liberated_value = move *addr;
cast::forget(move p);
move liberated_value
}
fn test(x: bool, foo: ~{x: int, y: int, z: int}) -> int {
let bar = foo;
let mut y: ~{x: int, y: int, z: int};
- if x { y <- bar; } else { y = ~{x: 4, y: 5, z: 6}; }
+ if x { y = move bar; } else { y = ~{x: 4, y: 5, z: 6}; }
return y.y;
}
fn test(x: bool, foo: @{x: int, y: int, z: int}) -> int {
let bar = foo;
let mut y: @{x: int, y: int, z: int};
- if x { y <- bar; } else { y = @{x: 4, y: 5, z: 6}; }
+ if x { y = move bar; } else { y = @{x: 4, y: 5, z: 6}; }
return y.y;
}
-fn main() { let x = ~{x: 1, y: 2, z: 3}; let y <- x; assert (y.y == 2); }
+fn main() { let x = ~{x: 1, y: 2, z: 3}; let y = move x; assert (y.y == 2); }
-fn main() { let x = @{x: 1, y: 2, z: 3}; let y <- x; assert (y.y == 2); }
+fn main() { let x = @{x: 1, y: 2, z: 3}; let y = move x; assert (y.y == 2); }
fn test(x: bool, foo: ~{x: int, y: int, z: int}) -> int {
let bar = foo;
let mut y: ~{x: int, y: int, z: int};
- if x { y <- bar; } else { y = ~{x: 4, y: 5, z: 6}; }
+ if x { y = move bar; } else { y = ~{x: 4, y: 5, z: 6}; }
return y.y;
}
fn test(x: bool, foo: @{x: int, y: int, z: int}) -> int {
let bar = foo;
let mut y: @{x: int, y: int, z: int};
- if x { y <- bar; } else { y = @{x: 4, y: 5, z: 6}; }
+ if x { y = move bar; } else { y = @{x: 4, y: 5, z: 6}; }
return y.y;
}
fn test(foo: ~{a: int, b: int, c: int}) -> ~{a: int, b: int, c: int} {
let foo = foo;
- let bar <- foo;
- let baz <- bar;
- let quux <- baz;
+ let bar = move foo;
+ let baz = move bar;
+ let quux = move baz;
return quux;
}
fn test(foo: @{a: int, b: int, c: int}) -> @{a: int, b: int, c: int} {
let foo = foo;
- let bar <- foo;
- let baz <- bar;
- let quux <- baz;
+ let bar = move foo;
+ let baz = move bar;
+ let quux = move baz;
return quux;
}
let y: int = 42;
let mut x: int;
- x <- y;
+ x = move y;
assert (x == 42);
}
)
macro_rules! move_it (
- { $x:expr } => { unsafe { let y <- *ptr::addr_of(&($x)); move y } }
+ { $x:expr } => { unsafe { let y = move *ptr::addr_of(&($x)); move y } }
)
fn switch<T: Send, U>(+endp: pipes::RecvPacket<T>,
fn main() {
let my_total = @@mut 10;
- { let pt <- shrinky_pointer(my_total); assert (pt.look_at() == 10); }
+ { let pt = move shrinky_pointer(my_total); assert (pt.look_at() == 10); }
log(error, fmt!("my_total = %d", **my_total));
assert (**my_total == 9);
}
let box = @mut 10;
fn dec_box(&&i: @mut int) { *i -= 1; }
- { let _i <- finish({val: box, fin: dec_box}); }
+ { let _i = move finish({val: box, fin: dec_box}); }
assert (*box == 9);
}
fn main() {
- let i <- ~100;
+ let i = move ~100;
assert *i == 100;
}
\ No newline at end of file
fn main() {
let i = ~100;
- let j <- i;
+ let j = move i;
assert *j == 100;
}
\ No newline at end of file
fn main() {
let i = ~100;
let j = ~200;
- let j <- i;
+ let j = move i;
assert *j == 100;
}
\ No newline at end of file
fn main() {
let mut i;
- i <- ~100;
+ i = move ~100;
assert *i == 100;
}
\ No newline at end of file
fn main() {
let i = ~100;
let mut j;
- j <- i;
+ j = move i;
assert *j == 100;
}
\ No newline at end of file
fn id(x: bool) -> bool { x }
fn call_id() {
- let c <- fail;
+ let c = move fail;
id(c); //~ WARNING unreachable statement
}
fn id(x: bool) -> bool { x }
fn call_id() {
- let c <- fail;
+ let c = move fail;
id(c);
}
}
fn f(c: comm::Chan<bool>) {
- let _c <- complainer(c);
+ let _c = move complainer(c);
fail;
}
}
fn f() {
- let c <- complainer(@0);
+ let c = move complainer(@0);
fail;
}
fn notsure() {
let mut _x;
let mut _y = (_x = 0) == (_x = 0);
- let mut _z = (_x <- 0) < (_x = 0);
+ let mut _z = (_x = move 0) < (_x = 0);
let _a = (_x += 0) == (_x = 0);
let _b = (_y <-> _z) == (_y <-> _z);
}
break; }
}
-fn evil_lincoln() { let evil <- debug!("lincoln"); }
+fn evil_lincoln() { let evil = move debug!("lincoln"); }
fn main() {
strange();
let mut x: int;
while z < 50 {
z += 1;
- while false { x <- y; y = z; }
+ while false { x = move y; y = z; }
log(debug, y);
}
assert (y == 42 && z == 50);