diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-05-05 18:56:44 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-05-06 23:12:54 -0700 |
| commit | 090040bf4037a094e50b03d79e4baf5cd89c912b (patch) | |
| tree | 27fa91d623889d59260d3db167abdfa8c4288849 /src/test | |
| parent | 24f6f26e633e50b5b59f9d0f6cca0b1e49e215d9 (diff) | |
| download | rust-090040bf4037a094e50b03d79e4baf5cd89c912b.tar.gz rust-090040bf4037a094e50b03d79e4baf5cd89c912b.zip | |
librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, except
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
Diffstat (limited to 'src/test')
319 files changed, 929 insertions, 802 deletions
diff --git a/src/test/auxiliary/issue-2380.rs b/src/test/auxiliary/issue-2380.rs index a34ec980bda..c617c1b2d03 100644 --- a/src/test/auxiliary/issue-2380.rs +++ b/src/test/auxiliary/issue-2380.rs @@ -11,10 +11,11 @@ #![crate_id="a"] #![crate_type = "lib"] + pub trait i<T> { } -pub fn f<T>() -> ~i<T> { +pub fn f<T>() -> Box<i<T>> { impl<T> i<T> for () { } - ~() as ~i<T> + box() () as Box<i<T>> } diff --git a/src/test/auxiliary/issue13507.rs b/src/test/auxiliary/issue13507.rs index be066187be5..2b4df978cc8 100644 --- a/src/test/auxiliary/issue13507.rs +++ b/src/test/auxiliary/issue13507.rs @@ -59,7 +59,7 @@ pub mod testtypes { // Skipping ty_box // Tests ty_uniq (of u8) - pub type FooUniq = ~u8; + pub type FooUniq = Box<u8>; // As with ty_str, what type should be used for ty_vec? diff --git a/src/test/auxiliary/macro_crate_outlive_expansion_phase.rs b/src/test/auxiliary/macro_crate_outlive_expansion_phase.rs index 4e933be5092..a2c7e3533d8 100644 --- a/src/test/auxiliary/macro_crate_outlive_expansion_phase.rs +++ b/src/test/auxiliary/macro_crate_outlive_expansion_phase.rs @@ -29,7 +29,7 @@ impl Drop for Foo { #[macro_registrar] pub fn registrar(_: |Name, SyntaxExtension|) { - local_data_key!(foo: ~Any:Send); - local_data::set(foo, ~Foo { foo: 10 } as ~Any:Send); + local_data_key!(foo: Box<Any:Send>); + local_data::set(foo, box Foo { foo: 10 } as Box<Any:Send>); } diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs index 070bb6dfcb7..95f2a8c1ca1 100644 --- a/src/test/auxiliary/macro_crate_test.rs +++ b/src/test/auxiliary/macro_crate_test.rs @@ -27,7 +27,7 @@ macro_rules! unexported_macro (() => (3)) #[macro_registrar] pub fn macro_registrar(register: |Name, SyntaxExtension|) { register(token::intern("make_a_1"), - NormalTT(~BasicMacroExpander { + NormalTT(box BasicMacroExpander { expander: expand_make_a_1, span: None, }, @@ -35,7 +35,8 @@ pub fn macro_registrar(register: |Name, SyntaxExtension|) { register(token::intern("into_foo"), ItemModifier(expand_into_foo)); } -fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> ~MacResult { +fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) + -> Box<MacResult> { if !tts.is_empty() { cx.span_fatal(sp, "make_a_1 takes no arguments"); } diff --git a/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs b/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs index 8156e7f0e34..93b56a7600d 100644 --- a/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs +++ b/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs @@ -25,14 +25,15 @@ use syntax::parse::token; #[macro_registrar] pub fn macro_registrar(register: |Name, SyntaxExtension|) { register(token::intern("foo"), - NormalTT(~BasicMacroExpander { + NormalTT(box BasicMacroExpander { expander: expand_foo, span: None, }, None)); } -fn expand_foo(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> ~MacResult { +fn expand_foo(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) + -> Box<MacResult> { let answer = other::the_answer(); MacExpr::new(quote_expr!(cx, $answer)) } diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index dd6e504f1de..659270b5554 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -147,9 +147,9 @@ fn main() { let rdr = if os::getenv("RUST_BENCH").is_some() { let foo = include_bin!("shootout-k-nucleotide.data"); - ~MemReader::new(Vec::from_slice(foo)) as ~Reader + box MemReader::new(Vec::from_slice(foo)) as Box<Reader> } else { - ~stdio::stdin() as ~Reader + box stdio::stdin() as Box<Reader> }; let mut rdr = BufferedReader::new(rdr); diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 865b3a03726..dfa287459f3 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -91,16 +91,16 @@ impl TableCallback for PrintCallback { struct Entry { code: Code, count: uint, - next: Option<~Entry>, + next: Option<Box<Entry>>, } struct Table { count: uint, - items: Vec<Option<~Entry>> } + items: Vec<Option<Box<Entry>>> } struct Items<'a> { cur: Option<&'a Entry>, - items: slice::Items<'a, Option<~Entry>>, + items: slice::Items<'a, Option<Box<Entry>>>, } impl Table { @@ -114,7 +114,7 @@ impl Table { fn search_remainder<C:TableCallback>(item: &mut Entry, key: Code, c: C) { match item.next { None => { - let mut entry = ~Entry { + let mut entry = box Entry { code: key, count: 0, next: None, @@ -138,7 +138,7 @@ impl Table { { if self.items.get(index as uint).is_none() { - let mut entry = ~Entry { + let mut entry = box Entry { code: key, count: 0, next: None, diff --git a/src/test/bench/shootout-regex-dna.rs b/src/test/bench/shootout-regex-dna.rs index 0f86b8043a0..f5409688bc6 100644 --- a/src/test/bench/shootout-regex-dna.rs +++ b/src/test/bench/shootout-regex-dna.rs @@ -34,9 +34,9 @@ fn count_matches(seq: &str, variant: &Regex) -> int { fn main() { let mut rdr = if std::os::getenv("RUST_BENCH").is_some() { let fd = io::File::open(&Path::new("shootout-k-nucleotide.data")); - ~io::BufferedReader::new(fd) as ~io::Reader + box io::BufferedReader::new(fd) as Box<io::Reader> } else { - ~io::stdin() as ~io::Reader + box io::stdin() as Box<io::Reader> }; let mut seq = StrBuf::from_str(rdr.read_to_str().unwrap()); let ilen = seq.len(); diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 3398cd84acd..bd47734c3da 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -15,8 +15,8 @@ use std::io; use std::io::stdio::StdReader; use std::io::BufferedReader; -use std::os; use std::num::Bitwise; +use std::os; // Computes a single solution to a given 9x9 sudoku // @@ -132,7 +132,7 @@ impl Sudoku { fn next_color(&mut self, row: u8, col: u8, start_color: u8) -> bool { if start_color < 10u8 { // colors not yet used - let mut avail = ~Colors::new(start_color); + let mut avail = box Colors::new(start_color); // drop colors already in use in neighbourhood self.drop_colors(avail, row, col); diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index 813a75cfb4d..fc47269ef87 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -24,7 +24,7 @@ enum List<T> { } enum UniqueList { - ULNil, ULCons(~UniqueList) + ULNil, ULCons(Box<UniqueList>) } fn main() { @@ -53,8 +53,8 @@ type nillist = List<()>; struct State { managed: @nillist, - unique: ~nillist, - tuple: (@nillist, ~nillist), + unique: Box<nillist>, + tuple: (@nillist, Box<nillist>), vec: Vec<@nillist>, res: r } @@ -85,8 +85,8 @@ fn recurse_or_fail(depth: int, st: Option<State>) { None => { State { managed: @Nil, - unique: ~Nil, - tuple: (@Nil, ~Nil), + unique: box Nil, + tuple: (@Nil, box Nil), vec: vec!(@Nil), res: r(@Nil) } @@ -94,9 +94,9 @@ fn recurse_or_fail(depth: int, st: Option<State>) { Some(st) => { State { managed: @Cons((), st.managed), - unique: ~Cons((), @*st.unique), + unique: box Cons((), @*st.unique), tuple: (@Cons((), st.tuple.ref0().clone()), - ~Cons((), @*st.tuple.ref1().clone())), + box Cons((), @*st.tuple.ref1().clone())), vec: st.vec.clone().append(&[@Cons((), *st.vec.last().unwrap())]), res: r(@Cons((), st.res._l)) } diff --git a/src/test/compile-fail/borrowck-bad-nested-calls-free.rs b/src/test/compile-fail/borrowck-bad-nested-calls-free.rs index c142876c5c2..fd96b750fc1 100644 --- a/src/test/compile-fail/borrowck-bad-nested-calls-free.rs +++ b/src/test/compile-fail/borrowck-bad-nested-calls-free.rs @@ -11,8 +11,9 @@ // Test that we detect nested calls that could free pointers evaluated // for earlier arguments. -fn rewrite(v: &mut ~uint) -> uint { - *v = ~22; + +fn rewrite(v: &mut Box<uint>) -> uint { + *v = box 22; **v } @@ -21,7 +22,7 @@ fn add(v: &uint, w: uint) -> uint { } fn implicit() { - let mut a = ~1; + let mut a = box 1; // Note the danger here: // @@ -34,7 +35,7 @@ fn implicit() { } fn explicit() { - let mut a = ~1; + let mut a = box 1; add( &*a, rewrite(&mut a)); //~ ERROR cannot borrow diff --git a/src/test/compile-fail/borrowck-bad-nested-calls-move.rs b/src/test/compile-fail/borrowck-bad-nested-calls-move.rs index 622d2e78ee7..d1ab70e4aed 100644 --- a/src/test/compile-fail/borrowck-bad-nested-calls-move.rs +++ b/src/test/compile-fail/borrowck-bad-nested-calls-move.rs @@ -11,17 +11,18 @@ // Test that we detect nested calls that could free pointers evaluated // for earlier arguments. -fn rewrite(v: &mut ~uint) -> uint { - *v = ~22; + +fn rewrite(v: &mut Box<uint>) -> uint { + *v = box 22; **v } -fn add(v: &uint, w: ~uint) -> uint { +fn add(v: &uint, w: Box<uint>) -> uint { *v + *w } fn implicit() { - let mut a = ~1; + let mut a = box 1; // Note the danger here: // @@ -34,7 +35,7 @@ fn implicit() { } fn explicit() { - let mut a = ~1; + let mut a = box 1; add( &*a, a); //~ ERROR cannot move diff --git a/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs b/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs index 1051c5829ec..c7695e0ff5f 100644 --- a/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs +++ b/src/test/compile-fail/borrowck-borrow-from-owned-ptr.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct Foo { bar1: Bar, bar2: Bar @@ -18,7 +19,7 @@ struct Bar { int2: int, } -fn make_foo() -> ~Foo { fail!() } +fn make_foo() -> Box<Foo> { fail!() } fn borrow_same_field_twice_mut_mut() { let mut foo = make_foo(); diff --git a/src/test/compile-fail/borrowck-borrow-overloaded-auto-deref-mut.rs b/src/test/compile-fail/borrowck-borrow-overloaded-auto-deref-mut.rs index e43ac98aa98..1e04a3568c3 100644 --- a/src/test/compile-fail/borrowck-borrow-overloaded-auto-deref-mut.rs +++ b/src/test/compile-fail/borrowck-borrow-overloaded-auto-deref-mut.rs @@ -78,7 +78,7 @@ fn deref_extend_mut_field2<'a>(x: &'a mut Own<Point>) -> &'a mut int { } fn deref_extend_mut_field3<'a>(x: &'a mut Own<Point>) { - // Hmm, this is unfortunate, because with ~ it would work, + // Hmm, this is unfortunate, because with box it would work, // but it's presently the expected outcome. See `deref_extend_mut_field4` // for the workaround. diff --git a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs index 20411723715..120223bbf60 100644 --- a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs +++ b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs @@ -15,9 +15,9 @@ use collections::HashMap; fn main() { let mut buggy_map: HashMap<uint, &uint> = HashMap::new(); - buggy_map.insert(42, &*~1); //~ ERROR borrowed value does not live long enough + buggy_map.insert(42, &*box 1); //~ ERROR borrowed value does not live long enough // but it is ok if we use a temporary - let tmp = ~2; + let tmp = box 2; buggy_map.insert(43, &*tmp); } diff --git a/src/test/compile-fail/borrowck-closures-mut-and-imm.rs b/src/test/compile-fail/borrowck-closures-mut-and-imm.rs index 006f475b29d..ce8b17ea40b 100644 --- a/src/test/compile-fail/borrowck-closures-mut-and-imm.rs +++ b/src/test/compile-fail/borrowck-closures-mut-and-imm.rs @@ -11,6 +11,7 @@ // Tests that two closures cannot simultaneously have mutable // and immutable access to the variable. Issue #6801. + fn get(x: &int) -> int { *x } @@ -50,27 +51,27 @@ fn e() { } fn f() { - let mut x = ~3; + let mut x = box 3; let c1 = || get(&*x); *x = 5; //~ ERROR cannot assign } fn g() { struct Foo { - f: ~int + f: Box<int> } - let mut x = ~Foo { f: ~3 }; + let mut x = box Foo { f: box 3 }; let c1 = || get(&*x.f); *x.f = 5; //~ ERROR cannot assign to `*x.f` } fn h() { struct Foo { - f: ~int + f: Box<int> } - let mut x = ~Foo { f: ~3 }; + let mut x = box Foo { f: box 3 }; let c1 = || get(&*x.f); let c2 = || *x.f = 5; //~ ERROR cannot borrow `x` as mutable } diff --git a/src/test/compile-fail/borrowck-closures-two-mut.rs b/src/test/compile-fail/borrowck-closures-two-mut.rs index 570249aed44..e1967d4e6df 100644 --- a/src/test/compile-fail/borrowck-closures-two-mut.rs +++ b/src/test/compile-fail/borrowck-closures-two-mut.rs @@ -12,6 +12,7 @@ // access to the variable, whether that mutable access be used // for direct assignment or for taking mutable ref. Issue #6801. + fn a() { let mut x = 3; let c1 = || x = 4; @@ -43,10 +44,10 @@ fn d() { fn g() { struct Foo { - f: ~int + f: Box<int> } - let mut x = ~Foo { f: ~3 }; + let mut x = box Foo { f: box 3 }; let c1 = || set(&mut *x.f); let c2 = || set(&mut *x.f); //~^ ERROR cannot borrow `x` as mutable more than once diff --git a/src/test/compile-fail/borrowck-closures-use-after-free.rs b/src/test/compile-fail/borrowck-closures-use-after-free.rs index 38c13b1fce9..ec31160f0d5 100644 --- a/src/test/compile-fail/borrowck-closures-use-after-free.rs +++ b/src/test/compile-fail/borrowck-closures-use-after-free.rs @@ -12,6 +12,7 @@ // cannot also be supplied a borrowed version of that // variable's contents. Issue #11192. + struct Foo { x: int } @@ -23,9 +24,9 @@ impl Drop for Foo { } fn main() { - let mut ptr = ~Foo { x: 0 }; + let mut ptr = box Foo { x: 0 }; let test = |foo: &Foo| { - ptr = ~Foo { x: ptr.x + 1 }; + ptr = box Foo { x: ptr.x + 1 }; }; test(ptr); //~ ERROR cannot borrow `*ptr` } diff --git a/src/test/compile-fail/borrowck-issue-2657-1.rs b/src/test/compile-fail/borrowck-issue-2657-1.rs index 8bcd5f9a72e..9313473d6c9 100644 --- a/src/test/compile-fail/borrowck-issue-2657-1.rs +++ b/src/test/compile-fail/borrowck-issue-2657-1.rs @@ -9,7 +9,7 @@ // except according to those terms. fn main() { -let x = Some(~1); +let x = Some(box 1); match x { Some(ref _y) => { let _a = x; //~ ERROR cannot move diff --git a/src/test/compile-fail/borrowck-issue-2657-2.rs b/src/test/compile-fail/borrowck-issue-2657-2.rs index fac805c57ca..39c3ae8fdfd 100644 --- a/src/test/compile-fail/borrowck-issue-2657-2.rs +++ b/src/test/compile-fail/borrowck-issue-2657-2.rs @@ -9,7 +9,7 @@ // except according to those terms. fn main() { -let x = Some(~1); +let x = Some(box 1); match x { Some(ref y) => { let _b = *y; //~ ERROR cannot move out diff --git a/src/test/compile-fail/borrowck-lend-flow-if.rs b/src/test/compile-fail/borrowck-lend-flow-if.rs index 80b8770397f..b1ba057dc14 100644 --- a/src/test/compile-fail/borrowck-lend-flow-if.rs +++ b/src/test/compile-fail/borrowck-lend-flow-if.rs @@ -14,21 +14,22 @@ // either genuine or would require more advanced changes. The latter // cases are noted. + fn borrow(_v: &int) {} fn borrow_mut(_v: &mut int) {} fn cond() -> bool { fail!() } fn for_func(_f: || -> bool) { fail!() } fn produce<T>() -> T { fail!(); } -fn inc(v: &mut ~int) { - *v = ~(**v + 1); +fn inc(v: &mut Box<int>) { + *v = box() (**v + 1); } fn pre_freeze_cond() { // In this instance, the freeze is conditional and starts before // the mut borrow. - let mut v = ~3; + let mut v = box 3; let _w; if cond() { _w = &v; @@ -40,7 +41,7 @@ fn pre_freeze_else() { // In this instance, the freeze and mut borrow are on separate sides // of the if. - let mut v = ~3; + let mut v = box 3; let _w; if cond() { _w = &v; diff --git a/src/test/compile-fail/borrowck-lend-flow-loop.rs b/src/test/compile-fail/borrowck-lend-flow-loop.rs index 4f0c71457b2..831c4d3e824 100644 --- a/src/test/compile-fail/borrowck-lend-flow-loop.rs +++ b/src/test/compile-fail/borrowck-lend-flow-loop.rs @@ -14,19 +14,20 @@ // either genuine or would require more advanced changes. The latter // cases are noted. + fn borrow(_v: &int) {} fn borrow_mut(_v: &mut int) {} fn cond() -> bool { fail!() } fn produce<T>() -> T { fail!(); } -fn inc(v: &mut ~int) { - *v = ~(**v + 1); +fn inc(v: &mut Box<int>) { + *v = box() (**v + 1); } fn loop_overarching_alias_mut() { // In this instance, the borrow encompasses the entire loop. - let mut v = ~3; + let mut v = box 3; let mut x = &mut v; **x += 1; loop { @@ -37,19 +38,19 @@ fn loop_overarching_alias_mut() { fn block_overarching_alias_mut() { // In this instance, the borrow encompasses the entire closure call. - let mut v = ~3; + let mut v = box 3; let mut x = &mut v; for _ in range(0, 3) { borrow(v); //~ ERROR cannot borrow } - *x = ~5; + *x = box 5; } fn loop_aliased_mut() { // In this instance, the borrow is carried through the loop. - let mut v = ~3; - let mut w = ~4; + let mut v = box 3; + let mut w = box 4; let mut _x = &w; loop { borrow_mut(v); //~ ERROR cannot borrow @@ -60,8 +61,8 @@ fn loop_aliased_mut() { fn while_aliased_mut() { // In this instance, the borrow is carried through the loop. - let mut v = ~3; - let mut w = ~4; + let mut v = box 3; + let mut w = box 4; let mut _x = &w; while cond() { borrow_mut(v); //~ ERROR cannot borrow @@ -73,8 +74,8 @@ fn while_aliased_mut() { fn loop_aliased_mut_break() { // In this instance, the borrow is carried through the loop. - let mut v = ~3; - let mut w = ~4; + let mut v = box 3; + let mut w = box 4; let mut _x = &w; loop { borrow_mut(v); @@ -87,8 +88,8 @@ fn loop_aliased_mut_break() { fn while_aliased_mut_break() { // In this instance, the borrow is carried through the loop. - let mut v = ~3; - let mut w = ~4; + let mut v = box 3; + let mut w = box 4; let mut _x = &w; while cond() { borrow_mut(v); @@ -99,8 +100,8 @@ fn while_aliased_mut_break() { } fn while_aliased_mut_cond(cond: bool, cond2: bool) { - let mut v = ~3; - let mut w = ~4; + let mut v = box 3; + let mut w = box 4; let mut x = &mut w; while cond { **x += 1; diff --git a/src/test/compile-fail/borrowck-lend-flow-match.rs b/src/test/compile-fail/borrowck-lend-flow-match.rs index 9d234e0aaa6..ea0f5d34b72 100644 --- a/src/test/compile-fail/borrowck-lend-flow-match.rs +++ b/src/test/compile-fail/borrowck-lend-flow-match.rs @@ -37,24 +37,24 @@ fn guard() { // Here the guard performs a borrow. This borrow "infects" all // subsequent arms (but not the prior ones). - let mut a = ~3; - let mut b = ~4; + let mut a = box 3; + let mut b = box 4; let mut w = &*a; match 22 { _ if cond() => { - b = ~5; + b = box 5; } _ if link(&*b, &mut w) => { - b = ~6; //~ ERROR cannot assign + b = box 6; //~ ERROR cannot assign } _ => { - b = ~7; //~ ERROR cannot assign + b = box 7; //~ ERROR cannot assign } } - b = ~8; //~ ERROR cannot assign + b = box 8; //~ ERROR cannot assign } fn main() {} diff --git a/src/test/compile-fail/borrowck-lend-flow.rs b/src/test/compile-fail/borrowck-lend-flow.rs index 5e4e5bb1e73..54f326b479a 100644 --- a/src/test/compile-fail/borrowck-lend-flow.rs +++ b/src/test/compile-fail/borrowck-lend-flow.rs @@ -14,20 +14,21 @@ // either genuine or would require more advanced changes. The latter // cases are noted. + fn borrow(_v: &int) {} fn borrow_mut(_v: &mut int) {} fn cond() -> bool { fail!() } fn for_func(_f: || -> bool) { fail!() } fn produce<T>() -> T { fail!(); } -fn inc(v: &mut ~int) { - *v = ~(**v + 1); +fn inc(v: &mut Box<int>) { + *v = box() (**v + 1); } fn pre_freeze() { // In this instance, the freeze starts before the mut borrow. - let mut v = ~3; + let mut v = box 3; let _w = &v; borrow_mut(v); //~ ERROR cannot borrow } @@ -35,7 +36,7 @@ fn pre_freeze() { fn post_freeze() { // In this instance, the const alias starts after the borrow. - let mut v = ~3; + let mut v = box 3; borrow_mut(v); let _w = &v; } diff --git a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs index 0fa2ee5be17..d262bcee983 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs @@ -15,7 +15,7 @@ fn borrow(v: &int, f: |x: &int|) { } fn box_imm() { - let v = ~3; + let v = box 3; let _w = &v; task::spawn(proc() { println!("v={}", *v); @@ -24,7 +24,7 @@ fn box_imm() { } fn box_imm_explicit() { - let v = ~3; + let v = box 3; let _w = &v; task::spawn(proc() { println!("v={}", *v); diff --git a/src/test/compile-fail/borrowck-loan-blocks-move.rs b/src/test/compile-fail/borrowck-loan-blocks-move.rs index b9a79f4f3b1..3c284ede0c8 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-move.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-move.rs @@ -8,11 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn take(_v: ~int) { + +fn take(_v: Box<int>) { } fn box_imm() { - let v = ~3; + let v = box 3; let _w = &v; take(v); //~ ERROR cannot move out of `v` because it is borrowed } diff --git a/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs b/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs index 6a0d3ef82fb..c11a08b254f 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs @@ -13,10 +13,10 @@ fn borrow(v: &int, f: |x: &int|) { } fn box_imm() { - let mut v = ~3; + let mut v = box 3; borrow(v, |w| { //~ ERROR cannot borrow `v` as mutable - v = ~4; + v = box 4; assert_eq!(*v, 3); assert_eq!(*w, 4); }) diff --git a/src/test/compile-fail/borrowck-loan-in-overloaded-op.rs b/src/test/compile-fail/borrowck-loan-in-overloaded-op.rs index 962b7068546..4a6c20079c1 100644 --- a/src/test/compile-fail/borrowck-loan-in-overloaded-op.rs +++ b/src/test/compile-fail/borrowck-loan-in-overloaded-op.rs @@ -8,18 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct foo(~uint); + +struct foo(Box<uint>); impl Add<foo, foo> for foo { fn add(&self, f: &foo) -> foo { - let foo(~i) = *self; - let foo(~j) = *f; - foo(~(i + j)) + let foo(box i) = *self; + let foo(box j) = *f; + foo(box() (i + j)) } } fn main() { - let x = foo(~3); + let x = foo(box 3); let _y = x + {x}; // the `{x}` forces a move to occur //~^ ERROR cannot move out of `x` } diff --git a/src/test/compile-fail/borrowck-move-by-capture.rs b/src/test/compile-fail/borrowck-move-by-capture.rs index f3869e5c9fd..c52924ebdb7 100644 --- a/src/test/compile-fail/borrowck-move-by-capture.rs +++ b/src/test/compile-fail/borrowck-move-by-capture.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let bar = ~3; + let bar = box 3; let _g = || { let _h: proc() -> int = proc() *bar; //~ ERROR cannot move out of captured outer variable }; diff --git a/src/test/compile-fail/borrowck-move-error-with-note.rs b/src/test/compile-fail/borrowck-move-error-with-note.rs index 087e619f213..72101d86960 100644 --- a/src/test/compile-fail/borrowck-move-error-with-note.rs +++ b/src/test/compile-fail/borrowck-move-error-with-note.rs @@ -8,14 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + enum Foo { - Foo1(~u32, ~u32), - Foo2(~u32), + Foo1(Box<u32>, Box<u32>), + Foo2(Box<u32>), Foo3, } fn blah() { - let f = &Foo1(~1u32, ~2u32); + let f = &Foo1(box 1u32, box 2u32); match *f { //~ ERROR cannot move out of Foo1(num1, //~ NOTE attempting to move value to here num2) => (), //~ NOTE and here @@ -24,7 +25,10 @@ fn blah() { } } -struct S {f:~str, g:~str} +struct S { + f: ~str, + g: ~str +} impl Drop for S { fn drop(&mut self) { println!("{}", self.f); } } @@ -40,13 +44,13 @@ fn move_in_match() { // from issue-8064 struct A { - a: ~int + a: Box<int>, } fn free<T>(_: T) {} fn blah2() { - let a = &A { a: ~1 }; + let a = &A { a: box 1 }; match a.a { //~ ERROR cannot move out of n => { //~ NOTE attempting to move value to here free(n) diff --git a/src/test/compile-fail/borrowck-move-from-subpath-of-borrowed-path.rs b/src/test/compile-fail/borrowck-move-from-subpath-of-borrowed-path.rs index 6106644a263..35106487f34 100644 --- a/src/test/compile-fail/borrowck-move-from-subpath-of-borrowed-path.rs +++ b/src/test/compile-fail/borrowck-move-from-subpath-of-borrowed-path.rs @@ -12,7 +12,7 @@ // borrowed path. fn main() { - let a = ~~2; + let a = box box 2; let b = &a; let z = *a; //~ ERROR: cannot move out of `*a` because it is borrowed diff --git a/src/test/compile-fail/borrowck-move-from-unsafe-ptr.rs b/src/test/compile-fail/borrowck-move-from-unsafe-ptr.rs index 8f332646bbc..c507b636f15 100644 --- a/src/test/compile-fail/borrowck-move-from-unsafe-ptr.rs +++ b/src/test/compile-fail/borrowck-move-from-unsafe-ptr.rs @@ -8,7 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo(x: *~int) -> ~int { + +fn foo(x: *Box<int>) -> Box<int> { let y = *x; //~ ERROR dereference of unsafe pointer requires unsafe function or block return y; } diff --git a/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs b/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs index 53b5d866b81..b385305d74a 100644 --- a/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs +++ b/src/test/compile-fail/borrowck-move-moved-value-into-closure.rs @@ -13,7 +13,7 @@ fn call_f(f: proc() -> int) -> int { } fn main() { - let t = ~3; + let t = box 3; call_f(proc() { *t + 1 }); call_f(proc() { *t + 1 }); //~ ERROR capture of moved value diff --git a/src/test/compile-fail/borrowck-move-subcomponent.rs b/src/test/compile-fail/borrowck-move-subcomponent.rs index 6940c85e0e6..a29a171e935 100644 --- a/src/test/compile-fail/borrowck-move-subcomponent.rs +++ b/src/test/compile-fail/borrowck-move-subcomponent.rs @@ -11,19 +11,15 @@ // Tests that the borrow checker checks all components of a path when moving // out. -#![no_std] - -#[lang="sized"] -pub trait Sized {} struct S { - x : ~int + x : Box<int> } fn f<T>(_: T) {} fn main() { - let a : S = S { x : ~1 }; + let a : S = S { x : box 1 }; let pb = &a; let S { x: ax } = a; //~ ERROR cannot move out f(pb); diff --git a/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs b/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs index ed270de51e2..ad90839b4bc 100644 --- a/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs +++ b/src/test/compile-fail/borrowck-no-cycle-in-exchange-heap.rs @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct node_ { - a: ~cycle + a: Box<cycle> } enum cycle { @@ -17,7 +18,7 @@ enum cycle { empty } fn main() { - let mut x = ~node(node_ {a: ~empty}); + let mut x = box node(node_ {a: box empty}); // Create a cycle! match *x { node(ref mut y) => { diff --git a/src/test/compile-fail/borrowck-object-lifetime.rs b/src/test/compile-fail/borrowck-object-lifetime.rs index 92b77d8243e..9466a78588c 100644 --- a/src/test/compile-fail/borrowck-object-lifetime.rs +++ b/src/test/compile-fail/borrowck-object-lifetime.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait Foo { fn borrowed<'a>(&'a self) -> &'a (); } @@ -16,16 +17,16 @@ fn borrowed_receiver<'a>(x: &'a Foo) -> &'a () { x.borrowed() } -fn owned_receiver(x: ~Foo) -> &() { +fn owned_receiver(x: Box<Foo>) -> &() { x.borrowed() //~ ERROR `*x` does not live long enough } -fn mut_owned_receiver(mut x: ~Foo) { +fn mut_owned_receiver(mut x: Box<Foo>) { let _y = x.borrowed(); let _z = &mut x; //~ ERROR cannot borrow } -fn imm_owned_receiver(mut x: ~Foo) { +fn imm_owned_receiver(mut x: Box<Foo>) { let _y = x.borrowed(); let _z = &x; } diff --git a/src/test/compile-fail/borrowck-object-mutability.rs b/src/test/compile-fail/borrowck-object-mutability.rs index d4203dc9916..9b5087bd7e0 100644 --- a/src/test/compile-fail/borrowck-object-mutability.rs +++ b/src/test/compile-fail/borrowck-object-mutability.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait Foo { fn borrowed(&self); fn borrowed_mut(&mut self); @@ -23,12 +24,12 @@ fn borrowed_mut_receiver(x: &mut Foo) { x.borrowed_mut(); } -fn owned_receiver(x: ~Foo) { +fn owned_receiver(x: Box<Foo>) { x.borrowed(); x.borrowed_mut(); //~ ERROR cannot borrow } -fn mut_owned_receiver(mut x: ~Foo) { +fn mut_owned_receiver(mut x: Box<Foo>) { x.borrowed(); x.borrowed_mut(); } diff --git a/src/test/compile-fail/borrowck-preserve-box-in-field.rs b/src/test/compile-fail/borrowck-preserve-box-in-field.rs index ff138451e93..168a331e9fe 100644 --- a/src/test/compile-fail/borrowck-preserve-box-in-field.rs +++ b/src/test/compile-fail/borrowck-preserve-box-in-field.rs @@ -14,6 +14,7 @@ #![feature(managed_boxes)] + fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); @@ -21,16 +22,16 @@ fn borrow(x: &int, f: |x: &int|) { assert_eq!(before, after); } -struct F { f: ~int } +struct F { f: Box<int> } pub fn main() { - let mut x = @F {f: ~3}; + let mut x = @F {f: box 3}; borrow(x.f, |b_x| { //~^ ERROR cannot borrow `x` as mutable because `*x.f` is also borrowed as immutable assert_eq!(*b_x, 3); assert_eq!(&(*x.f) as *int, &(*b_x) as *int); //~^ NOTE borrow occurs due to use of `x` in closure - x = @F {f: ~4}; + x = @F {f: box 4}; println!("&*b_x = {:p}", &(*b_x)); assert_eq!(*b_x, 3); diff --git a/src/test/compile-fail/borrowck-preserve-box-in-uniq.rs b/src/test/compile-fail/borrowck-preserve-box-in-uniq.rs index b06eb0d6ba2..d79b7e040c7 100644 --- a/src/test/compile-fail/borrowck-preserve-box-in-uniq.rs +++ b/src/test/compile-fail/borrowck-preserve-box-in-uniq.rs @@ -14,6 +14,7 @@ #![feature(managed_boxes)] + fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); @@ -21,16 +22,16 @@ fn borrow(x: &int, f: |x: &int|) { assert_eq!(before, after); } -struct F { f: ~int } +struct F { f: Box<int> } pub fn main() { - let mut x = ~@F{f: ~3}; + let mut x = box @F{f: box 3}; borrow(x.f, |b_x| { //~^ ERROR cannot borrow `x` as mutable because `*x.f` is also borrowed as immutable assert_eq!(*b_x, 3); assert_eq!(&(*x.f) as *int, &(*b_x) as *int); //~^ NOTE borrow occurs due to use of `x` in closure - *x = @F{f: ~4}; + *x = @F{f: box 4}; println!("&*b_x = {:p}", &(*b_x)); assert_eq!(*b_x, 3); diff --git a/src/test/compile-fail/borrowck-preserve-expl-deref.rs b/src/test/compile-fail/borrowck-preserve-expl-deref.rs index aeabf6d9f8b..9b7966b0af0 100644 --- a/src/test/compile-fail/borrowck-preserve-expl-deref.rs +++ b/src/test/compile-fail/borrowck-preserve-expl-deref.rs @@ -14,6 +14,7 @@ #![feature(managed_boxes)] + fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); @@ -21,16 +22,16 @@ fn borrow(x: &int, f: |x: &int|) { assert_eq!(before, after); } -struct F { f: ~int } +struct F { f: Box<int> } pub fn main() { - let mut x = @F {f: ~3}; + let mut x = @F {f: box 3}; borrow((*x).f, |b_x| { //~^ ERROR cannot borrow `x` as mutable because `*x.f` is also borrowed as immutable assert_eq!(*b_x, 3); assert_eq!(&(*x.f) as *int, &(*b_x) as *int); //~^ NOTE borrow occurs due to use of `x` in closure - x = @F {f: ~4}; + x = @F {f: box 4}; println!("&*b_x = {:p}", &(*b_x)); assert_eq!(*b_x, 3); diff --git a/src/test/compile-fail/borrowck-struct-update-with-dtor.rs b/src/test/compile-fail/borrowck-struct-update-with-dtor.rs index 651104d1eda..b5d274a5584 100644 --- a/src/test/compile-fail/borrowck-struct-update-with-dtor.rs +++ b/src/test/compile-fail/borrowck-struct-update-with-dtor.rs @@ -13,10 +13,12 @@ // NoCopy use NP = std::kinds::marker::NoCopy; + + struct S { a: int, np: NP } impl Drop for S { fn drop(&mut self) { } } -struct T { a: int, mv: ~int } +struct T { a: int, mv: Box<int> } impl Drop for T { fn drop(&mut self) { } } fn f(s0:S) { diff --git a/src/test/compile-fail/borrowck-unary-move.rs b/src/test/compile-fail/borrowck-unary-move.rs index a67a12f9d0f..72941f77210 100644 --- a/src/test/compile-fail/borrowck-unary-move.rs +++ b/src/test/compile-fail/borrowck-unary-move.rs @@ -8,13 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo(x: ~int) -> int { + +fn foo(x: Box<int>) -> int { let y = &*x; free(x); //~ ERROR cannot move out of `x` because it is borrowed *y } -fn free(_x: ~int) { +fn free(_x: Box<int>) { } fn main() { diff --git a/src/test/compile-fail/borrowck-uniq-via-lend.rs b/src/test/compile-fail/borrowck-uniq-via-lend.rs index c87428cd300..fb03ad61f3d 100644 --- a/src/test/compile-fail/borrowck-uniq-via-lend.rs +++ b/src/test/compile-fail/borrowck-uniq-via-lend.rs @@ -8,49 +8,50 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + fn borrow(_v: &int) {} fn local() { - let mut v = ~3; + let mut v = box 3; borrow(v); } fn local_rec() { - struct F { f: ~int } - let mut v = F {f: ~3}; + struct F { f: Box<int> } + let mut v = F {f: box 3}; borrow(v.f); } fn local_recs() { struct F { f: G } struct G { g: H } - struct H { h: ~int } - let mut v = F {f: G {g: H {h: ~3}}}; + struct H { h: Box<int> } + let mut v = F {f: G {g: H {h: box 3}}}; borrow(v.f.g.h); } fn aliased_imm() { - let mut v = ~3; + let mut v = box 3; let _w = &v; borrow(v); } fn aliased_mut() { - let mut v = ~3; + let mut v = box 3; let _w = &mut v; borrow(v); //~ ERROR cannot borrow `*v` } fn aliased_other() { - let mut v = ~3; - let mut w = ~4; + let mut v = box 3; + let mut w = box 4; let _x = &mut w; borrow(v); } fn aliased_other_reassign() { - let mut v = ~3; - let mut w = ~4; + let mut v = box 3; + let mut w = box 4; let mut _x = &mut w; _x = &mut v; borrow(v); //~ ERROR cannot borrow `*v` diff --git a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs index 7f0a6c84f8c..f41f74b166f 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs @@ -8,28 +8,29 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + fn a() { - let mut vec = [~1, ~2, ~3]; + let mut vec = [box 1, box 2, box 3]; match vec { - [~ref _a, _, _] => { - vec[0] = ~4; //~ ERROR cannot assign + [box ref _a, _, _] => { + vec[0] = box 4; //~ ERROR cannot assign } } } fn b() { - let mut vec = vec!(~1, ~2, ~3); - let vec: &mut [~int] = vec.as_mut_slice(); + let mut vec = vec!(box 1, box 2, box 3); + let vec: &mut [Box<int>] = vec.as_mut_slice(); match vec { [.._b] => { - vec[0] = ~4; //~ ERROR cannot assign + vec[0] = box 4; //~ ERROR cannot assign } } } fn c() { - let mut vec = vec!(~1, ~2, ~3); - let vec: &mut [~int] = vec.as_mut_slice(); + let mut vec = vec!(box 1, box 2, box 3); + let vec: &mut [Box<int>] = vec.as_mut_slice(); match vec { [_a, //~ ERROR cannot move out .._b] => { //~^ NOTE attempting to move value to here @@ -46,8 +47,8 @@ fn c() { } fn d() { - let mut vec = vec!(~1, ~2, ~3); - let vec: &mut [~int] = vec.as_mut_slice(); + let mut vec = vec!(box 1, box 2, box 3); + let vec: &mut [Box<int>] = vec.as_mut_slice(); match vec { [.._a, //~ ERROR cannot move out _b] => {} //~ NOTE attempting to move value to here @@ -57,8 +58,8 @@ fn d() { } fn e() { - let mut vec = vec!(~1, ~2, ~3); - let vec: &mut [~int] = vec.as_mut_slice(); + let mut vec = vec!(box 1, box 2, box 3); + let vec: &mut [Box<int>] = vec.as_mut_slice(); match vec { [_a, _b, _c] => {} //~ ERROR cannot move out //~^ NOTE attempting to move value to here diff --git a/src/test/compile-fail/check-static-values-constraints.rs b/src/test/compile-fail/check-static-values-constraints.rs index a8581534848..6c1e759cc2f 100644 --- a/src/test/compile-fail/check-static-values-constraints.rs +++ b/src/test/compile-fail/check-static-values-constraints.rs @@ -94,7 +94,7 @@ static STATIC10: UnsafeStruct = UnsafeStruct; struct MyOwned; -static STATIC11: ~MyOwned = ~MyOwned; +static STATIC11: Box<MyOwned> = box MyOwned; //~^ ERROR static items are not allowed to have owned pointers // The following examples test that mutable structs are just forbidden @@ -109,11 +109,12 @@ static mut STATIC13: SafeStruct = SafeStruct{field1: Variant1, field2: Variant3( static mut STATIC14: SafeStruct = SafeStruct{field1: Variant1, field2: Variant4("str".to_owned())}; //~^ ERROR mutable static items are not allowed to have destructors -static STATIC15: &'static [~MyOwned] = &'static [~MyOwned, ~MyOwned]; +static STATIC15: &'static [Box<MyOwned>] = &'static [box MyOwned, box MyOwned]; //~^ ERROR static items are not allowed to have owned pointers //~^^ ERROR static items are not allowed to have owned pointers -static STATIC16: (&'static ~MyOwned, &'static ~MyOwned) = (&'static ~MyOwned, &'static ~MyOwned); +static STATIC16: (&'static Box<MyOwned>, &'static Box<MyOwned>) = + (&'static box MyOwned, &'static box MyOwned); //~^ ERROR static items are not allowed to have owned pointers //~^^ ERROR static items are not allowed to have owned pointers @@ -123,10 +124,10 @@ static mut STATIC17: SafeEnum = Variant1; static STATIC18: @SafeStruct = @SafeStruct{field1: Variant1, field2: Variant2(0)}; //~^ ERROR static items are not allowed to have managed pointers -static STATIC19: ~int = box 3; +static STATIC19: Box<int> = box 3; //~^ ERROR static items are not allowed to have owned pointers pub fn main() { - let y = { static x: ~int = ~3; x }; + let y = { static x: Box<int> = box 3; x }; //~^ ERROR static items are not allowed to have owned pointers } diff --git a/src/test/compile-fail/class-cast-to-trait.rs b/src/test/compile-fail/class-cast-to-trait.rs index 506e1cba9fd..c4344db027b 100644 --- a/src/test/compile-fail/class-cast-to-trait.rs +++ b/src/test/compile-fail/class-cast-to-trait.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait noisy { fn speak(&self); } @@ -57,6 +58,6 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { } fn main() { - let nyan: ~noisy = ~cat(0, 2, "nyan".to_owned()) as ~noisy; + let nyan: Box<noisy> = box cat(0, 2, "nyan".to_owned()) as Box<noisy>; nyan.eat(); //~ ERROR does not implement any method in scope named `eat` } diff --git a/src/test/compile-fail/estr-subtyping.rs b/src/test/compile-fail/estr-subtyping.rs index 5927ae12f1c..db86b5e092c 100644 --- a/src/test/compile-fail/estr-subtyping.rs +++ b/src/test/compile-fail/estr-subtyping.rs @@ -17,7 +17,7 @@ fn has_uniq(x: ~str) { } fn has_slice(x: &str) { - wants_uniq(x); //~ ERROR mismatched types: expected `~str` but found `&str` (expected ~-ptr but f + wants_uniq(x); //~ ERROR mismatched types: expected `~str` but found `&str` (expected box but f wants_slice(x); } diff --git a/src/test/compile-fail/immut-function-arguments.rs b/src/test/compile-fail/immut-function-arguments.rs index 663a50e9e55..71328acdd70 100644 --- a/src/test/compile-fail/immut-function-arguments.rs +++ b/src/test/compile-fail/immut-function-arguments.rs @@ -8,12 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(y: ~int) { + +fn f(y: Box<int>) { *y = 5; //~ ERROR cannot assign } fn g() { - let _frob: |~int| = |q| { *q = 2; }; //~ ERROR cannot assign + let _frob: |Box<int>| = |q| { *q = 2; }; //~ ERROR cannot assign } diff --git a/src/test/compile-fail/infinite-autoderef.rs b/src/test/compile-fail/infinite-autoderef.rs index ddef459453e..b41797d0042 100644 --- a/src/test/compile-fail/infinite-autoderef.rs +++ b/src/test/compile-fail/infinite-autoderef.rs @@ -23,7 +23,7 @@ impl Deref<Foo> for Foo { pub fn main() { let mut x; loop { - x = ~x; + x = box x; x.foo; x.bar(); } diff --git a/src/test/compile-fail/inherit-struct1.rs b/src/test/compile-fail/inherit-struct1.rs index 00ea4b7783b..47f2b291187 100644 --- a/src/test/compile-fail/inherit-struct1.rs +++ b/src/test/compile-fail/inherit-struct1.rs @@ -11,7 +11,8 @@ // Test struct inheritance. #![feature(struct_inherit)] -struct S6 : ~S2; //~ ERROR not a struct + +struct S6 : int; //~ ERROR super-struct could not be resolved pub fn main() { } diff --git a/src/test/compile-fail/issue-10398.rs b/src/test/compile-fail/issue-10398.rs index a58c88737b6..97642377ba8 100644 --- a/src/test/compile-fail/issue-10398.rs +++ b/src/test/compile-fail/issue-10398.rs @@ -9,7 +9,7 @@ // except according to those terms. fn main() { - let x = ~1; + let x = box 1; let f: proc() = proc() { let _a = x; drop(x); diff --git a/src/test/compile-fail/issue-11192.rs b/src/test/compile-fail/issue-11192.rs index f1da3032890..e7fa8300bcb 100644 --- a/src/test/compile-fail/issue-11192.rs +++ b/src/test/compile-fail/issue-11192.rs @@ -19,10 +19,10 @@ impl Drop for Foo { } fn main() { - let mut ptr = ~Foo { x: 0 }; + let mut ptr = box Foo { x: 0 }; let test = |foo: &Foo| { println!("access {}", foo.x); - ptr = ~Foo { x: ptr.x + 1 }; + ptr = box Foo { x: ptr.x + 1 }; println!("access {}", foo.x); }; test(ptr); diff --git a/src/test/compile-fail/issue-11515.rs b/src/test/compile-fail/issue-11515.rs index 52288a9ce02..4d520b570b7 100644 --- a/src/test/compile-fail/issue-11515.rs +++ b/src/test/compile-fail/issue-11515.rs @@ -13,6 +13,6 @@ struct Test<'s> { } fn main() { - let test = ~Test { func: proc() {} }; + let test = box Test { func: proc() {} }; //~^ ERROR: expected `||` but found `proc()` } diff --git a/src/test/compile-fail/issue-11925.rs b/src/test/compile-fail/issue-11925.rs index 0b8eaa5b831..a8d2c7509ce 100644 --- a/src/test/compile-fail/issue-11925.rs +++ b/src/test/compile-fail/issue-11925.rs @@ -10,7 +10,7 @@ fn main() { let r = { - let x = ~42; + let x = box 42; let f = proc() &x; //~ ERROR: `x` does not live long enough f() }; diff --git a/src/test/compile-fail/issue-2063.rs b/src/test/compile-fail/issue-2063.rs index b6425dac3c1..4a6219aafd0 100644 --- a/src/test/compile-fail/issue-2063.rs +++ b/src/test/compile-fail/issue-2063.rs @@ -11,7 +11,9 @@ // test that autoderef of a type like this does not // cause compiler to loop. Note that no instances // of such a type could ever be constructed. -struct t(~t); //~ ERROR this type cannot be instantiated + + +struct t(Box<t>); //~ ERROR this type cannot be instantiated trait to_str_2 { fn my_to_str() -> ~str; diff --git a/src/test/compile-fail/issue-3601.rs b/src/test/compile-fail/issue-3601.rs index c37c5a3e5af..6ca4e22576e 100644 --- a/src/test/compile-fail/issue-3601.rs +++ b/src/test/compile-fail/issue-3601.rs @@ -8,12 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct HTMLImageData { image: Option<~str> } struct ElementData { - kind: ~ElementKind + kind: Box<ElementKind> } enum ElementKind { @@ -25,17 +26,17 @@ enum NodeKind { } struct NodeData { - kind: ~NodeKind + kind: Box<NodeKind>, } fn main() { let mut id = HTMLImageData { image: None }; - let ed = ElementData { kind: ~HTMLImageElement(id) }; - let n = NodeData {kind : ~Element(ed)}; + let ed = ElementData { kind: box HTMLImageElement(id) }; + let n = NodeData {kind : box Element(ed)}; // n.b. span could be better match n.kind { - ~Element(ed) => match ed.kind { //~ ERROR non-exhaustive patterns - ~HTMLImageElement(ref d) if d.image.is_some() => { true } + box Element(ed) => match ed.kind { //~ ERROR non-exhaustive patterns + box HTMLImageElement(ref d) if d.image.is_some() => { true } }, _ => fail!("WAT") //~ ERROR unreachable pattern }; diff --git a/src/test/compile-fail/issue-3763.rs b/src/test/compile-fail/issue-3763.rs index 8eed8aa8644..657d9c8f17e 100644 --- a/src/test/compile-fail/issue-3763.rs +++ b/src/test/compile-fail/issue-3763.rs @@ -26,12 +26,12 @@ fn main() { let my_struct = my_mod::MyStruct(); let _woohoo = (&my_struct).priv_field; //~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private - let _woohoo = (~my_struct).priv_field; + let _woohoo = (box my_struct).priv_field; //~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private let _woohoo = (@my_struct).priv_field; //~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private (&my_struct).happyfun(); //~ ERROR method `happyfun` is private - (~my_struct).happyfun(); //~ ERROR method `happyfun` is private + (box my_struct).happyfun(); //~ ERROR method `happyfun` is private (@my_struct).happyfun(); //~ ERROR method `happyfun` is private let nope = my_struct.priv_field; //~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private diff --git a/src/test/compile-fail/issue-4972.rs b/src/test/compile-fail/issue-4972.rs index 8d281a0b174..ffac6b499f4 100644 --- a/src/test/compile-fail/issue-4972.rs +++ b/src/test/compile-fail/issue-4972.rs @@ -8,15 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait MyTrait { } pub enum TraitWrapper { - A(~MyTrait), + A(Box<MyTrait>), } fn get_tw_map<'lt>(tw: &'lt TraitWrapper) -> &'lt MyTrait { match *tw { - A(~ref map) => map, //~ ERROR found a `~`-box pattern + A(box ref map) => map, //~ ERROR found a box pattern } } diff --git a/src/test/compile-fail/issue-5100.rs b/src/test/compile-fail/issue-5100.rs index b7c440d30b3..6734a546be5 100644 --- a/src/test/compile-fail/issue-5100.rs +++ b/src/test/compile-fail/issue-5100.rs @@ -23,8 +23,8 @@ fn main() { } match (true, false) { - ~(true, false) => () - //~^ ERROR mismatched types: expected `(bool,bool)` but found a `~`-box pattern + box (true, false) => () + //~^ ERROR mismatched types: expected `(bool,bool)` but found a box pattern } match (true, false) { diff --git a/src/test/compile-fail/issue-5439.rs b/src/test/compile-fail/issue-5439.rs index 03fe86cb879..55e3459a589 100644 --- a/src/test/compile-fail/issue-5439.rs +++ b/src/test/compile-fail/issue-5439.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct Foo { foo: int, } @@ -17,8 +18,8 @@ struct Bar { } impl Bar { - fn make_foo (&self, i: int) -> ~Foo { - return ~Foo { nonexistent: self, foo: i }; //~ ERROR: no field named + fn make_foo (&self, i: int) -> Box<Foo> { + return box Foo { nonexistent: self, foo: i }; //~ ERROR: no field named } } diff --git a/src/test/compile-fail/issue-6801.rs b/src/test/compile-fail/issue-6801.rs index a80d4b72192..5925f686939 100644 --- a/src/test/compile-fail/issue-6801.rs +++ b/src/test/compile-fail/issue-6801.rs @@ -12,7 +12,8 @@ // transferring ownership of the owned box before invoking the stack // closure results in a crash. -fn twice(x: ~uint) -> uint { + +fn twice(x: Box<uint>) -> uint { *x * 2 } @@ -21,7 +22,7 @@ fn invoke(f: || -> uint) { } fn main() { - let x : ~uint = ~9; + let x : Box<uint> = box 9; let sq : || -> uint = || { *x * *x }; twice(x); //~ ERROR: cannot move out of diff --git a/src/test/compile-fail/issue-7013.rs b/src/test/compile-fail/issue-7013.rs index 6a7f01e6767..1bc4e076553 100644 --- a/src/test/compile-fail/issue-7013.rs +++ b/src/test/compile-fail/issue-7013.rs @@ -8,35 +8,30 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::rc::Rc; use std::cell::RefCell; +use std::rc::Rc; -trait Foo -{ +trait Foo { fn set(&mut self, v: Rc<RefCell<A>>); } -struct B -{ +struct B { v: Option<Rc<RefCell<A>>> } -impl Foo for B -{ +impl Foo for B { fn set(&mut self, v: Rc<RefCell<A>>) { self.v = Some(v); } } -struct A -{ - v: ~Foo:Send, +struct A { + v: Box<Foo:Send>, } -fn main() -{ - let a = A {v: ~B{v: None} as ~Foo:Send}; +fn main() { + let a = A {v: box B{v: None} as Box<Foo:Send>}; //~^ ERROR cannot pack type `~B`, which does not fulfill `Send` let v = Rc::new(RefCell::new(a)); let w = v.clone(); diff --git a/src/test/compile-fail/issue-8727.rs b/src/test/compile-fail/issue-8727.rs index 9d7edefbf02..e2790eb7b39 100644 --- a/src/test/compile-fail/issue-8727.rs +++ b/src/test/compile-fail/issue-8727.rs @@ -11,7 +11,8 @@ // Verify the compiler fails with an error on infinite function // recursions. -struct Data(~Option<Data>); + +struct Data(Box<Option<Data>>); fn generic<T>( _ : Vec<(Data,T)> ) { //~^ ERROR reached the recursion limit during monomorphization diff --git a/src/test/compile-fail/kindck-copy.rs b/src/test/compile-fail/kindck-copy.rs index d4010346998..694b0f1dbe2 100644 --- a/src/test/compile-fail/kindck-copy.rs +++ b/src/test/compile-fail/kindck-copy.rs @@ -23,7 +23,7 @@ struct MyStruct { } struct MyNoncopyStruct { - x: ~int, + x: Box<int>, } fn test<'a,T,U:Copy>(_: &'a int) { @@ -38,10 +38,10 @@ fn test<'a,T,U:Copy>(_: &'a int) { assert_copy::<&'a mut int>(); //~ ERROR does not fulfill // ~ pointers are not ok - assert_copy::<~int>(); //~ ERROR does not fulfill + assert_copy::<Box<int>>(); //~ ERROR does not fulfill assert_copy::<~str>(); //~ ERROR does not fulfill assert_copy::<Vec<int> >(); //~ ERROR does not fulfill - assert_copy::<~&'a mut int>(); //~ ERROR does not fulfill + assert_copy::<Box<&'a mut int>>(); //~ ERROR does not fulfill // borrowed object types are generally ok assert_copy::<&'a Dummy>(); @@ -49,8 +49,8 @@ fn test<'a,T,U:Copy>(_: &'a int) { assert_copy::<&'static Dummy:Copy>(); // owned object types are not ok - assert_copy::<~Dummy>(); //~ ERROR does not fulfill - assert_copy::<~Dummy:Copy>(); //~ ERROR does not fulfill + assert_copy::<Box<Dummy>>(); //~ ERROR does not fulfill + assert_copy::<Box<Dummy:Copy>>(); //~ ERROR does not fulfill // mutable object types are not ok assert_copy::<&'a mut Dummy:Copy>(); //~ ERROR does not fulfill diff --git a/src/test/compile-fail/kindck-owned-trait-contains.rs b/src/test/compile-fail/kindck-owned-trait-contains.rs index e2005cbae91..3f6c622dd0d 100644 --- a/src/test/compile-fail/kindck-owned-trait-contains.rs +++ b/src/test/compile-fail/kindck-owned-trait-contains.rs @@ -8,14 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait Repeat<A> { fn get(&self) -> A; } impl<A:Clone> Repeat<A> for A { fn get(&self) -> A { self.clone() } } -fn repeater<A:Clone>(v: A) -> ~Repeat<A>: { - ~v as ~Repeat<A>: // No +fn repeater<A:Clone>(v: A) -> Box<Repeat<A>:> { + box v as Box<Repeat<A>:> // No } fn main() { diff --git a/src/test/compile-fail/kindck-send.rs b/src/test/compile-fail/kindck-send.rs index cdf24257ce7..518e97515e7 100644 --- a/src/test/compile-fail/kindck-send.rs +++ b/src/test/compile-fail/kindck-send.rs @@ -28,28 +28,28 @@ fn test<'a,T,U:Send>(_: &'a int) { assert_send::<&'a str>(); //~ ERROR does not fulfill `Send` assert_send::<&'a [int]>(); //~ ERROR does not fulfill `Send` - // ~ pointers are ok - assert_send::<~int>(); + // boxes are ok + assert_send::<Box<int>>(); assert_send::<~str>(); assert_send::<Vec<int> >(); // but not if they own a bad thing - assert_send::<~&'a int>(); //~ ERROR does not fulfill `Send` + assert_send::<Box<&'a int>>(); //~ ERROR does not fulfill `Send` // careful with object types, who knows what they close over... assert_send::<&'static Dummy>(); //~ ERROR does not fulfill `Send` assert_send::<&'a Dummy>(); //~ ERROR does not fulfill `Send` assert_send::<&'a Dummy:Send>(); //~ ERROR does not fulfill `Send` - assert_send::<~Dummy:>(); //~ ERROR does not fulfill `Send` + assert_send::<Box<Dummy:>>(); //~ ERROR does not fulfill `Send` // ...unless they are properly bounded assert_send::<&'static Dummy:Send>(); - assert_send::<~Dummy:Send>(); + assert_send::<Box<Dummy:Send>>(); // but closure and object types can have lifetime bounds which make // them not ok (FIXME #5121) // assert_send::<proc:'a()>(); // ERROR does not fulfill `Send` - // assert_send::<~Dummy:'a>(); // ERROR does not fulfill `Send` + // assert_send::<Box<Dummy:'a>>(); // ERROR does not fulfill `Send` // unsafe ptrs are ok unless they point at unsendable things assert_send::<*int>(); diff --git a/src/test/compile-fail/lint-allocation.rs b/src/test/compile-fail/lint-allocation.rs index 46199fa0280..c898107f5e3 100644 --- a/src/test/compile-fail/lint-allocation.rs +++ b/src/test/compile-fail/lint-allocation.rs @@ -14,6 +14,6 @@ fn f(_: &int) {} fn g(_: &mut int) {} fn main() { - f(~1); //~ ERROR unnecessary allocation, use & instead - g(~1); //~ ERROR unnecessary allocation, use &mut instead + f(box 1); //~ ERROR unnecessary allocation, use & instead + g(box 1); //~ ERROR unnecessary allocation, use &mut instead } diff --git a/src/test/compile-fail/lint-dead-code-1.rs b/src/test/compile-fail/lint-dead-code-1.rs index bbcc59f0d6c..10734f1f243 100644 --- a/src/test/compile-fail/lint-dead-code-1.rs +++ b/src/test/compile-fail/lint-dead-code-1.rs @@ -36,7 +36,7 @@ pub static used_static2: int = used_static; static USED_STATIC: int = 0; static STATIC_USED_IN_ENUM_DISCRIMINANT: uint = 10; -pub type typ = ~UsedStruct4; +pub type typ = *UsedStruct4; pub struct PubStruct(); struct PrivStruct; //~ ERROR: code is never used struct UsedStruct1 { x: int } @@ -57,7 +57,7 @@ pub struct PubStruct2 { } pub enum pub_enum { foo1, bar1 } -pub enum pub_enum2 { a(~StructUsedInEnum) } +pub enum pub_enum2 { a(*StructUsedInEnum) } pub enum pub_enum3 { Foo = STATIC_USED_IN_ENUM_DISCRIMINANT } enum priv_enum { foo2, bar2 } //~ ERROR: code is never used enum used_enum { foo3, bar3 } diff --git a/src/test/compile-fail/lint-heap-memory.rs b/src/test/compile-fail/lint-heap-memory.rs index 5f2987c6cfb..eaa1819bd53 100644 --- a/src/test/compile-fail/lint-heap-memory.rs +++ b/src/test/compile-fail/lint-heap-memory.rs @@ -13,19 +13,20 @@ #![allow(dead_code)] #![allow(deprecated_owned_vector)] + struct Foo { x: @int //~ ERROR type uses managed } -struct Bar { x: ~int } //~ ERROR type uses owned +struct Bar { x: Box<int> } //~ ERROR type uses owned fn main() { - let _x : Bar = Bar {x : ~10}; //~ ERROR type uses owned + let _x : Bar = Bar {x : box 10}; //~ ERROR type uses owned @2; //~ ERROR type uses managed - ~2; //~ ERROR type uses owned - fn g(_: ~Clone) {} //~ ERROR type uses owned + box 2; //~ ERROR type uses owned + fn g(_: Box<Clone>) {} //~ ERROR type uses owned "".to_owned(); //~ ERROR type uses owned proc() {}; //~ ERROR type uses owned } diff --git a/src/test/compile-fail/lint-owned-heap-memory.rs b/src/test/compile-fail/lint-owned-heap-memory.rs index 859dd127b97..c9688ad49d7 100644 --- a/src/test/compile-fail/lint-owned-heap-memory.rs +++ b/src/test/compile-fail/lint-owned-heap-memory.rs @@ -10,11 +10,12 @@ #![forbid(owned_heap_memory)] + struct Foo { - x: ~int //~ ERROR type uses owned + x: Box<int> //~ ERROR type uses owned } fn main() { - let _x : Foo = Foo {x : ~10}; + let _x : Foo = Foo {x : box 10}; //~^ ERROR type uses owned } diff --git a/src/test/compile-fail/liveness-move-call-arg.rs b/src/test/compile-fail/liveness-move-call-arg.rs index ae1c086b340..b9ad1c0fb65 100644 --- a/src/test/compile-fail/liveness-move-call-arg.rs +++ b/src/test/compile-fail/liveness-move-call-arg.rs @@ -8,11 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn take(_x: ~int) {} + +fn take(_x: Box<int>) {} fn main() { - let x: ~int = ~25; + let x: Box<int> = box 25; loop { take(x); //~ ERROR use of moved value: `x` } diff --git a/src/test/compile-fail/liveness-move-in-loop.rs b/src/test/compile-fail/liveness-move-in-loop.rs index a64d7578af3..018b0aaecfd 100644 --- a/src/test/compile-fail/liveness-move-in-loop.rs +++ b/src/test/compile-fail/liveness-move-in-loop.rs @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + fn main() { - let y: ~int = ~42; - let mut x: ~int; + let y: Box<int> = box 42; + let mut x: Box<int>; loop { println!("{:?}", y); loop { diff --git a/src/test/compile-fail/liveness-move-in-while.rs b/src/test/compile-fail/liveness-move-in-while.rs index 8aa85c03ad4..e32d8a78585 100644 --- a/src/test/compile-fail/liveness-move-in-while.rs +++ b/src/test/compile-fail/liveness-move-in-while.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { - let y: ~int = ~42; - let mut x: ~int; +fn main() { + let y: Box<int> = box 42; + let mut x: Box<int>; loop { println!("{:?}", y); //~ ERROR use of moved value: `y` while true { while true { while true { x = y; x.clone(); } } } diff --git a/src/test/compile-fail/liveness-use-after-move.rs b/src/test/compile-fail/liveness-use-after-move.rs index eccb3784325..f2b8976c61b 100644 --- a/src/test/compile-fail/liveness-use-after-move.rs +++ b/src/test/compile-fail/liveness-use-after-move.rs @@ -9,7 +9,7 @@ // except according to those terms. fn main() { - let x = ~5; + let x = box 5; let y = x; println!("{:?}", *x); //~ ERROR use of moved value: `x` y.clone(); diff --git a/src/test/compile-fail/liveness-use-after-send.rs b/src/test/compile-fail/liveness-use-after-send.rs index 8747d055ff9..2716d476c3a 100644 --- a/src/test/compile-fail/liveness-use-after-send.rs +++ b/src/test/compile-fail/liveness-use-after-send.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + fn send<T:Send>(ch: _chan<T>, data: T) { println!("{:?}", ch); println!("{:?}", data); @@ -18,7 +19,7 @@ struct _chan<T>(int); // Tests that "log(debug, message);" is flagged as using // message after the send deinitializes it -fn test00_start(ch: _chan<~int>, message: ~int, _count: ~int) { +fn test00_start(ch: _chan<Box<int>>, message: Box<int>, _count: Box<int>) { send(ch, message); println!("{:?}", message); //~ ERROR use of moved value: `message` } diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index bd10c6ad8c3..eda4deba752 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -15,9 +15,9 @@ use collections::HashMap; // Test that trait types printed in error msgs include the type arguments. fn main() { - let x: ~HashMap<~str, ~str> = ~HashMap::new(); - let x: ~Map<~str, ~str> = x; - let y: ~Map<uint, ~str> = ~x; + let x: Box<HashMap<~str, ~str>> = box HashMap::new(); + let x: Box<Map<~str, ~str>> = x; + let y: Box<Map<uint, ~str>> = box x; //~^ ERROR failed to find an implementation of trait std::container::Map<uint,~str> // for ~std::container::Map<~str,~str>:Send } diff --git a/src/test/compile-fail/moves-based-on-type-block-bad.rs b/src/test/compile-fail/moves-based-on-type-block-bad.rs index 4ec0831c588..73323def28d 100644 --- a/src/test/compile-fail/moves-based-on-type-block-bad.rs +++ b/src/test/compile-fail/moves-based-on-type-block-bad.rs @@ -8,13 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct S { - x: ~E + x: Box<E> } enum E { - Foo(~S), - Bar(~int), + Foo(Box<S>), + Bar(Box<int>), Baz } @@ -23,13 +24,13 @@ fn f(s: &S, g: |&S|) { } fn main() { - let s = S { x: ~Bar(~42) }; + let s = S { x: box Bar(box 42) }; loop { f(&s, |hellothere| { match hellothere.x { //~ ERROR cannot move out - ~Foo(_) => {} - ~Bar(x) => println!("{}", x.to_str()), //~ NOTE attempting to move value to here - ~Baz => {} + box Foo(_) => {} + box Bar(x) => println!("{}", x.to_str()), //~ NOTE attempting to move value to here + box Baz => {} } }) } diff --git a/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs b/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs index cf82cf087a3..805c82f03f9 100644 --- a/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs +++ b/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs @@ -12,9 +12,10 @@ // temporary kinds wound up being stored in a cache and used later. // See middle::ty::type_contents() for more information. -struct List { key: int, next: Option<~List> } -fn foo(node: ~List) -> int { +struct List { key: int, next: Option<Box<List>> } + +fn foo(node: Box<List>) -> int { let r = match node.next { Some(right) => consume(right), None => 0 @@ -22,7 +23,7 @@ fn foo(node: ~List) -> int { consume(node) + r //~ ERROR use of partially moved value: `node` } -fn consume(v: ~List) -> int { +fn consume(v: Box<List>) -> int { v.key } diff --git a/src/test/compile-fail/moves-based-on-type-move-out-of-closure-env-issue-1965.rs b/src/test/compile-fail/moves-based-on-type-move-out-of-closure-env-issue-1965.rs index ac52f10ba70..f9614574abd 100644 --- a/src/test/compile-fail/moves-based-on-type-move-out-of-closure-env-issue-1965.rs +++ b/src/test/compile-fail/moves-based-on-type-move-out-of-closure-env-issue-1965.rs @@ -10,9 +10,9 @@ use std::uint; -fn test(_x: ~uint) {} +fn test(_x: Box<uint>) {} fn main() { - let i = ~3; + let i = box 3; let _f = || test(i); //~ ERROR cannot move out } diff --git a/src/test/compile-fail/moves-based-on-type-tuple.rs b/src/test/compile-fail/moves-based-on-type-tuple.rs index 6d5bb638be6..85c435ef0db 100644 --- a/src/test/compile-fail/moves-based-on-type-tuple.rs +++ b/src/test/compile-fail/moves-based-on-type-tuple.rs @@ -8,7 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn dup(x: ~int) -> ~(~int,~int) { ~(x, x) } //~ ERROR use of moved value + +fn dup(x: Box<int>) -> Box<(Box<int>,Box<int>)> { box() (x, x) } //~ ERROR use of moved value fn main() { - dup(~3); + dup(box 3); } diff --git a/src/test/compile-fail/moves-sru-moved-field.rs b/src/test/compile-fail/moves-sru-moved-field.rs index 3306d19186c..6f8353c6164 100644 --- a/src/test/compile-fail/moves-sru-moved-field.rs +++ b/src/test/compile-fail/moves-sru-moved-field.rs @@ -8,18 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + type Noncopyable = proc(); struct Foo { copied: int, - moved: ~int, + moved: Box<int>, noncopyable: Noncopyable } fn test0(f: Foo, g: Noncopyable, h: Noncopyable) { // just copy implicitly copyable fields from `f`, no moves: - let _b = Foo {moved: ~1, noncopyable: g, ..f}; - let _c = Foo {moved: ~2, noncopyable: h, ..f}; + let _b = Foo {moved: box 1, noncopyable: g, ..f}; + let _c = Foo {moved: box 2, noncopyable: h, ..f}; } fn test1(f: Foo, g: Noncopyable, h: Noncopyable) { @@ -30,7 +31,7 @@ fn test1(f: Foo, g: Noncopyable, h: Noncopyable) { fn test2(f: Foo, g: Noncopyable) { // move non-copyable field - let _b = Foo {copied: 22, moved: ~23, ..f}; + let _b = Foo {copied: 22, moved: box 23, ..f}; let _c = Foo {noncopyable: g, ..f}; //~ ERROR use of partially moved value: `f` } diff --git a/src/test/compile-fail/new-box-syntax-bad.rs b/src/test/compile-fail/new-box-syntax-bad.rs index 4b00334899d..543902a7a55 100644 --- a/src/test/compile-fail/new-box-syntax-bad.rs +++ b/src/test/compile-fail/new-box-syntax-bad.rs @@ -14,11 +14,11 @@ // Tests that the new `box` syntax works with unique pointers and GC pointers. use std::gc::Gc; -use std::owned::HEAP; +use std::owned::{Box, HEAP}; pub fn main() { let x: Gc<int> = box(HEAP) 2; //~ ERROR mismatched types let y: Gc<int> = box(HEAP)(1 + 2); //~ ERROR mismatched types - let z: ~int = box(GC)(4 + 5); //~ ERROR mismatched types + let z: Box<int> = box(GC)(4 + 5); //~ ERROR mismatched types } diff --git a/src/test/compile-fail/object-does-not-impl-trait.rs b/src/test/compile-fail/object-does-not-impl-trait.rs index 95f92380816..17083933afa 100644 --- a/src/test/compile-fail/object-does-not-impl-trait.rs +++ b/src/test/compile-fail/object-does-not-impl-trait.rs @@ -8,10 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test that an object type `~Foo` is not considered to implement the +// Test that an object type `Box<Foo>` is not considered to implement the // trait `Foo`. Issue #5087. + trait Foo {} fn take_foo<F:Foo>(f: F) {} -fn take_object(f: ~Foo) { take_foo(f); } //~ ERROR failed to find an implementation of trait +fn take_object(f: Box<Foo>) { take_foo(f); } //~ ERROR failed to find an implementation of trait fn main() {} diff --git a/src/test/compile-fail/object-pointer-types.rs b/src/test/compile-fail/object-pointer-types.rs index ab2aa928c26..8868ddd4dfa 100644 --- a/src/test/compile-fail/object-pointer-types.rs +++ b/src/test/compile-fail/object-pointer-types.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait Foo { fn borrowed(&self); fn borrowed_mut(&mut self); @@ -27,7 +28,7 @@ fn borrowed_mut_receiver(x: &mut Foo) { x.owned(); //~ ERROR does not implement any method } -fn owned_receiver(x: ~Foo) { +fn owned_receiver(x: Box<Foo>) { x.borrowed(); x.borrowed_mut(); // See [1] x.managed(); //~ ERROR does not implement any method diff --git a/src/test/compile-fail/owned-ptr-static-bound.rs b/src/test/compile-fail/owned-ptr-static-bound.rs index 508633d2941..48f04c33494 100644 --- a/src/test/compile-fail/owned-ptr-static-bound.rs +++ b/src/test/compile-fail/owned-ptr-static-bound.rs @@ -8,22 +8,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait A<T> {} struct B<'a, T>(&'a A<T>); trait X {} impl<'a, T> X for B<'a, T> {} -fn f<'a, T, U>(v: ~A<T>) -> ~X: { - ~B(v) as ~X: //~ ERROR value may contain references; add `'static` bound to `T` +fn f<'a, T, U>(v: Box<A<T>>) -> Box<X:> { + box B(v) as Box<X:> //~ ERROR value may contain references; add `'static` bound to `T` } -fn g<'a, T, U>(v: ~A<U>) -> ~X: { - ~B(v) as ~X: //~ ERROR value may contain references; add `'static` bound to `U` +fn g<'a, T, U>(v: Box<A<U>>) -> Box<X:> { + box B(v) as Box<X:> //~ ERROR value may contain references; add `'static` bound to `U` } -fn h<'a, T: 'static>(v: ~A<T>) -> ~X: { - ~B(v) as ~X: // ok +fn h<'a, T: 'static>(v: Box<A<T>>) -> Box<X:> { + box B(v) as Box<X:> // ok } fn main() {} diff --git a/src/test/compile-fail/pinned-deep-copy.rs b/src/test/compile-fail/pinned-deep-copy.rs index 0589d58a4c2..49f2f35d29d 100644 --- a/src/test/compile-fail/pinned-deep-copy.rs +++ b/src/test/compile-fail/pinned-deep-copy.rs @@ -39,7 +39,7 @@ fn main() { let i = @Cell::new(0); { // Can't do this copy - let x = ~~~A {y: r(i)}; + let x = box box box A {y: r(i)}; let _z = x.clone(); //~ ERROR failed to find an implementation println!("{:?}", x); } diff --git a/src/test/compile-fail/privacy-ns1.rs b/src/test/compile-fail/privacy-ns1.rs index cb11a50055f..b7eee206b40 100644 --- a/src/test/compile-fail/privacy-ns1.rs +++ b/src/test/compile-fail/privacy-ns1.rs @@ -15,6 +15,7 @@ #![allow(dead_code)] #![allow(unused_imports)] + // public type, private value pub mod foo1 { pub trait Bar { @@ -42,7 +43,7 @@ pub mod foo2 { fn test_glob2() { use foo2::*; - let _x: ~Bar; //~ ERROR use of undeclared type name `Bar` + let _x: Box<Bar>; //~ ERROR use of undeclared type name `Bar` } // neither public @@ -58,7 +59,7 @@ fn test_glob3() { use foo3::*; Bar(); //~ ERROR unresolved name `Bar`. - let _x: ~Bar; //~ ERROR use of undeclared type name `Bar` + let _x: Box<Bar>; //~ ERROR use of undeclared type name `Bar` } fn main() { diff --git a/src/test/compile-fail/privacy-ns2.rs b/src/test/compile-fail/privacy-ns2.rs index c75b12165c0..5ce0fb7e56a 100644 --- a/src/test/compile-fail/privacy-ns2.rs +++ b/src/test/compile-fail/privacy-ns2.rs @@ -15,6 +15,7 @@ #![allow(dead_code)] #![allow(unused_imports)] + // public type, private value pub mod foo1 { pub trait Bar { @@ -49,13 +50,13 @@ pub mod foo2 { fn test_single2() { use foo2::Bar; //~ ERROR `Bar` is private - let _x : ~Bar; + let _x : Box<Bar>; } fn test_list2() { use foo2::{Bar,Baz}; //~ ERROR `Bar` is private - let _x: ~Bar; + let _x: Box<Bar>; } // neither public @@ -76,14 +77,14 @@ fn test_single3() { use foo3::Bar; //~ ERROR `Bar` is private Bar(); - let _x: ~Bar; + let _x: Box<Bar>; } fn test_list3() { use foo3::{Bar,Baz}; //~ ERROR `Bar` is private Bar(); - let _x: ~Bar; + let _x: Box<Bar>; } fn main() { diff --git a/src/test/compile-fail/regions-bound-lists-feature-gate.rs b/src/test/compile-fail/regions-bound-lists-feature-gate.rs index 05050b72e5e..aa398bcd557 100644 --- a/src/test/compile-fail/regions-bound-lists-feature-gate.rs +++ b/src/test/compile-fail/regions-bound-lists-feature-gate.rs @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait Foo { } -fn foo<'a>(x: ~Foo:'a) { //~ ERROR only the 'static lifetime is accepted here +fn foo<'a>(x: Box<Foo:'a>) { //~ ERROR only the 'static lifetime is accepted here } fn bar<'a, T:'a>() { //~ ERROR only the 'static lifetime is accepted here diff --git a/src/test/compile-fail/regions-ref-in-fn-arg.rs b/src/test/compile-fail/regions-ref-in-fn-arg.rs index 8c8404f7abc..47fca8bb8df 100644 --- a/src/test/compile-fail/regions-ref-in-fn-arg.rs +++ b/src/test/compile-fail/regions-ref-in-fn-arg.rs @@ -8,14 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn arg_item(~ref x: ~int) -> &'static int { + +fn arg_item(box ref x: Box<int>) -> &'static int { x //~^ ERROR borrowed value does not live long enough } -fn with<R>(f: |~int| -> R) -> R { f(~3) } +fn with<R>(f: |Box<int>| -> R) -> R { f(box 3) } fn arg_closure() -> &'static int { - with(|~ref x| x) //~ ERROR borrowed value does not live long enough + with(|box ref x| x) //~ ERROR borrowed value does not live long enough } fn main() {} diff --git a/src/test/compile-fail/regions-trait-1.rs b/src/test/compile-fail/regions-trait-1.rs index 7aa545ab1b9..7771a71c79b 100644 --- a/src/test/compile-fail/regions-trait-1.rs +++ b/src/test/compile-fail/regions-trait-1.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct ctxt { v: uint } trait get_ctxt { @@ -27,12 +28,12 @@ impl<'a> get_ctxt for has_ctxt<'a> { } -fn get_v(gc: ~get_ctxt) -> uint { +fn get_v(gc: Box<get_ctxt>) -> uint { gc.get_ctxt().v } fn main() { let ctxt = ctxt { v: 22u }; let hc = has_ctxt { c: &ctxt }; - assert_eq!(get_v(~hc as ~get_ctxt), 22u); + assert_eq!(get_v(box hc as Box<get_ctxt>), 22u); } diff --git a/src/test/compile-fail/removed-syntax-closure-lifetime.rs b/src/test/compile-fail/removed-syntax-closure-lifetime.rs index e2ab70b1678..c5c8aa043f3 100644 --- a/src/test/compile-fail/removed-syntax-closure-lifetime.rs +++ b/src/test/compile-fail/removed-syntax-closure-lifetime.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -type closure = ~lt/fn(); //~ ERROR expected `;` but found `/` +type closure = Box<lt/fn()>; //~ ERROR expected `,` but found `/` diff --git a/src/test/compile-fail/removed-syntax-uniq-mut-expr.rs b/src/test/compile-fail/removed-syntax-uniq-mut-expr.rs index 0c2693a898b..5603cd21f3b 100644 --- a/src/test/compile-fail/removed-syntax-uniq-mut-expr.rs +++ b/src/test/compile-fail/removed-syntax-uniq-mut-expr.rs @@ -9,7 +9,7 @@ // except according to those terms. fn f() { - let a_box = ~mut 42; + let a_box = box mut 42; //~^ ERROR found `mut` in ident position //~^^ ERROR expected `;` but found `42` } diff --git a/src/test/compile-fail/removed-syntax-uniq-mut-ty.rs b/src/test/compile-fail/removed-syntax-uniq-mut-ty.rs index 98ab7522966..128dbbd9cab 100644 --- a/src/test/compile-fail/removed-syntax-uniq-mut-ty.rs +++ b/src/test/compile-fail/removed-syntax-uniq-mut-ty.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -type mut_box = ~mut int; +type mut_box = Box<mut int>; //~^ ERROR found `mut` in ident position - //~^^ ERROR expected `;` but found `int` + //~^^ ERROR expected `,` but found `int` diff --git a/src/test/compile-fail/removed-syntax-uniq-self.rs b/src/test/compile-fail/removed-syntax-uniq-self.rs deleted file mode 100644 index 8fb9c5e0e6f..00000000000 --- a/src/test/compile-fail/removed-syntax-uniq-self.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -struct S; - -impl S { - fn f(~mut self) {} //~ ERROR found `self` in ident position - //~^ ERROR expected `:` but found `)` -} diff --git a/src/test/compile-fail/selftype-traittype.rs b/src/test/compile-fail/selftype-traittype.rs index 73df5c3967c..3bf547e3aff 100644 --- a/src/test/compile-fail/selftype-traittype.rs +++ b/src/test/compile-fail/selftype-traittype.rs @@ -8,11 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait add { fn plus(&self, x: Self) -> Self; } -fn do_add(x: ~add, y: ~add) -> ~add { +fn do_add(x: Box<add>, y: Box<add>) -> Box<add> { x.plus(y) //~ ERROR cannot call a method whose type contains a self-type through an object } diff --git a/src/test/compile-fail/static-mut-not-constant.rs b/src/test/compile-fail/static-mut-not-constant.rs index 90dabb7e3a2..927006adc9e 100644 --- a/src/test/compile-fail/static-mut-not-constant.rs +++ b/src/test/compile-fail/static-mut-not-constant.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -static mut a: ~int = ~3; //~ ERROR: mutable static items are not allowed to have owned pointers + +static mut a: Box<int> = box 3; +//~^ ERROR mutable static items are not allowed to have owned pointers fn main() {} diff --git a/src/test/compile-fail/struct-fields-missing.rs b/src/test/compile-fail/struct-fields-missing.rs index 81d2ea3b959..0afc84ee1b3 100644 --- a/src/test/compile-fail/struct-fields-missing.rs +++ b/src/test/compile-fail/struct-fields-missing.rs @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct BuildData { foo: int, - bar: ~int + bar: Box<int>, } fn main() { diff --git a/src/test/compile-fail/trait-bounds-cant-coerce.rs b/src/test/compile-fail/trait-bounds-cant-coerce.rs index 958a97412bc..12205ef062d 100644 --- a/src/test/compile-fail/trait-bounds-cant-coerce.rs +++ b/src/test/compile-fail/trait-bounds-cant-coerce.rs @@ -8,17 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait Foo { } -fn a(_x: ~Foo:Send) { +fn a(_x: Box<Foo:Send>) { } -fn c(x: ~Foo:Share+Send) { +fn c(x: Box<Foo:Share+Send>) { a(x); } -fn d(x: ~Foo:) { +fn d(x: Box<Foo:>) { a(x); //~ ERROR found no bounds } diff --git a/src/test/compile-fail/trait-bounds-not-on-struct.rs b/src/test/compile-fail/trait-bounds-not-on-struct.rs index ebffd0303e0..be5375d2938 100644 --- a/src/test/compile-fail/trait-bounds-not-on-struct.rs +++ b/src/test/compile-fail/trait-bounds-not-on-struct.rs @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct Foo; -fn foo(_x: ~Foo:Send) { } //~ ERROR kind bounds can only be used on trait types +fn foo(_x: Box<Foo:Send>) { } //~ ERROR kind bounds can only be used on trait types fn main() { } diff --git a/src/test/compile-fail/trait-bounds-sugar.rs b/src/test/compile-fail/trait-bounds-sugar.rs index 32c23a3efdd..9447030a7f4 100644 --- a/src/test/compile-fail/trait-bounds-sugar.rs +++ b/src/test/compile-fail/trait-bounds-sugar.rs @@ -10,15 +10,16 @@ // Tests for "default" bounds inferred for traits with no bounds list. + trait Foo {} -fn a(_x: ~Foo:Send) { +fn a(_x: Box<Foo:Send>) { } fn b(_x: &'static Foo) { // should be same as &'static Foo:'static } -fn c(x: ~Foo:Share) { +fn c(x: Box<Foo:Share>) { a(x); //~ ERROR expected bounds `Send` } diff --git a/src/test/compile-fail/trait-coercion-generic-bad.rs b/src/test/compile-fail/trait-coercion-generic-bad.rs index 297d36c3a0e..7c4b633fa9e 100644 --- a/src/test/compile-fail/trait-coercion-generic-bad.rs +++ b/src/test/compile-fail/trait-coercion-generic-bad.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct Struct { person: &'static str } @@ -23,7 +24,7 @@ impl Trait<&'static str> for Struct { } fn main() { - let s: ~Trait<int> = ~Struct { person: "Fred" }; + let s: Box<Trait<int>> = box Struct { person: "Fred" }; //~^ ERROR expected Trait<int>, but found Trait<&'static str> //~^^ ERROR expected Trait<int>, but found Trait<&'static str> s.f(1); diff --git a/src/test/compile-fail/trait-coercion-generic-regions.rs b/src/test/compile-fail/trait-coercion-generic-regions.rs index 6ffee2ef22b..04239de2a83 100644 --- a/src/test/compile-fail/trait-coercion-generic-regions.rs +++ b/src/test/compile-fail/trait-coercion-generic-regions.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct Struct { person: &'static str } @@ -25,6 +26,6 @@ impl Trait<&'static str> for Struct { fn main() { let person = "Fred".to_owned(); let person: &str = person; //~ ERROR `person[..]` does not live long enough - let s: ~Trait<&'static str> = ~Struct { person: person }; + let s: Box<Trait<&'static str>> = box Struct { person: person }; } diff --git a/src/test/compile-fail/trait-test-2.rs b/src/test/compile-fail/trait-test-2.rs index acac7ae9556..5e0340ce4f5 100644 --- a/src/test/compile-fail/trait-test-2.rs +++ b/src/test/compile-fail/trait-test-2.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait bar { fn dup(&self) -> Self; fn blah<X>(&self); } impl bar for int { fn dup(&self) -> int { *self } fn blah<X>(&self) {} } impl bar for uint { fn dup(&self) -> uint { *self } fn blah<X>(&self) {} } @@ -15,5 +16,5 @@ impl bar for uint { fn dup(&self) -> uint { *self } fn blah<X>(&self) {} } fn main() { 10i.dup::<int>(); //~ ERROR does not take type parameters 10i.blah::<int, int>(); //~ ERROR incorrect number of type parameters - (~10 as ~bar).dup(); //~ ERROR contains a self-type + (box 10 as Box<bar>).dup(); //~ ERROR contains a self-type } diff --git a/src/test/compile-fail/unique-object-noncopyable.rs b/src/test/compile-fail/unique-object-noncopyable.rs index 843b61c9dbe..e237e2c8b75 100644 --- a/src/test/compile-fail/unique-object-noncopyable.rs +++ b/src/test/compile-fail/unique-object-noncopyable.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait Foo { fn f(&self); } @@ -27,7 +28,7 @@ impl Foo for Bar { } fn main() { - let x = ~Bar { x: 10 }; - let y: ~Foo = x as ~Foo; + let x = box Bar { x: 10 }; + let y: Box<Foo> = x as Box<Foo>; let _z = y.clone(); //~ ERROR does not implement any method in scope } diff --git a/src/test/compile-fail/unique-pinned-nocopy.rs b/src/test/compile-fail/unique-pinned-nocopy.rs index da9e24b7314..04d8bc96a47 100644 --- a/src/test/compile-fail/unique-pinned-nocopy.rs +++ b/src/test/compile-fail/unique-pinned-nocopy.rs @@ -17,7 +17,7 @@ impl Drop for r { } fn main() { - let i = ~r { b: true }; + let i = box r { b: true }; let _j = i.clone(); //~ ERROR failed to find an implementation println!("{:?}", i); } diff --git a/src/test/compile-fail/unique-unique-kind.rs b/src/test/compile-fail/unique-unique-kind.rs index 8e951cc9b55..6a62256b881 100644 --- a/src/test/compile-fail/unique-unique-kind.rs +++ b/src/test/compile-fail/unique-unique-kind.rs @@ -14,6 +14,6 @@ fn f<T:Send>(_i: T) { } fn main() { - let i = ~@100; + let i = box @100; f(i); //~ ERROR does not fulfill `Send` } diff --git a/src/test/compile-fail/unique-vec-res.rs b/src/test/compile-fail/unique-vec-res.rs index b83277b38a6..adeecf2babf 100644 --- a/src/test/compile-fail/unique-vec-res.rs +++ b/src/test/compile-fail/unique-vec-res.rs @@ -31,8 +31,8 @@ fn f<T>(_i: Vec<T> , _j: Vec<T> ) { fn main() { let i1 = @Cell::new(0); let i2 = @Cell::new(1); - let r1 = vec!(~r { i: i1 }); - let r2 = vec!(~r { i: i2 }); + let r1 = vec!(box r { i: i1 }); + let r2 = vec!(box r { i: i2 }); f(r1.clone(), r2.clone()); //~^ ERROR failed to find an implementation of println!("{:?}", (r2, i1.get())); diff --git a/src/test/compile-fail/unreachable-arm.rs b/src/test/compile-fail/unreachable-arm.rs index b983eabb743..e356f87af69 100644 --- a/src/test/compile-fail/unreachable-arm.rs +++ b/src/test/compile-fail/unreachable-arm.rs @@ -10,6 +10,7 @@ // error-pattern:unreachable pattern -enum foo { a(~foo, int), b(uint), } -fn main() { match b(1u) { b(_) | a(~_, 1) => { } a(_, 1) => { } } } +enum foo { a(Box<foo>, int), b(uint), } + +fn main() { match b(1u) { b(_) | a(box _, 1) => { } a(_, 1) => { } } } diff --git a/src/test/compile-fail/unsized3.rs b/src/test/compile-fail/unsized3.rs index 0ff5b1c9b5a..c321871c40f 100644 --- a/src/test/compile-fail/unsized3.rs +++ b/src/test/compile-fail/unsized3.rs @@ -10,6 +10,7 @@ // Test sized-ness checking in substitution. + // Unbounded. fn f1<type X>(x: &X) { f2::<X>(x); //~ ERROR instantiating a type parameter with an incompatible type `X`, which does n @@ -49,7 +50,7 @@ fn f8<type X>(x1: &S<X>, x2: &S<X>) { } // Test some tuples. -fn f9<type X>(x1: ~S<X>, x2: ~E<X>) { +fn f9<type X>(x1: Box<S<X>>, x2: Box<E<X>>) { f5(&(*x1, 34)); //~ERROR instantiating a type parameter with an incompatible type `(S<X>,int)`, f5(&(32, *x2)); //~ERROR instantiating a type parameter with an incompatible type `(int,E<X>)`, } diff --git a/src/test/compile-fail/unsized6.rs b/src/test/compile-fail/unsized6.rs index a763373e364..9916fdba20f 100644 --- a/src/test/compile-fail/unsized6.rs +++ b/src/test/compile-fail/unsized6.rs @@ -10,6 +10,7 @@ // Test `type` local variables. + trait T for type {} fn f1<type X>(x: &X) { @@ -25,12 +26,12 @@ fn f2<type X: T>(x: &X) { let y: (int, (X, int)); //~ERROR variable `y` has dynamically sized type `(int,(X,int))` } -fn f3<type X>(x1: ~X, x2: ~X, x3: ~X) { +fn f3<type X>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { let y: X = *x1; //~ERROR variable `y` has dynamically sized type `X` let y = *x2; //~ERROR variable `y` has dynamically sized type `X` let (y, z) = (*x3, 4); //~ERROR variable `y` has dynamically sized type `X` } -fn f4<type X: T>(x1: ~X, x2: ~X, x3: ~X) { +fn f4<type X: T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) { let y: X = *x1; //~ERROR variable `y` has dynamically sized type `X` let y = *x2; //~ERROR variable `y` has dynamically sized type `X` let (y, z) = (*x3, 4); //~ERROR variable `y` has dynamically sized type `X` diff --git a/src/test/compile-fail/use-after-move-implicity-coerced-object.rs b/src/test/compile-fail/use-after-move-implicity-coerced-object.rs index 4d57470a721..e95ab71e5aa 100644 --- a/src/test/compile-fail/use-after-move-implicity-coerced-object.rs +++ b/src/test/compile-fail/use-after-move-implicity-coerced-object.rs @@ -23,17 +23,17 @@ impl fmt::Show for Number { } struct List { - list: Vec<~ToStr> } + list: Vec<Box<ToStr>> } impl List { - fn push(&mut self, n: ~ToStr) { + fn push(&mut self, n: Box<ToStr>) { self.list.push(n); } } fn main() { - let n = ~Number { n: 42 }; - let mut l = ~List { list: Vec::new() }; + let n = box Number { n: 42 }; + let mut l = box List { list: Vec::new() }; l.push(n); let x = n.to_str(); //~^ ERROR: use of moved value: `n` diff --git a/src/test/compile-fail/use-after-move-self.rs b/src/test/compile-fail/use-after-move-self.rs index 56e5fdce3cf..8d1ab1bcd94 100644 --- a/src/test/compile-fail/use-after-move-self.rs +++ b/src/test/compile-fail/use-after-move-self.rs @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct S { - x: ~int + x: Box<int>, } impl S { @@ -22,6 +23,6 @@ impl S { } fn main() { - let x = S { x: ~1 }; + let x = S { x: box 1 }; println!("{}", x.foo()); } diff --git a/src/test/debug-info/borrowed-struct.rs b/src/test/debug-info/borrowed-struct.rs index c5f4bf0ac62..e271a221611 100644 --- a/src/test/debug-info/borrowed-struct.rs +++ b/src/test/debug-info/borrowed-struct.rs @@ -65,7 +65,7 @@ fn main() { let managed_val_interior_ref_1: &int = &managed_val.x; let managed_val_interior_ref_2: &f64 = &managed_val.y; - let unique_val = ~SomeStruct { x: 13, y: 26.5 }; + let unique_val = box SomeStruct { x: 13, y: 26.5 }; let unique_val_ref: &SomeStruct = unique_val; let unique_val_interior_ref_1: &int = &unique_val.x; let unique_val_interior_ref_2: &f64 = &unique_val.y; diff --git a/src/test/debug-info/borrowed-tuple.rs b/src/test/debug-info/borrowed-tuple.rs index 5cc69c94d59..b619f8e8ba1 100644 --- a/src/test/debug-info/borrowed-tuple.rs +++ b/src/test/debug-info/borrowed-tuple.rs @@ -31,6 +31,7 @@ #![allow(unused_variable)] + fn main() { let stack_val: (i16, f32) = (-14, -19f32); let stack_val_ref: &(i16, f32) = &stack_val; @@ -39,7 +40,7 @@ fn main() { let managed_val: @(i16, f32) = @(-16, -21f32); let managed_val_ref: &(i16, f32) = managed_val; - let unique_val: ~(i16, f32) = ~(-17, -22f32); + let unique_val: Box<(i16, f32)> = box() (-17, -22f32); let unique_val_ref: &(i16, f32) = unique_val; zzz(); diff --git a/src/test/debug-info/borrowed-unique-basic.rs b/src/test/debug-info/borrowed-unique-basic.rs index 98cf0905f2a..eaa2679e698 100644 --- a/src/test/debug-info/borrowed-unique-basic.rs +++ b/src/test/debug-info/borrowed-unique-basic.rs @@ -63,46 +63,46 @@ fn main() { - let bool_box: ~bool = ~true; + let bool_box: Box<bool> = box true; let bool_ref: &bool = bool_box; - let int_box: ~int = ~-1; + let int_box: Box<int> = box -1; let int_ref: &int = int_box; - let char_box: ~char = ~'a'; + let char_box: Box<char> = box 'a'; let char_ref: &char = char_box; - let i8_box: ~i8 = ~68; + let i8_box: Box<i8> = box 68; let i8_ref: &i8 = i8_box; - let i16_box: ~i16 = ~-16; + let i16_box: Box<i16> = box -16; let i16_ref: &i16 = i16_box; - let i32_box: ~i32 = ~-32; + let i32_box: Box<i32> = box -32; let i32_ref: &i32 = i32_box; - let i64_box: ~i64 = ~-64; + let i64_box: Box<i64> = box -64; let i64_ref: &i64 = i64_box; - let uint_box: ~uint = ~1; + let uint_box: Box<uint> = box 1; let uint_ref: &uint = uint_box; - let u8_box: ~u8 = ~100; + let u8_box: Box<u8> = box 100; let u8_ref: &u8 = u8_box; - let u16_box: ~u16 = ~16; + let u16_box: Box<u16> = box 16; let u16_ref: &u16 = u16_box; - let u32_box: ~u32 = ~32; + let u32_box: Box<u32> = box 32; let u32_ref: &u32 = u32_box; - let u64_box: ~u64 = ~64; + let u64_box: Box<u64> = box 64; let u64_ref: &u64 = u64_box; - let f32_box: ~f32 = ~2.5; + let f32_box: Box<f32> = box 2.5; let f32_ref: &f32 = f32_box; - let f64_box: ~f64 = ~3.5; + let f64_box: Box<f64> = box 3.5; let f64_ref: &f64 = f64_box; zzz(); } diff --git a/src/test/debug-info/box.rs b/src/test/debug-info/box.rs index 208dd52f9ac..a849a058332 100644 --- a/src/test/debug-info/box.rs +++ b/src/test/debug-info/box.rs @@ -28,8 +28,8 @@ #![allow(unused_variable)] fn main() { - let a = ~1; - let b = ~(2, 3.5); + let a = box 1; + let b = box() (2, 3.5); let c = @4; let d = @false; _zzz(); diff --git a/src/test/debug-info/boxed-struct.rs b/src/test/debug-info/boxed-struct.rs index 84b35134ad5..a286fca22c1 100644 --- a/src/test/debug-info/boxed-struct.rs +++ b/src/test/debug-info/boxed-struct.rs @@ -30,6 +30,7 @@ #![feature(managed_boxes)] #![allow(unused_variable)] + struct StructWithSomePadding { x: i16, y: i32, @@ -50,10 +51,10 @@ impl Drop for StructWithDestructor { fn main() { - let unique = ~StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 }; + let unique = box StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 }; let managed = @StructWithSomePadding { x: 88, y: 888, z: 8888, w: 88888 }; - let unique_dtor = ~StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 }; + let unique_dtor = box StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 }; let managed_dtor = @StructWithDestructor { x: 33, y: 333, z: 3333, w: 33333 }; zzz(); diff --git a/src/test/debug-info/closure-in-generic-function.rs b/src/test/debug-info/closure-in-generic-function.rs index 1184ce8643b..f3692e7bf96 100644 --- a/src/test/debug-info/closure-in-generic-function.rs +++ b/src/test/debug-info/closure-in-generic-function.rs @@ -40,7 +40,7 @@ fn some_generic_fun<T1, T2>(a: T1, b: T2) -> (T2, T1) { fn main() { some_generic_fun(0.5, 10); - some_generic_fun(&29, ~110); + some_generic_fun(&29, box 110); } fn zzz() {()} diff --git a/src/test/debug-info/destructured-fn-argument.rs b/src/test/debug-info/destructured-fn-argument.rs index 246857d345c..2f7fc961cdd 100644 --- a/src/test/debug-info/destructured-fn-argument.rs +++ b/src/test/debug-info/destructured-fn-argument.rs @@ -183,6 +183,7 @@ #![allow(unused_variable)] + struct Struct { a: i64, b: i32 @@ -249,7 +250,7 @@ fn contained_borrowed_pointer((&cc, _): (&int, int)) { zzz(); } -fn unique_pointer(~dd: ~(int, int, int)) { +fn unique_pointer(box dd: Box<(int, int, int)>) { zzz(); } @@ -299,7 +300,7 @@ fn main() { managed_box(&(34, 35)); borrowed_pointer(&(36, 37)); contained_borrowed_pointer((&38, 39)); - unique_pointer(~(40, 41, 42)); + unique_pointer(box() (40, 41, 42)); ref_binding((43, 44, 45)); ref_binding_in_tuple((46, (47, 48))); ref_binding_in_struct(Struct { a: 49, b: 50 }); diff --git a/src/test/debug-info/destructured-local.rs b/src/test/debug-info/destructured-local.rs index 5aabf1fe82f..3dab6ace9a8 100644 --- a/src/test/debug-info/destructured-local.rs +++ b/src/test/debug-info/destructured-local.rs @@ -181,7 +181,7 @@ fn main() { let (&cc, _) = (&38, 39); // unique pointer - let ~dd = ~(40, 41, 42); + let box dd = box() (40, 41, 42); // ref binding let ref ee = (43, 44, 45); diff --git a/src/test/debug-info/generic-method-on-generic-struct.rs b/src/test/debug-info/generic-method-on-generic-struct.rs index 38d260678b7..7afa8952998 100644 --- a/src/test/debug-info/generic-method-on-generic-struct.rs +++ b/src/test/debug-info/generic-method-on-generic-struct.rs @@ -91,7 +91,7 @@ fn main() { let _ = stack.self_by_ref(-1, -2_i8); let _ = stack.self_by_val(-3, -4_i16); - let owned = ~Struct { x: 1234.5 }; + let owned = box Struct { x: 1234.5 }; let _ = owned.self_by_ref(-5, -6_i32); let _ = owned.self_by_val(-7, -8_i64); let _ = owned.self_owned(-9, -10.5_f32); diff --git a/src/test/debug-info/managed-pointer-within-unique.rs b/src/test/debug-info/managed-pointer-within-unique.rs index 79fb353ac4d..2207b3ef798 100644 --- a/src/test/debug-info/managed-pointer-within-unique.rs +++ b/src/test/debug-info/managed-pointer-within-unique.rs @@ -35,9 +35,9 @@ struct ContainsManaged { } fn main() { - let ordinary_unique = ~(-1, -2); + let ordinary_unique = box() (-1, -2); - let managed_within_unique = ~ContainsManaged { x: -3, y: @-4 }; + let managed_within_unique = box ContainsManaged { x: -3, y: @-4 }; zzz(); } diff --git a/src/test/debug-info/method-on-enum.rs b/src/test/debug-info/method-on-enum.rs index 3ef78c49a54..9c8718a4295 100644 --- a/src/test/debug-info/method-on-enum.rs +++ b/src/test/debug-info/method-on-enum.rs @@ -94,7 +94,7 @@ fn main() { let _ = stack.self_by_ref(-1, -2); let _ = stack.self_by_val(-3, -4); - let owned = ~Variant1{ x: 1799, y: 1799 }; + let owned = box Variant1{ x: 1799, y: 1799 }; let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); diff --git a/src/test/debug-info/method-on-generic-struct.rs b/src/test/debug-info/method-on-generic-struct.rs index 1c82fec2a8b..f2cdadd8aad 100644 --- a/src/test/debug-info/method-on-generic-struct.rs +++ b/src/test/debug-info/method-on-generic-struct.rs @@ -91,7 +91,7 @@ fn main() { let _ = stack.self_by_ref(-1, -2); let _ = stack.self_by_val(-3, -4); - let owned = ~Struct { x: 1234.5 }; + let owned = box Struct { x: 1234.5 }; let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); diff --git a/src/test/debug-info/method-on-struct.rs b/src/test/debug-info/method-on-struct.rs index 1bfec62dedc..dcd285b0a14 100644 --- a/src/test/debug-info/method-on-struct.rs +++ b/src/test/debug-info/method-on-struct.rs @@ -91,7 +91,7 @@ fn main() { let _ = stack.self_by_ref(-1, -2); let _ = stack.self_by_val(-3, -4); - let owned = ~Struct { x: 200 }; + let owned = box Struct { x: 200 }; let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); diff --git a/src/test/debug-info/method-on-trait.rs b/src/test/debug-info/method-on-trait.rs index 473ed973bb5..6e1f8e6c72d 100644 --- a/src/test/debug-info/method-on-trait.rs +++ b/src/test/debug-info/method-on-trait.rs @@ -97,7 +97,7 @@ fn main() { let _ = stack.self_by_ref(-1, -2); let _ = stack.self_by_val(-3, -4); - let owned = ~Struct { x: 200 }; + let owned = box Struct { x: 200 }; let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); diff --git a/src/test/debug-info/method-on-tuple-struct.rs b/src/test/debug-info/method-on-tuple-struct.rs index d0b97a079cc..184bee99d87 100644 --- a/src/test/debug-info/method-on-tuple-struct.rs +++ b/src/test/debug-info/method-on-tuple-struct.rs @@ -89,7 +89,7 @@ fn main() { let _ = stack.self_by_ref(-1, -2); let _ = stack.self_by_val(-3, -4); - let owned = ~TupleStruct(200, -200.5); + let owned = box TupleStruct(200, -200.5); let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); diff --git a/src/test/debug-info/recursive-struct.rs b/src/test/debug-info/recursive-struct.rs index ca178468941..a46a1c248ff 100644 --- a/src/test/debug-info/recursive-struct.rs +++ b/src/test/debug-info/recursive-struct.rs @@ -105,13 +105,14 @@ #![allow(unused_variable)] #![feature(struct_variant)] + enum Opt<T> { Empty, Val { val: T } } struct UniqueNode<T> { - next: Opt<~UniqueNode<T>>, + next: Opt<Box<UniqueNode<T>>>, value: T } @@ -121,27 +122,27 @@ struct ManagedNode<T> { } struct LongCycle1<T> { - next: ~LongCycle2<T>, + next: Box<LongCycle2<T>>, value: T, } struct LongCycle2<T> { - next: ~LongCycle3<T>, + next: Box<LongCycle3<T>>, value: T, } struct LongCycle3<T> { - next: ~LongCycle4<T>, + next: Box<LongCycle4<T>>, value: T, } struct LongCycle4<T> { - next: Option<~LongCycle1<T>>, + next: Option<Box<LongCycle1<T>>>, value: T, } struct LongCycleWithAnonymousTypes { - next: Opt<~~~~~LongCycleWithAnonymousTypes>, + next: Opt<Box<Box<Box<Box<Box<LongCycleWithAnonymousTypes>>>>>>, value: uint, } @@ -163,7 +164,7 @@ struct LongCycleWithAnonymousTypes { fn main() { let stack_unique: UniqueNode<u16> = UniqueNode { next: Val { - val: ~UniqueNode { + val: box UniqueNode { next: Empty, value: 1_u16, } @@ -171,9 +172,9 @@ fn main() { value: 0_u16, }; - let unique_unique: ~UniqueNode<u32> = ~UniqueNode { + let unique_unique: Box<UniqueNode<u32>> = box UniqueNode { next: Val { - val: ~UniqueNode { + val: box UniqueNode { next: Empty, value: 3, } @@ -183,7 +184,7 @@ fn main() { let box_unique: @UniqueNode<u64> = @UniqueNode { next: Val { - val: ~UniqueNode { + val: box UniqueNode { next: Empty, value: 5, } @@ -193,7 +194,7 @@ fn main() { let vec_unique: [UniqueNode<f32>, ..1] = [UniqueNode { next: Val { - val: ~UniqueNode { + val: box UniqueNode { next: Empty, value: 7.5, } @@ -203,7 +204,7 @@ fn main() { let borrowed_unique: &UniqueNode<f64> = &UniqueNode { next: Val { - val: ~UniqueNode { + val: box UniqueNode { next: Empty, value: 9.5, } @@ -221,7 +222,7 @@ fn main() { value: 10, }; - let unique_managed: ~ManagedNode<u32> = ~ManagedNode { + let unique_managed: Box<ManagedNode<u32>> = box ManagedNode { next: Val { val: @ManagedNode { next: Empty, @@ -263,9 +264,9 @@ fn main() { // LONG CYCLE let long_cycle1: LongCycle1<u16> = LongCycle1 { - next: ~LongCycle2 { - next: ~LongCycle3 { - next: ~LongCycle4 { + next: box LongCycle2 { + next: box LongCycle3 { + next: box LongCycle4 { next: None, value: 23, }, @@ -277,8 +278,8 @@ fn main() { }; let long_cycle2: LongCycle2<u32> = LongCycle2 { - next: ~LongCycle3 { - next: ~LongCycle4 { + next: box LongCycle3 { + next: box LongCycle4 { next: None, value: 26, }, @@ -288,7 +289,7 @@ fn main() { }; let long_cycle3: LongCycle3<u64> = LongCycle3 { - next: ~LongCycle4 { + next: box LongCycle4 { next: None, value: 28, }, @@ -301,10 +302,10 @@ fn main() { }; // It's important that LongCycleWithAnonymousTypes is encountered only at the end of the - // `~` chain. - let long_cycle_w_anonymous_types = ~~~~~LongCycleWithAnonymousTypes { + // `box` chain. + let long_cycle_w_anonymous_types = box box box box box LongCycleWithAnonymousTypes { next: Val { - val: ~~~~~LongCycleWithAnonymousTypes { + val: box box box box box LongCycleWithAnonymousTypes { next: Empty, value: 31, } diff --git a/src/test/debug-info/self-in-default-method.rs b/src/test/debug-info/self-in-default-method.rs index c8ab9d1f0bc..194cfc77bf3 100644 --- a/src/test/debug-info/self-in-default-method.rs +++ b/src/test/debug-info/self-in-default-method.rs @@ -92,7 +92,7 @@ fn main() { let _ = stack.self_by_ref(-1, -2); let _ = stack.self_by_val(-3, -4); - let owned = ~Struct { x: 200 }; + let owned = box Struct { x: 200 }; let _ = owned.self_by_ref(-5, -6); let _ = owned.self_by_val(-7, -8); let _ = owned.self_owned(-9, -10); diff --git a/src/test/debug-info/self-in-generic-default-method.rs b/src/test/debug-info/self-in-generic-default-method.rs index 51fb8860761..9e7504be15b 100644 --- a/src/test/debug-info/self-in-generic-default-method.rs +++ b/src/test/debug-info/self-in-generic-default-method.rs @@ -93,7 +93,7 @@ fn main() { let _ = stack.self_by_ref(-1, -2_i8); let _ = stack.self_by_val(-3, -4_i16); - let owned = ~Struct { x: 879 }; + let owned = box Struct { x: 879 }; let _ = owned.self_by_ref(-5, -6_i32); let _ = owned.self_by_val(-7, -8_i64); let _ = owned.self_owned(-9, -10.5_f32); diff --git a/src/test/debug-info/trait-pointers.rs b/src/test/debug-info/trait-pointers.rs index 8d114a3f8dd..fcb0f6082a3 100644 --- a/src/test/debug-info/trait-pointers.rs +++ b/src/test/debug-info/trait-pointers.rs @@ -15,6 +15,7 @@ #![allow(unused_variable)] + trait Trait { fn method(&self) -> int { 0 } } @@ -30,5 +31,5 @@ impl Trait for Struct {} fn main() { let stack_struct = Struct { a:0, b: 1.0 }; let reference: &Trait = &stack_struct as &Trait; - let unique: ~Trait = ~Struct { a:2, b: 3.0 } as ~Trait; + let unique: Box<Trait> = box Struct { a:2, b: 3.0 } as Box<Trait>; } diff --git a/src/test/debug-info/unique-enum.rs b/src/test/debug-info/unique-enum.rs index 1c2cc883285..45f0213bf8c 100644 --- a/src/test/debug-info/unique-enum.rs +++ b/src/test/debug-info/unique-enum.rs @@ -50,15 +50,15 @@ fn main() { // 0b01111100011111000111110001111100 = 2088533116 // 0b0111110001111100 = 31868 // 0b01111100 = 124 - let the_a = ~TheA { x: 0, y: 8970181431921507452 }; + let the_a = box TheA { x: 0, y: 8970181431921507452 }; // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441 // 0b00010001000100010001000100010001 = 286331153 // 0b0001000100010001 = 4369 // 0b00010001 = 17 - let the_b = ~TheB (0, 286331153, 286331153); + let the_b = box TheB (0, 286331153, 286331153); - let univariant = ~TheOnlyCase(123234); + let univariant = box TheOnlyCase(123234); zzz(); } diff --git a/src/test/debug-info/var-captured-in-nested-closure.rs b/src/test/debug-info/var-captured-in-nested-closure.rs index 8dd22e60617..7677c9e9235 100644 --- a/src/test/debug-info/var-captured-in-nested-closure.rs +++ b/src/test/debug-info/var-captured-in-nested-closure.rs @@ -68,7 +68,7 @@ fn main() { }; let struct_ref = &a_struct; - let owned = ~6; + let owned = box 6; let managed = @7; let closure = || { diff --git a/src/test/debug-info/var-captured-in-sendable-closure.rs b/src/test/debug-info/var-captured-in-sendable-closure.rs index 83b26e08975..4316e503a51 100644 --- a/src/test/debug-info/var-captured-in-sendable-closure.rs +++ b/src/test/debug-info/var-captured-in-sendable-closure.rs @@ -39,7 +39,7 @@ fn main() { c: 4 }; - let owned = ~5; + let owned = box 5; let closure: proc() = proc() { zzz(); diff --git a/src/test/debug-info/var-captured-in-stack-closure.rs b/src/test/debug-info/var-captured-in-stack-closure.rs index 4daaf8f7a0e..57dcabe90b6 100644 --- a/src/test/debug-info/var-captured-in-stack-closure.rs +++ b/src/test/debug-info/var-captured-in-stack-closure.rs @@ -48,7 +48,7 @@ fn main() { }; let struct_ref = &a_struct; - let owned = ~6; + let owned = box 6; let managed = @7; let closure = || { diff --git a/src/test/pretty/path-type-bounds.rs b/src/test/pretty/path-type-bounds.rs index 7b09c589320..0fdbad67f16 100644 --- a/src/test/pretty/path-type-bounds.rs +++ b/src/test/pretty/path-type-bounds.rs @@ -10,14 +10,15 @@ // pp-exact + trait Tr { } impl Tr for int { } -fn foo(x: ~Tr: Share) -> ~Tr: Share { x } +fn foo(x: Box<Tr: Share>) -> Box<Tr: Share> { x } fn main() { - let x: ~Tr: Share; + let x: Box<Tr: Share>; - ~1 as ~Tr: Share; + box() 1 as Box<Tr: Share>; } diff --git a/src/test/run-fail/fail-macro-any-wrapped.rs b/src/test/run-fail/fail-macro-any-wrapped.rs index 5a3dda88f70..e1eea1d89b9 100644 --- a/src/test/run-fail/fail-macro-any-wrapped.rs +++ b/src/test/run-fail/fail-macro-any-wrapped.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:failed at '~Any' +// error-pattern:failed at 'Box<Any>' fn main() { - fail!(~612_i64); + fail!(box 612_i64); } diff --git a/src/test/run-fail/fail-macro-any.rs b/src/test/run-fail/fail-macro-any.rs index d812e19e1c8..09b50743308 100644 --- a/src/test/run-fail/fail-macro-any.rs +++ b/src/test/run-fail/fail-macro-any.rs @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:failed at '~Any' +// error-pattern:failed at 'Box<Any>' + fn main() { - fail!(~413 as ~::std::any::Any:Send); + fail!(box 413 as Box<::std::any::Any:Send>); } diff --git a/src/test/run-fail/issue-2272.rs b/src/test/run-fail/issue-2272.rs index c27ddef8711..9ac5790f2b7 100644 --- a/src/test/run-fail/issue-2272.rs +++ b/src/test/run-fail/issue-2272.rs @@ -13,7 +13,8 @@ // error-pattern:explicit failure // Issue #2272 - unwind this without leaking the unique pointer -struct X { y: Y, a: ~int } + +struct X { y: Y, a: Box<int> } struct Y { z: @int } @@ -22,7 +23,7 @@ fn main() { y: Y { z: @0 }, - a: ~0 + a: box 0 }; fail!(); } diff --git a/src/test/run-fail/unique-fail.rs b/src/test/run-fail/unique-fail.rs index 86fde5b7f97..f1804c10691 100644 --- a/src/test/run-fail/unique-fail.rs +++ b/src/test/run-fail/unique-fail.rs @@ -9,4 +9,4 @@ // except according to those terms. // error-pattern: fail -fn main() { ~fail!(); } +fn main() { box fail!(); } diff --git a/src/test/run-fail/unwind-box-fn-unique.rs b/src/test/run-fail/unwind-box-fn-unique.rs index 3fabbdff9b3..50ecedd68fe 100644 --- a/src/test/run-fail/unwind-box-fn-unique.rs +++ b/src/test/run-fail/unwind-box-fn-unique.rs @@ -17,7 +17,7 @@ fn failfn() { } fn main() { - let y = ~0; + let y = box 0; let x: @proc():Send = @(proc() { println!("{:?}", y.clone()); }); diff --git a/src/test/run-fail/unwind-box-res.rs b/src/test/run-fail/unwind-box-res.rs index 2e4ebf5ea34..ecaae7f5cc7 100644 --- a/src/test/run-fail/unwind-box-res.rs +++ b/src/test/run-fail/unwind-box-res.rs @@ -25,7 +25,7 @@ struct r { impl Drop for r { fn drop(&mut self) { unsafe { - let _v2: ~int = cast::transmute(self.v); + let _v2: Box<int> = cast::transmute(self.v); } } } @@ -38,7 +38,7 @@ fn r(v: *int) -> r { fn main() { unsafe { - let i1 = ~0; + let i1 = box 0; let i1p = cast::transmute_copy(&i1); cast::forget(i1); let x = @r(i1p); diff --git a/src/test/run-fail/unwind-box-unique-unique.rs b/src/test/run-fail/unwind-box-unique-unique.rs index dcfaccf5ab7..82da2bc6ca3 100644 --- a/src/test/run-fail/unwind-box-unique-unique.rs +++ b/src/test/run-fail/unwind-box-unique-unique.rs @@ -12,12 +12,13 @@ #![feature(managed_boxes)] + fn failfn() { fail!(); } fn main() { - let x = @~~0; + let x = @box box 0; failfn(); println!("{:?}", x); } diff --git a/src/test/run-fail/unwind-box-unique.rs b/src/test/run-fail/unwind-box-unique.rs index bfe72835f45..99adaaad314 100644 --- a/src/test/run-fail/unwind-box-unique.rs +++ b/src/test/run-fail/unwind-box-unique.rs @@ -17,7 +17,7 @@ fn failfn() { } fn main() { - let x = @~0; + let x = @box 0; failfn(); println!("{:?}", x); } diff --git a/src/test/run-fail/unwind-partial-unique.rs b/src/test/run-fail/unwind-partial-unique.rs index f265655e0ef..8d5fcfff963 100644 --- a/src/test/run-fail/unwind-partial-unique.rs +++ b/src/test/run-fail/unwind-partial-unique.rs @@ -22,7 +22,7 @@ fn prime() { } fn partial() { - let _x = ~f(); + let _x = box f(); } fn main() { diff --git a/src/test/run-fail/unwind-unique.rs b/src/test/run-fail/unwind-unique.rs index 53b2a55602c..af1e499d1f2 100644 --- a/src/test/run-fail/unwind-unique.rs +++ b/src/test/run-fail/unwind-unique.rs @@ -10,11 +10,12 @@ // error-pattern:fail + fn failfn() { fail!(); } fn main() { - ~0; + box 0; failfn(); } diff --git a/src/test/run-pass/alignment-gep-tup-like-1.rs b/src/test/run-pass/alignment-gep-tup-like-1.rs index 2c71d791cd4..0af2be8ab29 100644 --- a/src/test/run-pass/alignment-gep-tup-like-1.rs +++ b/src/test/run-pass/alignment-gep-tup-like-1.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct pair<A,B> { a: A, b: B } @@ -27,11 +28,11 @@ impl<A:Clone> Invokable<A> for Invoker<A> { } } -fn f<A:Clone + 'static>(a: A, b: u16) -> ~Invokable<A>: { - ~Invoker { +fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>:> { + box Invoker { a: a, b: b, - } as ~Invokable<A>: + } as Box<Invokable<A>>: } pub fn main() { diff --git a/src/test/run-pass/assert-eq-macro-success.rs b/src/test/run-pass/assert-eq-macro-success.rs index 1e0418d8806..4aea57871b9 100644 --- a/src/test/run-pass/assert-eq-macro-success.rs +++ b/src/test/run-pass/assert-eq-macro-success.rs @@ -14,7 +14,7 @@ struct Point { x : int } pub fn main() { assert_eq!(14,14); assert_eq!("abc".to_owned(),"abc".to_owned()); - assert_eq!(~Point{x:34},~Point{x:34}); + assert_eq!(box Point{x:34},box Point{x:34}); assert_eq!(&Point{x:34},&Point{x:34}); assert_eq!(@Point{x:34},@Point{x:34}); } diff --git a/src/test/run-pass/auto-ref-slice-plus-ref.rs b/src/test/run-pass/auto-ref-slice-plus-ref.rs index 2c3e6c6f04e..626f19b5108 100644 --- a/src/test/run-pass/auto-ref-slice-plus-ref.rs +++ b/src/test/run-pass/auto-ref-slice-plus-ref.rs @@ -26,8 +26,6 @@ impl<'a> MyIter for &'a str { } pub fn main() { - // NB: Associativity of ~, etc. in this context is surprising. These must be parenthesized - ([1]).test_imm(); (vec!(1)).as_slice().test_imm(); (&[1]).test_imm(); diff --git a/src/test/run-pass/autoderef-method-on-trait.rs b/src/test/run-pass/autoderef-method-on-trait.rs index 6f0bba72025..e50825a401f 100644 --- a/src/test/run-pass/autoderef-method-on-trait.rs +++ b/src/test/run-pass/autoderef-method-on-trait.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait double { fn double(~self) -> uint; } @@ -17,6 +18,6 @@ impl double for uint { } pub fn main() { - let x = ~(~3u as ~double); + let x = box() (box 3u as Box<double>); assert_eq!(x.double(), 6u); } diff --git a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs index a03ac80a3f1..7acd54788a8 100644 --- a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs +++ b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs @@ -8,15 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait double { fn double(~self) -> uint; } -impl double for ~uint { +impl double for Box<uint> { fn double(~self) -> uint { **self * 2u } } pub fn main() { - let x = ~~~~~3u; + let x = box box box box box 3u; assert_eq!(x.double(), 6u); } diff --git a/src/test/run-pass/autoderef-method-twice.rs b/src/test/run-pass/autoderef-method-twice.rs index 7835eaae510..a8b6b6f74f4 100644 --- a/src/test/run-pass/autoderef-method-twice.rs +++ b/src/test/run-pass/autoderef-method-twice.rs @@ -17,6 +17,6 @@ impl double for uint { } pub fn main() { - let x = ~~3u; + let x = box box 3u; assert_eq!(x.double(), 6u); } diff --git a/src/test/run-pass/autoderef-method.rs b/src/test/run-pass/autoderef-method.rs index 81469e5454a..4c4ebdc94f0 100644 --- a/src/test/run-pass/autoderef-method.rs +++ b/src/test/run-pass/autoderef-method.rs @@ -17,6 +17,6 @@ impl double for uint { } pub fn main() { - let x = ~3u; + let x = box 3u; assert_eq!(x.double(), 6u); } diff --git a/src/test/run-pass/bitv-perf-test.rs b/src/test/run-pass/bitv-perf-test.rs index 658c888b8d8..0f114969420 100644 --- a/src/test/run-pass/bitv-perf-test.rs +++ b/src/test/run-pass/bitv-perf-test.rs @@ -13,8 +13,8 @@ extern crate collections; use collections::Bitv; fn bitv_test() { - let mut v1 = ~Bitv::new(31, false); - let v2 = ~Bitv::new(31, true); + let mut v1 = box Bitv::new(31, false); + let v2 = box Bitv::new(31, true); v1.union(v2); } diff --git a/src/test/run-pass/borrowck-borrow-from-expr-block.rs b/src/test/run-pass/borrowck-borrow-from-expr-block.rs index 66b9d0430a1..2db2f8c16e0 100644 --- a/src/test/run-pass/borrowck-borrow-from-expr-block.rs +++ b/src/test/run-pass/borrowck-borrow-from-expr-block.rs @@ -10,11 +10,12 @@ #![feature(managed_boxes)] + fn borrow(x: &int, f: |x: &int|) { f(x) } -fn test1(x: @~int) { +fn test1(x: @Box<int>) { borrow(&*(*x).clone(), |p| { let x_a = &**x as *int; assert!((x_a as uint) != (p as *int as uint)); @@ -23,5 +24,5 @@ fn test1(x: @~int) { } pub fn main() { - test1(@~22); + test1(@box 22); } diff --git a/src/test/run-pass/borrowck-lend-args.rs b/src/test/run-pass/borrowck-lend-args.rs index a912e1ef65c..68d1b74e201 100644 --- a/src/test/run-pass/borrowck-lend-args.rs +++ b/src/test/run-pass/borrowck-lend-args.rs @@ -8,17 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + fn borrow(_v: &int) {} -fn borrow_from_arg_imm_ref(v: ~int) { +fn borrow_from_arg_imm_ref(v: Box<int>) { borrow(v); } -fn borrow_from_arg_mut_ref(v: &mut ~int) { +fn borrow_from_arg_mut_ref(v: &mut Box<int>) { borrow(*v); } -fn borrow_from_arg_copy(v: ~int) { +fn borrow_from_arg_copy(v: Box<int>) { borrow(v); } diff --git a/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs b/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs index 881a5b4d3f6..10835730fa5 100644 --- a/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs +++ b/src/test/run-pass/borrowck-macro-interaction-issue-6304.rs @@ -13,24 +13,25 @@ #![feature(macro_rules)] + struct Foo { a: int } pub enum Bar { - Bar1, Bar2(int, ~Bar), + Bar1, Bar2(int, Box<Bar>), } impl Foo { - fn elaborate_stm(&mut self, s: ~Bar) -> ~Bar { + fn elaborate_stm(&mut self, s: Box<Bar>) -> Box<Bar> { macro_rules! declare( ($id:expr, $rest:expr) => ({ self.check_id($id); - ~Bar2($id, $rest) + box Bar2($id, $rest) }) ); match s { - ~Bar2(id, rest) => declare!(id, self.elaborate_stm(rest)), + box Bar2(id, rest) => declare!(id, self.elaborate_stm(rest)), _ => fail!() } } diff --git a/src/test/run-pass/borrowck-move-by-capture-ok.rs b/src/test/run-pass/borrowck-move-by-capture-ok.rs index 8ceef830948..48ddf927722 100644 --- a/src/test/run-pass/borrowck-move-by-capture-ok.rs +++ b/src/test/run-pass/borrowck-move-by-capture-ok.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let bar = ~3; + let bar = box 3; let h: proc() -> int = proc() *bar; assert_eq!(h(), 3); } diff --git a/src/test/run-pass/borrowck-mut-uniq.rs b/src/test/run-pass/borrowck-mut-uniq.rs index bed6fcd0091..ea849ee9829 100644 --- a/src/test/run-pass/borrowck-mut-uniq.rs +++ b/src/test/run-pass/borrowck-mut-uniq.rs @@ -10,7 +10,7 @@ use std::mem::swap; -struct Ints {sum: ~int, values: Vec<int> } +struct Ints {sum: Box<int>, values: Vec<int> } fn add_int(x: &mut Ints, v: int) { *x.sum += v; @@ -26,7 +26,7 @@ fn iter_ints(x: &Ints, f: |x: &int| -> bool) -> bool { } pub fn main() { - let mut ints = ~Ints {sum: ~0, values: Vec::new()}; + let mut ints = box Ints {sum: box 0, values: Vec::new()}; add_int(ints, 22); add_int(ints, 44); diff --git a/src/test/run-pass/borrowck-uniq-via-ref.rs b/src/test/run-pass/borrowck-uniq-via-ref.rs index d50b4f15f4e..451f9ccf5bd 100644 --- a/src/test/run-pass/borrowck-uniq-via-ref.rs +++ b/src/test/run-pass/borrowck-uniq-via-ref.rs @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct Rec { - f: ~int, + f: Box<int>, } struct Outer { @@ -21,12 +22,12 @@ struct Inner { } struct Innermost { - h: ~int, + h: Box<int>, } fn borrow(_v: &int) {} -fn box_mut(v: &mut ~int) { +fn box_mut(v: &mut Box<int>) { borrow(*v); // OK: &mut -> &imm } @@ -38,7 +39,7 @@ fn box_mut_recs(v: &mut Outer) { borrow(v.f.g.h); // OK: &mut -> &imm } -fn box_imm(v: &~int) { +fn box_imm(v: &Box<int>) { borrow(*v); // OK } diff --git a/src/test/run-pass/cancel-clean-via-immediate-rvalue-ref.rs b/src/test/run-pass/cancel-clean-via-immediate-rvalue-ref.rs index 2b9e97be2c7..d326c20707d 100644 --- a/src/test/run-pass/cancel-clean-via-immediate-rvalue-ref.rs +++ b/src/test/run-pass/cancel-clean-via-immediate-rvalue-ref.rs @@ -8,10 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo(x: &mut ~u8) { - *x = ~5; + +fn foo(x: &mut Box<u8>) { + *x = box 5; } pub fn main() { - foo(&mut ~4); + foo(&mut box 4); } diff --git a/src/test/run-pass/capturing-logging.rs b/src/test/run-pass/capturing-logging.rs index 3859ed3a53d..e0e60289f9d 100644 --- a/src/test/run-pass/capturing-logging.rs +++ b/src/test/run-pass/capturing-logging.rs @@ -17,9 +17,9 @@ extern crate log; extern crate native; +use log::{set_logger, Logger, LogRecord}; use std::fmt; use std::io::{ChanReader, ChanWriter}; -use log::{set_logger, Logger, LogRecord}; struct MyWriter(ChanWriter); @@ -41,7 +41,7 @@ fn main() { let (tx, rx) = channel(); let (mut r, w) = (ChanReader::new(rx), ChanWriter::new(tx)); spawn(proc() { - set_logger(~MyWriter(w) as ~Logger:Send); + set_logger(box MyWriter(w) as Box<Logger:Send>); debug!("debug"); info!("info"); }); diff --git a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs index 85c3c5d518e..c6c78283e19 100644 --- a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs +++ b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs @@ -10,16 +10,17 @@ // aux-build:cci_class_cast.rs extern crate cci_class_cast; + use std::to_str::ToStr; use cci_class_cast::kitty::cat; -fn print_out(thing: ~ToStr, expected: ~str) { +fn print_out(thing: Box<ToStr>, expected: ~str) { let actual = thing.to_str(); println!("{}", actual); assert_eq!(actual, expected); } pub fn main() { - let nyan: ~ToStr = ~cat(0u, 2, "nyan".to_owned()) as ~ToStr; + let nyan: Box<ToStr> = box cat(0u, 2, "nyan".to_owned()) as Box<ToStr>; print_out(nyan, "nyan".to_owned()); } diff --git a/src/test/run-pass/class-separate-impl.rs b/src/test/run-pass/class-separate-impl.rs index 0f1e8aa2724..417c927701d 100644 --- a/src/test/run-pass/class-separate-impl.rs +++ b/src/test/run-pass/class-separate-impl.rs @@ -57,13 +57,13 @@ impl fmt::Show for cat { } } -fn print_out(thing: ~ToStr, expected: ~str) { +fn print_out(thing: Box<ToStr>, expected: ~str) { let actual = thing.to_str(); println!("{}", actual); assert_eq!(actual, expected); } pub fn main() { - let nyan: ~ToStr = ~cat(0u, 2, "nyan".to_owned()) as ~ToStr; + let nyan: Box<ToStr> = box cat(0u, 2, "nyan".to_owned()) as Box<ToStr>; print_out(nyan, "nyan".to_owned()); } diff --git a/src/test/run-pass/cleanup-arm-conditional.rs b/src/test/run-pass/cleanup-arm-conditional.rs index 360f94564b7..65ad68ba702 100644 --- a/src/test/run-pass/cleanup-arm-conditional.rs +++ b/src/test/run-pass/cleanup-arm-conditional.rs @@ -26,8 +26,8 @@ use std::os; struct Test { x: int } impl Test { - fn get_x(&self) -> Option<~int> { - Some(~self.x) + fn get_x(&self) -> Option<Box<int>> { + Some(box self.x) } } diff --git a/src/test/run-pass/cleanup-rvalue-during-if-and-while.rs b/src/test/run-pass/cleanup-rvalue-during-if-and-while.rs index 1ae907065bf..89b00102081 100644 --- a/src/test/run-pass/cleanup-rvalue-during-if-and-while.rs +++ b/src/test/run-pass/cleanup-rvalue-during-if-and-while.rs @@ -12,6 +12,7 @@ // This test verifies that temporaries created for `while`'s and `if` // conditions are dropped after the condition is evaluated. + struct Temporary; static mut DROPPED: int = 0; @@ -26,7 +27,7 @@ impl Temporary { fn do_stuff(&self) -> bool {true} } -fn borrow() -> ~Temporary { ~Temporary } +fn borrow() -> Box<Temporary> { box Temporary } pub fn main() { diff --git a/src/test/run-pass/cleanup-rvalue-scopes.rs b/src/test/run-pass/cleanup-rvalue-scopes.rs index f6f0da745ab..470e16b4888 100644 --- a/src/test/run-pass/cleanup-rvalue-scopes.rs +++ b/src/test/run-pass/cleanup-rvalue-scopes.rs @@ -111,8 +111,8 @@ pub fn main() { end_of_block!(AddFlags { bits: ref _x }, AddFlags(1)); end_of_block!(&AddFlags { bits }, &AddFlags(1)); end_of_block!((_, ref _y), (AddFlags(1), 22)); - end_of_block!(~ref _x, ~AddFlags(1)); - end_of_block!(~_x, ~AddFlags(1)); + end_of_block!(box ref _x, box AddFlags(1)); + end_of_block!(box _x, box AddFlags(1)); end_of_block!(_, { { check_flags(0); &AddFlags(1) } }); end_of_block!(_, &((Box { f: AddFlags(1) }).f)); end_of_block!(_, &(([AddFlags(1)])[0])); diff --git a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs index 8c906bf96b6..fda4a31375b 100644 --- a/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs +++ b/src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs @@ -8,16 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test cleanup of rvalue temporary that occurs while `~` construction +// Test cleanup of rvalue temporary that occurs while `box` construction // is in progress. This scenario revealed a rather terrible bug. The // ingredients are: // -// 1. Partial cleanup of `~` is in scope, +// 1. Partial cleanup of `box` is in scope, // 2. cleanup of return value from `get_bar()` is in scope, // 3. do_it() fails. // // This led to a bug because `the top-most frame that was to be -// cleaned (which happens to be the partial cleanup of `~`) required +// cleaned (which happens to be the partial cleanup of `box`) required // multiple basic blocks, which led to us dropping part of the cleanup // from the top-most frame. // @@ -30,7 +30,7 @@ enum Conzabble { Bickwick(Foo) } -struct Foo { field: ~uint } +struct Foo { field: Box<uint> } fn do_it(x: &[uint]) -> Foo { fail!() @@ -41,7 +41,7 @@ fn get_bar(x: uint) -> Vec<uint> { vec!(x * 2) } pub fn fails() { let x = 2; let mut y = Vec::new(); - y.push(~Bickwick(do_it(get_bar(x).as_slice()))); + y.push(box Bickwick(do_it(get_bar(x).as_slice()))); } pub fn main() { diff --git a/src/test/run-pass/clone-with-exterior.rs b/src/test/run-pass/clone-with-exterior.rs index 038c0418ecb..f676a6f0959 100644 --- a/src/test/run-pass/clone-with-exterior.rs +++ b/src/test/run-pass/clone-with-exterior.rs @@ -16,7 +16,7 @@ struct Pair { } pub fn main() { - let z = ~Pair { a : 10, b : 12}; + let z = box Pair { a : 10, b : 12}; let f: proc():Send = proc() { assert_eq!(z.a, 10); diff --git a/src/test/run-pass/close-over-big-then-small-data.rs b/src/test/run-pass/close-over-big-then-small-data.rs index c57b6fdf384..3e14d5b82c4 100644 --- a/src/test/run-pass/close-over-big-then-small-data.rs +++ b/src/test/run-pass/close-over-big-then-small-data.rs @@ -12,6 +12,7 @@ // storing closure data (as we used to do), the u64 would // overwrite the u16. + struct Pair<A,B> { a: A, b: B } @@ -31,11 +32,11 @@ impl<A:Clone> Invokable<A> for Invoker<A> { } } -fn f<A:Clone + 'static>(a: A, b: u16) -> ~Invokable<A>: { - ~Invoker { +fn f<A:Clone + 'static>(a: A, b: u16) -> Box<Invokable<A>:> { + box Invoker { a: a, b: b, - } as ~Invokable<A>: + } as Box<Invokable<A>>: } pub fn main() { diff --git a/src/test/run-pass/const-bound.rs b/src/test/run-pass/const-bound.rs index ff47f078da3..c864db33b21 100644 --- a/src/test/run-pass/const-bound.rs +++ b/src/test/run-pass/const-bound.rs @@ -23,5 +23,5 @@ pub fn main() { foo(F{field: 42}); foo((1, 2u)); foo(@1);*/ - foo(~1); + foo(box 1); } diff --git a/src/test/run-pass/empty-allocation-non-null.rs b/src/test/run-pass/empty-allocation-non-null.rs index 9695296ec15..a6baf21549e 100644 --- a/src/test/run-pass/empty-allocation-non-null.rs +++ b/src/test/run-pass/empty-allocation-non-null.rs @@ -9,10 +9,10 @@ // except according to those terms. pub fn main() { - assert!(Some(~()).is_some()); + assert!(Some(box() ()).is_some()); struct Foo; - assert!(Some(~Foo).is_some()); + assert!(Some(box Foo).is_some()); let xs: ~[()] = ~[]; assert!(Some(xs).is_some()); diff --git a/src/test/run-pass/empty-allocation-rvalue-non-null.rs b/src/test/run-pass/empty-allocation-rvalue-non-null.rs index a5fc8425cf6..96c5f81558e 100644 --- a/src/test/run-pass/empty-allocation-rvalue-non-null.rs +++ b/src/test/run-pass/empty-allocation-rvalue-non-null.rs @@ -9,5 +9,5 @@ // except according to those terms. pub fn main() { - let x = *~(); + let x = *box() (); } diff --git a/src/test/run-pass/enum-nullable-const-null-with-fields.rs b/src/test/run-pass/enum-nullable-const-null-with-fields.rs index 5defd837022..a48f3bcd59c 100644 --- a/src/test/run-pass/enum-nullable-const-null-with-fields.rs +++ b/src/test/run-pass/enum-nullable-const-null-with-fields.rs @@ -9,7 +9,8 @@ // except according to those terms. use std::result::{Result,Ok}; -static C: Result<(), ~int> = Ok(()); + +static C: Result<(), Box<int>> = Ok(()); // This is because of yet another bad assertion (ICE) about the null side of a nullable enum. // So we won't actually compile if the bug is present, but we check the value in main anyway. diff --git a/src/test/run-pass/explicit-self-generic.rs b/src/test/run-pass/explicit-self-generic.rs index 30b716f75d8..ac2922e92d4 100644 --- a/src/test/run-pass/explicit-self-generic.rs +++ b/src/test/run-pass/explicit-self-generic.rs @@ -37,6 +37,6 @@ impl<K,V> HashMap<K,V> { } pub fn main() { - let mut m = ~linear_map::<(),()>(); + let mut m = box linear_map::<(),()>(); assert_eq!(m.len(), 0); } diff --git a/src/test/run-pass/explicit-self-objects-uniq.rs b/src/test/run-pass/explicit-self-objects-uniq.rs index 69ca98eb018..595bb4f6b9e 100644 --- a/src/test/run-pass/explicit-self-objects-uniq.rs +++ b/src/test/run-pass/explicit-self-objects-uniq.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait Foo { fn f(~self); } @@ -23,7 +24,7 @@ impl Foo for S { } pub fn main() { - let x = ~S { x: 3 }; - let y = x as ~Foo; + let x = box S { x: 3 }; + let y = x as Box<Foo>; y.f(); } diff --git a/src/test/run-pass/explicit-self.rs b/src/test/run-pass/explicit-self.rs index 1076fc1662f..6c2e17046d3 100644 --- a/src/test/run-pass/explicit-self.rs +++ b/src/test/run-pass/explicit-self.rs @@ -67,7 +67,7 @@ trait Nus { fn f(&self); } impl Nus for thing { fn f(&self) {} } pub fn main() { - let y = ~thing(A {a: 10}); + let y = box thing(A {a: 10}); assert_eq!(y.clone().bar(), 10); assert_eq!(y.quux(), 10); diff --git a/src/test/run-pass/expr-block-generic-unique1.rs b/src/test/run-pass/expr-block-generic-unique1.rs index 95f3ff62d26..ec5013122ac 100644 --- a/src/test/run-pass/expr-block-generic-unique1.rs +++ b/src/test/run-pass/expr-block-generic-unique1.rs @@ -9,21 +9,20 @@ // except according to those terms. +type compare<'a, T> = |Box<T>, Box<T>|: 'a -> bool; -type compare<'a, T> = |~T, ~T|: 'a -> bool; - -fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) { - let actual: ~T = { expected.clone() }; +fn test_generic<T:Clone>(expected: Box<T>, eq: compare<T>) { + let actual: Box<T> = { expected.clone() }; assert!((eq(expected, actual))); } fn test_box() { - fn compare_box(b1: ~bool, b2: ~bool) -> bool { + fn compare_box(b1: Box<bool>, b2: Box<bool>) -> bool { println!("{}", *b1); println!("{}", *b2); return *b1 == *b2; } - test_generic::<bool>(~true, compare_box); + test_generic::<bool>(box true, compare_box); } pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-block-generic-unique2.rs b/src/test/run-pass/expr-block-generic-unique2.rs index f45312f9e09..48e27dc449c 100644 --- a/src/test/run-pass/expr-block-generic-unique2.rs +++ b/src/test/run-pass/expr-block-generic-unique2.rs @@ -17,8 +17,8 @@ fn test_generic<T:Clone>(expected: T, eq: compare<T>) { } fn test_vec() { - fn compare_vec(v1: ~int, v2: ~int) -> bool { return v1 == v2; } - test_generic::<~int>(~1, compare_vec); + fn compare_vec(v1: Box<int>, v2: Box<int>) -> bool { return v1 == v2; } + test_generic::<Box<int>>(box 1, compare_vec); } pub fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-block-unique.rs b/src/test/run-pass/expr-block-unique.rs index 6ef7ffe86fa..12777bce710 100644 --- a/src/test/run-pass/expr-block-unique.rs +++ b/src/test/run-pass/expr-block-unique.rs @@ -11,4 +11,4 @@ -pub fn main() { let x = { ~100 }; assert!((*x == 100)); } +pub fn main() { let x = { box 100 }; assert!((*x == 100)); } diff --git a/src/test/run-pass/expr-if-unique.rs b/src/test/run-pass/expr-if-unique.rs index b40dc03ccfb..aa96a93cdb3 100644 --- a/src/test/run-pass/expr-if-unique.rs +++ b/src/test/run-pass/expr-if-unique.rs @@ -14,7 +14,7 @@ // Tests for if as expressions returning boxed types fn test_box() { - let rs = if true { ~100 } else { ~101 }; + let rs = if true { box 100 } else { box 101 }; assert_eq!(*rs, 100); } diff --git a/src/test/run-pass/expr-match-generic-unique1.rs b/src/test/run-pass/expr-match-generic-unique1.rs index 991a1f449f1..e2f8f7c8ebf 100644 --- a/src/test/run-pass/expr-match-generic-unique1.rs +++ b/src/test/run-pass/expr-match-generic-unique1.rs @@ -9,11 +9,10 @@ // except according to those terms. +type compare<T> = |Box<T>, Box<T>|: 'static -> bool; -type compare<T> = |~T, ~T|: 'static -> bool; - -fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) { - let actual: ~T = match true { +fn test_generic<T:Clone>(expected: Box<T>, eq: compare<T>) { + let actual: Box<T> = match true { true => { expected.clone() }, _ => fail!("wat") }; @@ -21,8 +20,10 @@ fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) { } fn test_box() { - fn compare_box(b1: ~bool, b2: ~bool) -> bool { return *b1 == *b2; } - test_generic::<bool>(~true, compare_box); + fn compare_box(b1: Box<bool>, b2: Box<bool>) -> bool { + return *b1 == *b2; + } + test_generic::<bool>(box true, compare_box); } pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-match-generic-unique2.rs b/src/test/run-pass/expr-match-generic-unique2.rs index d229672d057..a9b02a6e799 100644 --- a/src/test/run-pass/expr-match-generic-unique2.rs +++ b/src/test/run-pass/expr-match-generic-unique2.rs @@ -20,8 +20,8 @@ fn test_generic<T:Clone>(expected: T, eq: compare<T>) { } fn test_vec() { - fn compare_box(v1: ~int, v2: ~int) -> bool { return v1 == v2; } - test_generic::<~int>(~1, compare_box); + fn compare_box(v1: Box<int>, v2: Box<int>) -> bool { return v1 == v2; } + test_generic::<Box<int>>(box 1, compare_box); } pub fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-match-unique.rs b/src/test/run-pass/expr-match-unique.rs index 85c6652c5aa..ca6e8799eae 100644 --- a/src/test/run-pass/expr-match-unique.rs +++ b/src/test/run-pass/expr-match-unique.rs @@ -9,12 +9,9 @@ // except according to those terms. - - - // Tests for match as expressions resulting in boxed types fn test_box() { - let res = match true { true => { ~100 }, _ => fail!() }; + let res = match true { true => { box 100 }, _ => fail!() }; assert_eq!(*res, 100); } diff --git a/src/test/run-pass/fsu-moves-and-copies.rs b/src/test/run-pass/fsu-moves-and-copies.rs index 571ef4bd7b4..0e6b857d7cf 100644 --- a/src/test/run-pass/fsu-moves-and-copies.rs +++ b/src/test/run-pass/fsu-moves-and-copies.rs @@ -21,9 +21,9 @@ impl NoFoo { fn new(x:int,y:int) -> NoFoo { NoFoo { copied: x, nocopy: ncint(y) } } } -struct MoveFoo { copied: int, moved: ~int, } +struct MoveFoo { copied: int, moved: Box<int>, } impl MoveFoo { - fn new(x:int,y:int) -> MoveFoo { MoveFoo { copied: x, moved: ~y } } + fn new(x:int,y:int) -> MoveFoo { MoveFoo { copied: x, moved: box y } } } struct DropNoFoo { inner: NoFoo } @@ -59,8 +59,8 @@ fn test0() { // Case 2: Owned let f = DropMoveFoo::new(5, 6); - let b = DropMoveFoo { inner: MoveFoo { moved: ~7, ..f.inner }}; - let c = DropMoveFoo { inner: MoveFoo { moved: ~8, ..f.inner }}; + let b = DropMoveFoo { inner: MoveFoo { moved: box 7, ..f.inner }}; + let c = DropMoveFoo { inner: MoveFoo { moved: box 8, ..f.inner }}; assert_eq!(f.inner.copied, 5); assert_eq!(*f.inner.moved, 6); @@ -75,7 +75,7 @@ fn test1() { // copying move-by-default fields from `f`, so it moves: let f = MoveFoo::new(11, 12); - let b = MoveFoo {moved: ~13, ..f}; + let b = MoveFoo {moved: box 13, ..f}; let c = MoveFoo {copied: 14, ..f}; assert_eq!(b.copied, 11); assert_eq!(*b.moved, 13); diff --git a/src/test/run-pass/func-arg-incomplete-pattern.rs b/src/test/run-pass/func-arg-incomplete-pattern.rs index 6dc9ef2fa4b..5ab3930e7a3 100644 --- a/src/test/run-pass/func-arg-incomplete-pattern.rs +++ b/src/test/run-pass/func-arg-incomplete-pattern.rs @@ -11,9 +11,10 @@ // Test that we do not leak when the arg pattern must drop part of the // argument (in this case, the `y` field). + struct Foo { - x: ~uint, - y: ~uint, + x: Box<uint>, + y: Box<uint>, } fn foo(Foo {x, ..}: Foo) -> *uint { @@ -22,9 +23,9 @@ fn foo(Foo {x, ..}: Foo) -> *uint { } pub fn main() { - let obj = ~1; + let obj = box 1; let objptr: *uint = &*obj; - let f = Foo {x: obj, y: ~2}; + let f = Foo {x: obj, y: box 2}; let xptr = foo(f); assert_eq!(objptr, xptr); } diff --git a/src/test/run-pass/func-arg-ref-pattern.rs b/src/test/run-pass/func-arg-ref-pattern.rs index 11df22d7433..bb4be948a5e 100644 --- a/src/test/run-pass/func-arg-ref-pattern.rs +++ b/src/test/run-pass/func-arg-ref-pattern.rs @@ -10,25 +10,26 @@ // exec-env:RUST_POISON_ON_FREE=1 -// Test argument patterns where we create refs to the inside of `~` +// Test argument patterns where we create refs to the inside of // boxes. Make sure that we don't free the box as we match the // pattern. -fn getaddr(~ref x: ~uint) -> *uint { + +fn getaddr(box ref x: Box<uint>) -> *uint { let addr: *uint = &*x; addr } -fn checkval(~ref x: ~uint) -> uint { +fn checkval(box ref x: Box<uint>) -> uint { *x } pub fn main() { - let obj = ~1; + let obj = box 1; let objptr: *uint = &*obj; let xptr = getaddr(obj); assert_eq!(objptr, xptr); - let obj = ~22; + let obj = box 22; assert_eq!(checkval(obj), 22); } diff --git a/src/test/run-pass/generic-alias-unique.rs b/src/test/run-pass/generic-alias-unique.rs index 898d0c0ec23..f1338358903 100644 --- a/src/test/run-pass/generic-alias-unique.rs +++ b/src/test/run-pass/generic-alias-unique.rs @@ -9,12 +9,11 @@ // except according to those terms. - fn id<T:Send>(t: T) -> T { return t; } pub fn main() { - let expected = ~100; - let actual = id::<~int>(expected.clone()); + let expected = box 100; + let actual = id::<Box<int>>(expected.clone()); println!("{:?}", *actual); assert_eq!(*expected, *actual); } diff --git a/src/test/run-pass/generic-exterior-unique.rs b/src/test/run-pass/generic-exterior-unique.rs index 0820923efcf..0746c994c2a 100644 --- a/src/test/run-pass/generic-exterior-unique.rs +++ b/src/test/run-pass/generic-exterior-unique.rs @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Recbox<T> {x: ~T} -fn reclift<T>(t: T) -> Recbox<T> { return Recbox {x: ~t}; } +struct Recbox<T> {x: Box<T>} + +fn reclift<T>(t: T) -> Recbox<T> { return Recbox {x: box t}; } pub fn main() { let foo: int = 17; diff --git a/src/test/run-pass/generic-fn-unique.rs b/src/test/run-pass/generic-fn-unique.rs index c27aff53b67..c0b3fd5bc94 100644 --- a/src/test/run-pass/generic-fn-unique.rs +++ b/src/test/run-pass/generic-fn-unique.rs @@ -9,6 +9,6 @@ // except according to those terms. -fn f<T>(x: ~T) -> ~T { return x; } +fn f<T>(x: Box<T>) -> Box<T> { return x; } -pub fn main() { let x = f(~3); println!("{:?}", *x); } +pub fn main() { let x = f(box 3); println!("{:?}", *x); } diff --git a/src/test/run-pass/generic-object.rs b/src/test/run-pass/generic-object.rs index 76db4a01829..d0a5af8e2ce 100644 --- a/src/test/run-pass/generic-object.rs +++ b/src/test/run-pass/generic-object.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait Foo<T> { fn get(&self) -> T; } @@ -23,7 +24,7 @@ impl Foo<int> for S { } pub fn main() { - let x = ~S { x: 1 }; - let y = x as ~Foo<int>; + let x = box S { x: 1 }; + let y = x as Box<Foo<int>>; assert_eq!(y.get(), 1); } diff --git a/src/test/run-pass/generic-unique.rs b/src/test/run-pass/generic-unique.rs index 3b817b314cf..4821b9354bf 100644 --- a/src/test/run-pass/generic-unique.rs +++ b/src/test/run-pass/generic-unique.rs @@ -8,11 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct Triple<T> { x: T, y: T, z: T } -fn box_it<T>(x: Triple<T>) -> ~Triple<T> { return ~x; } +fn box_it<T>(x: Triple<T>) -> Box<Triple<T>> { return box x; } pub fn main() { - let x: ~Triple<int> = box_it::<int>(Triple{x: 1, y: 2, z: 3}); + let x: Box<Triple<int>> = box_it::<int>(Triple{x: 1, y: 2, z: 3}); assert_eq!(x.y, 2); } diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 16b21f5f537..9227477c31e 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -40,7 +40,7 @@ pub fn main() { t!(format!("{:?}", 1), "1"); t!(format!("{:?}", A), "A"); t!(format!("{:?}", ()), "()"); - t!(format!("{:?}", @(~1, "foo")), "@(~1, \"foo\")"); + t!(format!("{:?}", @(box 1, "foo")), "@(box 1, \"foo\")"); // Various edge cases without formats t!(format!(""), ""); @@ -142,7 +142,7 @@ pub fn main() { test_order(); // make sure that format! doesn't move out of local variables - let a = ~3; + let a = box 3; format!("{:?}", a); format!("{:?}", a); diff --git a/src/test/run-pass/init-res-into-things.rs b/src/test/run-pass/init-res-into-things.rs index 4c1455e25cb..c573ca91840 100644 --- a/src/test/run-pass/init-res-into-things.rs +++ b/src/test/run-pass/init-res-into-things.rs @@ -73,7 +73,7 @@ fn test_tup() { fn test_unique() { let i = @Cell::new(0); { - let _a = ~r(i); + let _a = box r(i); } assert_eq!(i.get(), 1); } diff --git a/src/test/run-pass/intrinsic-atomics.rs b/src/test/run-pass/intrinsic-atomics.rs index b663cbfa509..8fa89303fa9 100644 --- a/src/test/run-pass/intrinsic-atomics.rs +++ b/src/test/run-pass/intrinsic-atomics.rs @@ -36,7 +36,7 @@ mod rusti { pub fn main() { unsafe { - let mut x = ~1; + let mut x = box 1; assert_eq!(rusti::atomic_load(&*x), 1); *x = 5; diff --git a/src/test/run-pass/intrinsic-move-val.rs b/src/test/run-pass/intrinsic-move-val.rs index f42d5ff2e52..5f5c1444819 100644 --- a/src/test/run-pass/intrinsic-move-val.rs +++ b/src/test/run-pass/intrinsic-move-val.rs @@ -19,7 +19,7 @@ mod rusti { pub fn main() { unsafe { - let x = ~1; + let x = box 1; let mut y = rusti::init(); let mut z: *uint = transmute(&x); rusti::move_val_init(&mut y, x); diff --git a/src/test/run-pass/issue-10682.rs b/src/test/run-pass/issue-10682.rs index 461167d5ea4..f2f8b17daa2 100644 --- a/src/test/run-pass/issue-10682.rs +++ b/src/test/run-pass/issue-10682.rs @@ -11,10 +11,11 @@ // Regression test for issue #10682 // Nested `proc` usage can't use outer owned data -fn work(_: ~int) {} + +fn work(_: Box<int>) {} fn foo(_: proc()) {} pub fn main() { - let a = ~1; + let a = box 1; foo(proc() { foo(proc() { work(a) }) }) } diff --git a/src/test/run-pass/issue-10767.rs b/src/test/run-pass/issue-10767.rs index 3254f5bc35f..a30eb8120ea 100644 --- a/src/test/run-pass/issue-10767.rs +++ b/src/test/run-pass/issue-10767.rs @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + pub fn main() { fn f() { }; - let _: ~fn() = ~f; + let _: Box<fn()> = box f; } diff --git a/src/test/run-pass/issue-10802.rs b/src/test/run-pass/issue-10802.rs index b7b65c9de0a..6c4f0cc7f5f 100644 --- a/src/test/run-pass/issue-10802.rs +++ b/src/test/run-pass/issue-10802.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct DroppableStruct; static mut DROPPED: bool = false; @@ -19,19 +20,19 @@ impl Drop for DroppableStruct { } trait MyTrait { } -impl MyTrait for ~DroppableStruct {} +impl MyTrait for Box<DroppableStruct> {} -struct Whatever { w: ~MyTrait } +struct Whatever { w: Box<MyTrait> } impl Whatever { - fn new(w: ~MyTrait) -> Whatever { + fn new(w: Box<MyTrait>) -> Whatever { Whatever { w: w } } } fn main() { { - let f = ~DroppableStruct; - let _a = Whatever::new(~f as ~MyTrait); + let f = box DroppableStruct; + let _a = Whatever::new(box f as Box<MyTrait>); } assert!(unsafe { DROPPED }); } diff --git a/src/test/run-pass/issue-11552.rs b/src/test/run-pass/issue-11552.rs index 418bf5f0f9a..42b5bbc8623 100644 --- a/src/test/run-pass/issue-11552.rs +++ b/src/test/run-pass/issue-11552.rs @@ -8,22 +8,22 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + #[deriving(Clone)] enum Noun { Atom(int), - Cell(~Noun, ~Noun) + Cell(Box<Noun>, Box<Noun>) } fn fas(n: &Noun) -> Noun { - match n - { - &Cell(~Atom(2), ~Cell(ref a, _)) => (**a).clone(), + match n { + &Cell(box Atom(2), box Cell(ref a, _)) => (**a).clone(), _ => fail!("Invalid fas pattern") } } pub fn main() { - fas(&Cell(~Atom(2), ~Cell(~Atom(2), ~Atom(3)))); + fas(&Cell(box Atom(2), box Cell(box Atom(2), box Atom(3)))); } diff --git a/src/test/run-pass/issue-2288.rs b/src/test/run-pass/issue-2288.rs index 9e03023a9e9..85dd879c830 100644 --- a/src/test/run-pass/issue-2288.rs +++ b/src/test/run-pass/issue-2288.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait clam<A> { fn chowder(&self, y: A); } @@ -26,13 +27,13 @@ fn foo<A>(b: A) -> foo<A> { } } -fn f<A>(x: ~clam<A>, a: A) { +fn f<A>(x: Box<clam<A>>, a: A) { x.chowder(a); } pub fn main() { let c = foo(42); - let d: ~clam<int> = ~c as ~clam<int>; + let d: Box<clam<int>> = box c as Box<clam<int>>; f(d, c.x); } diff --git a/src/test/run-pass/issue-2633-2.rs b/src/test/run-pass/issue-2633-2.rs index 71a491b8a39..42170bfe832 100644 --- a/src/test/run-pass/issue-2633-2.rs +++ b/src/test/run-pass/issue-2633-2.rs @@ -8,11 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn a_val(x: ~int, y: ~int) -> int { + +fn a_val(x: Box<int>, y: Box<int>) -> int { *x + *y } pub fn main() { - let z = ~22; + let z = box 22; a_val(z.clone(), z.clone()); } diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 0598fafd96e..2b1ba332841 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -42,7 +42,7 @@ pub mod pipes { pub fn packet<T:Send>() -> *packet<T> { unsafe { - let p: *packet<T> = cast::transmute(~Stuff{ + let p: *packet<T> = cast::transmute(box Stuff{ state: empty, blocked_task: None::<Task>, payload: None::<T> @@ -59,7 +59,7 @@ pub mod pipes { // We should consider moving this to ::std::unsafe, although I // suspect graydon would want us to use void pointers instead. - pub unsafe fn uniquify<T>(x: *T) -> ~T { + pub unsafe fn uniquify<T>(x: *T) -> Box<T> { cast::transmute(x) } diff --git a/src/test/run-pass/issue-2734.rs b/src/test/run-pass/issue-2734.rs index faf3b090312..9f337ecfe37 100644 --- a/src/test/run-pass/issue-2734.rs +++ b/src/test/run-pass/issue-2734.rs @@ -8,17 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait hax { } impl<A> hax for A { } -fn perform_hax<T: 'static>(x: ~T) -> ~hax: { - ~x as ~hax: +fn perform_hax<T: 'static>(x: Box<T>) -> Box<hax:> { + box x as Box<hax:> } fn deadcode() { - perform_hax(~"deadcode".to_owned()); + perform_hax(box "deadcode".to_owned()); } pub fn main() { - let _ = perform_hax(~42); + let _ = perform_hax(box 42); } diff --git a/src/test/run-pass/issue-2735.rs b/src/test/run-pass/issue-2735.rs index af6dc66b95b..bdaf8ac9755 100644 --- a/src/test/run-pass/issue-2735.rs +++ b/src/test/run-pass/issue-2735.rs @@ -8,17 +8,18 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait hax { } impl<A> hax for A { } -fn perform_hax<T: 'static>(x: ~T) -> ~hax: { - ~x as ~hax: +fn perform_hax<T: 'static>(x: Box<T>) -> Box<hax:> { + box x as Box<hax:> } fn deadcode() { - perform_hax(~"deadcode".to_owned()); + perform_hax(box "deadcode".to_owned()); } pub fn main() { - perform_hax(~42); + perform_hax(box 42); } diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs index 91e21dedd49..dfd34fcf591 100644 --- a/src/test/run-pass/issue-2804.rs +++ b/src/test/run-pass/issue-2804.rs @@ -21,7 +21,7 @@ enum object { int_value(i64), } -fn lookup(table: ~json::Object, key: ~str, default: ~str) -> ~str +fn lookup(table: Box<json::Object>, key: ~str, default: ~str) -> ~str { match table.find(&key) { option::Some(&json::String(ref s)) => { diff --git a/src/test/run-pass/issue-2935.rs b/src/test/run-pass/issue-2935.rs index aeef29acd0e..cdc41e892f9 100644 --- a/src/test/run-pass/issue-2935.rs +++ b/src/test/run-pass/issue-2935.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + //type t = { a: int }; // type t = { a: bool }; type t = bool; @@ -22,10 +23,10 @@ impl it for t { pub fn main() { // let x = ({a: 4i} as it); - // let y = ~({a: 4i}); - // let z = ~({a: 4i} as it); - // let z = ~({a: true} as it); - let z = ~(~true as ~it); + // let y = box ({a: 4i}); + // let z = box ({a: 4i} as it); + // let z = box ({a: true} as it); + let z = box() (box true as Box<it>); // x.f(); // y.f(); // (*z).f(); diff --git a/src/test/run-pass/issue-3026.rs b/src/test/run-pass/issue-3026.rs index 6c181935205..9d18e176638 100644 --- a/src/test/run-pass/issue-3026.rs +++ b/src/test/run-pass/issue-3026.rs @@ -15,6 +15,6 @@ use collections::HashMap; pub fn main() { let mut buggy_map: HashMap<uint, &uint> = HashMap::new(); - let x = ~1; + let x = box 1; buggy_map.insert(42, &*x); } diff --git a/src/test/run-pass/issue-3290.rs b/src/test/run-pass/issue-3290.rs index f2beda59733..00b78ee8e40 100644 --- a/src/test/run-pass/issue-3290.rs +++ b/src/test/run-pass/issue-3290.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let mut x = ~3; + let mut x = box 3; x = x; assert_eq!(*x, 3); } diff --git a/src/test/run-pass/issue-3702.rs b/src/test/run-pass/issue-3702.rs index 43f2e764e69..84414461e96 100644 --- a/src/test/run-pass/issue-3702.rs +++ b/src/test/run-pass/issue-3702.rs @@ -8,12 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + pub fn main() { trait Text { fn to_str(&self) -> ~str; } - fn to_string(t: ~Text) { + fn to_string(t: Box<Text>) { println!("{}", t.to_str()); } diff --git a/src/test/run-pass/issue-3794.rs b/src/test/run-pass/issue-3794.rs index 8cc7d275789..b08e6525ba5 100644 --- a/src/test/run-pass/issue-3794.rs +++ b/src/test/run-pass/issue-3794.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait T { fn print(&self); } @@ -31,9 +32,9 @@ fn print_s(s: &S) { } pub fn main() { - let s: ~S = ~S { s: 5 }; + let s: Box<S> = box S { s: 5 }; print_s(s); - let t: ~T = s as ~T; + let t: Box<T> = s as Box<T>; print_t(t); } diff --git a/src/test/run-pass/issue-3878.rs b/src/test/run-pass/issue-3878.rs index 4330663db25..1b09889c887 100644 --- a/src/test/run-pass/issue-3878.rs +++ b/src/test/run-pass/issue-3878.rs @@ -11,6 +11,6 @@ #![allow(path_statement)] pub fn main() { - let y = ~1; + let y = box 1; y; } diff --git a/src/test/run-pass/issue-4735.rs b/src/test/run-pass/issue-4735.rs index b23158522a3..e89e661e9d8 100644 --- a/src/test/run-pass/issue-4735.rs +++ b/src/test/run-pass/issue-4735.rs @@ -20,12 +20,12 @@ struct NonCopyable(*c_void); impl Drop for NonCopyable { fn drop(&mut self) { let NonCopyable(p) = *self; - let _v = unsafe { transmute::<*c_void, ~int>(p) }; + let _v = unsafe { transmute::<*c_void, Box<int>>(p) }; } } pub fn main() { - let t = ~0; - let p = unsafe { transmute::<~int, *c_void>(t) }; + let t = box 0; + let p = unsafe { transmute::<Box<int>, *c_void>(t) }; let _z = NonCopyable(p); } diff --git a/src/test/run-pass/issue-4759.rs b/src/test/run-pass/issue-4759.rs index 45912039857..4b5c3566965 100644 --- a/src/test/run-pass/issue-4759.rs +++ b/src/test/run-pass/issue-4759.rs @@ -8,18 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct T { a: ~int } + +struct T { a: Box<int> } trait U { fn f(self); } -impl U for ~int { +impl U for Box<int> { fn f(self) { } } pub fn main() { - let T { a: a } = T { a: ~0 }; + let T { a: a } = T { a: box 0 }; a.f(); } diff --git a/src/test/run-pass/issue-4830.rs b/src/test/run-pass/issue-4830.rs index 168389bf2b8..7fc1c10895e 100644 --- a/src/test/run-pass/issue-4830.rs +++ b/src/test/run-pass/issue-4830.rs @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + pub struct Scheduler { /// The event loop used to drive the scheduler and perform I/O - event_loop: ~int + event_loop: Box<int> } pub fn main() { } diff --git a/src/test/run-pass/issue-5192.rs b/src/test/run-pass/issue-5192.rs index 202a3cbcafa..0dd6623a349 100644 --- a/src/test/run-pass/issue-5192.rs +++ b/src/test/run-pass/issue-5192.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + pub trait EventLoop { } @@ -27,12 +28,12 @@ impl EventLoop for UvEventLoop { } pub struct Scheduler { - event_loop: ~EventLoop, + event_loop: Box<EventLoop>, } impl Scheduler { - pub fn new(event_loop: ~EventLoop) -> Scheduler { + pub fn new(event_loop: Box<EventLoop>) -> Scheduler { Scheduler { event_loop: event_loop, } @@ -40,5 +41,5 @@ impl Scheduler { } pub fn main() { - let _sched = Scheduler::new(~UvEventLoop::new() as ~EventLoop); + let _sched = Scheduler::new(box UvEventLoop::new() as Box<EventLoop>); } diff --git a/src/test/run-pass/issue-5666.rs b/src/test/run-pass/issue-5666.rs index a6efa5954f1..a3dc1fae7f1 100644 --- a/src/test/run-pass/issue-5666.rs +++ b/src/test/run-pass/issue-5666.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct Dog { name : ~str } @@ -24,9 +25,9 @@ impl Barks for Dog { pub fn main() { - let snoopy = ~Dog{name: "snoopy".to_owned()}; - let bubbles = ~Dog{name: "bubbles".to_owned()}; - let barker = [snoopy as ~Barks, bubbles as ~Barks]; + let snoopy = box Dog{name: "snoopy".to_owned()}; + let bubbles = box Dog{name: "bubbles".to_owned()}; + let barker = [snoopy as Box<Barks>, bubbles as Box<Barks>]; for pup in barker.iter() { println!("{}", pup.bark()); diff --git a/src/test/run-pass/issue-5884.rs b/src/test/run-pass/issue-5884.rs index 4a4c8a4011c..8d336c6e31b 100644 --- a/src/test/run-pass/issue-5884.rs +++ b/src/test/run-pass/issue-5884.rs @@ -10,17 +10,18 @@ #![feature(managed_boxes)] + pub struct Foo { a: int, } struct Bar<'a> { - a: ~Option<int>, + a: Box<Option<int>>, b: &'a Foo, } fn check(a: @Foo) { - let _ic = Bar{ b: a, a: ~None }; + let _ic = Bar{ b: a, a: box None }; } pub fn main(){} diff --git a/src/test/run-pass/issue-6128.rs b/src/test/run-pass/issue-6128.rs index 3694421c691..9f44f11e5c8 100644 --- a/src/test/run-pass/issue-6128.rs +++ b/src/test/run-pass/issue-6128.rs @@ -24,6 +24,6 @@ impl<E> Graph<int, E> for HashMap<int, int> { } pub fn main() { - let g : ~HashMap<int, int> = ~HashMap::new(); - let _g2 : ~Graph<int,int> = g as ~Graph<int,int>; + let g : Box<HashMap<int,int>> = box HashMap::new(); + let _g2 : Box<Graph<int,int>> = g as Box<Graph<int,int>>; } diff --git a/src/test/run-pass/issue-6318.rs b/src/test/run-pass/issue-6318.rs index 00a94c0cc37..4eb005f3397 100644 --- a/src/test/run-pass/issue-6318.rs +++ b/src/test/run-pass/issue-6318.rs @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + pub enum Thing { - A(~Foo) + A(Box<Foo>) } pub trait Foo {} @@ -19,7 +20,7 @@ pub struct Struct; impl Foo for Struct {} pub fn main() { - match A(~Struct as ~Foo) { + match A(box Struct as Box<Foo>) { A(_a) => 0, }; } diff --git a/src/test/run-pass/issue-6557.rs b/src/test/run-pass/issue-6557.rs index 57224612573..7061a17dcdd 100644 --- a/src/test/run-pass/issue-6557.rs +++ b/src/test/run-pass/issue-6557.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo(~(_x, _y): ~(int, int)) {} + +fn foo(box (_x, _y): Box<(int, int)>) {} pub fn main() {} diff --git a/src/test/run-pass/issue-7320.rs b/src/test/run-pass/issue-7320.rs index ccd2e807739..99ed4288a7e 100644 --- a/src/test/run-pass/issue-7320.rs +++ b/src/test/run-pass/issue-7320.rs @@ -8,10 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait Foo { - fn foo(~self) { bar(self as ~Foo); } + fn foo(~self) { bar(self as Box<Foo>); } } -fn bar(_b: ~Foo) { } +fn bar(_b: Box<Foo>) { } fn main() {} diff --git a/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs b/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs index cf1f979acb4..7cd7e70be74 100644 --- a/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs +++ b/src/test/run-pass/issue-7673-cast-generically-implemented-trait.rs @@ -14,11 +14,12 @@ */ + pub fn main() {} trait A {} impl<T: 'static> A for T {} -fn owned1<T: 'static>(a: T) { ~a as ~A:; } /* note `:` */ -fn owned2<T: 'static>(a: ~T) { a as ~A:; } -fn owned3<T: 'static>(a: ~T) { ~a as ~A:; } +fn owned1<T: 'static>(a: T) { box a as Box<A:>; } /* note `:` */ +fn owned2<T: 'static>(a: Box<T>) { a as Box<A:>; } +fn owned3<T: 'static>(a: Box<T>) { box a as Box<A:>; } diff --git a/src/test/run-pass/issue-8498.rs b/src/test/run-pass/issue-8498.rs index ac95b5e7c19..770de8f5346 100644 --- a/src/test/run-pass/issue-8498.rs +++ b/src/test/run-pass/issue-8498.rs @@ -9,14 +9,14 @@ // except according to those terms. pub fn main() { - match &[(~5,~7)] { + match &[(box 5,box 7)] { ps => { let (ref y, _) = ps[0]; assert!(**y == 5); } } - match Some(&[(~5,)]) { + match Some(&[(box 5,)]) { Some(ps) => { let (ref y,) = ps[0]; assert!(**y == 5); @@ -24,7 +24,7 @@ pub fn main() { None => () } - match Some(&[(~5,~7)]) { + match Some(&[(box 5,box 7)]) { Some(ps) => { let (ref y, ref z) = ps[0]; assert!(**y == 5); diff --git a/src/test/run-pass/issue-9129.rs b/src/test/run-pass/issue-9129.rs index 52fc33d121d..b61263d1754 100644 --- a/src/test/run-pass/issue-9129.rs +++ b/src/test/run-pass/issue-9129.rs @@ -12,6 +12,7 @@ #![feature(macro_rules)] + pub trait bomb { fn boom(&self, Ident); } pub struct S; impl bomb for S { fn boom(&self, _: Ident) { } } @@ -26,7 +27,7 @@ fn Ident_new() -> Ident { Ident {name: 0x6789ABCD } } -pub fn light_fuse(fld: ~bomb) { +pub fn light_fuse(fld: Box<bomb>) { int3!(); let f = || { int3!(); @@ -36,6 +37,6 @@ pub fn light_fuse(fld: ~bomb) { } pub fn main() { - let b = ~S as ~bomb; + let b = box S as Box<bomb>; light_fuse(b); } diff --git a/src/test/run-pass/issue-9382.rs b/src/test/run-pass/issue-9382.rs index 3b79782878b..bba4b69ee1e 100644 --- a/src/test/run-pass/issue-9382.rs +++ b/src/test/run-pass/issue-9382.rs @@ -18,23 +18,23 @@ struct Thing1<'a> { - baz: &'a [~int], - bar: ~u64, + baz: &'a [Box<int>], + bar: Box<u64>, } struct Thing2<'a> { - baz: &'a [~int], + baz: &'a [Box<int>], bar: u64, } pub fn main() { let _t1_fixed = Thing1 { baz: &[], - bar: ~32, + bar: box 32, }; Thing1 { baz: Vec::new().as_slice(), - bar: ~32, + bar: box 32, }; let _t2_fixed = Thing2 { baz: &[], diff --git a/src/test/run-pass/kindck-owned-trait-contains-1.rs b/src/test/run-pass/kindck-owned-trait-contains-1.rs index e4a7e7af14f..3dae50bda33 100644 --- a/src/test/run-pass/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/kindck-owned-trait-contains-1.rs @@ -8,21 +8,22 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait repeat<A> { fn get(&self) -> A; } -impl<A:Clone + 'static> repeat<A> for ~A { +impl<A:Clone + 'static> repeat<A> for Box<A> { fn get(&self) -> A { (**self).clone() } } -fn repeater<A:Clone + 'static>(v: ~A) -> ~repeat<A>: { +fn repeater<A:Clone + 'static>(v: Box<A>) -> Box<repeat<A>:> { // Note: owned kind is not necessary as A appears in the trait type - ~v as ~repeat<A>: // No + box v as Box<repeat<A>:> // No } pub fn main() { let x = 3; - let y = repeater(~x); + let y = repeater(box x); assert_eq!(x, y.get()); } diff --git a/src/test/run-pass/last-use-in-cap-clause.rs b/src/test/run-pass/last-use-in-cap-clause.rs index ec26dc0b3ed..463ea0c6863 100644 --- a/src/test/run-pass/last-use-in-cap-clause.rs +++ b/src/test/run-pass/last-use-in-cap-clause.rs @@ -10,10 +10,11 @@ // Make sure #1399 stays fixed -struct A { a: ~int } + +struct A { a: Box<int> } fn foo() -> ||: 'static -> int { - let k = ~22; + let k = box 22; let _u = A {a: k.clone()}; let result: ||: 'static -> int = || 22; result diff --git a/src/test/run-pass/last-use-is-capture.rs b/src/test/run-pass/last-use-is-capture.rs index f0149c811f0..5e892d5433e 100644 --- a/src/test/run-pass/last-use-is-capture.rs +++ b/src/test/run-pass/last-use-is-capture.rs @@ -10,11 +10,12 @@ // Make sure #1399 stays fixed -struct A { a: ~int } + +struct A { a: Box<int> } pub fn main() { fn invoke(f: ||) { f(); } - let k = ~22; + let k = box 22; let _u = A {a: k.clone()}; invoke(|| println!("{:?}", k.clone()) ) } diff --git a/src/test/run-pass/leak-unique-as-tydesc.rs b/src/test/run-pass/leak-unique-as-tydesc.rs index ab186d935df..b109e94b74f 100644 --- a/src/test/run-pass/leak-unique-as-tydesc.rs +++ b/src/test/run-pass/leak-unique-as-tydesc.rs @@ -9,7 +9,6 @@ // except according to those terms. - fn leaky<T>(_t: T) { } -pub fn main() { let x = ~10; leaky::<~int>(x); } +pub fn main() { let x = box 10; leaky::<Box<int>>(x); } diff --git a/src/test/run-pass/match-implicit-copy-unique.rs b/src/test/run-pass/match-implicit-copy-unique.rs index 23074894490..679fb472503 100644 --- a/src/test/run-pass/match-implicit-copy-unique.rs +++ b/src/test/run-pass/match-implicit-copy-unique.rs @@ -8,13 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Pair { a: ~int, b: ~int } + +struct Pair { a: Box<int>, b: Box<int> } pub fn main() { - let mut x = ~Pair {a: ~10, b: ~20}; + let mut x = box Pair {a: box 10, b: box 20}; match x { - ~Pair {a: ref mut a, b: ref mut _b} => { - assert!(**a == 10); *a = ~30; assert!(**a == 30); + box Pair {a: ref mut a, b: ref mut _b} => { + assert!(**a == 10); *a = box 30; assert!(**a == 30); } } } diff --git a/src/test/run-pass/match-unique-bind.rs b/src/test/run-pass/match-unique-bind.rs index 9fc3a7acf71..9fae0e30d59 100644 --- a/src/test/run-pass/match-unique-bind.rs +++ b/src/test/run-pass/match-unique-bind.rs @@ -9,8 +9,8 @@ // except according to those terms. pub fn main() { - match ~100 { - ~x => { + match box 100 { + box x => { println!("{:?}", x); assert_eq!(x, 100); } diff --git a/src/test/run-pass/match-value-binding-in-guard-3291.rs b/src/test/run-pass/match-value-binding-in-guard-3291.rs index 33785b2fbb0..0e7e9be6765 100644 --- a/src/test/run-pass/match-value-binding-in-guard-3291.rs +++ b/src/test/run-pass/match-value-binding-in-guard-3291.rs @@ -8,7 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo(x: Option<~int>, b: bool) -> int { + +fn foo(x: Option<Box<int>>, b: bool) -> int { match x { None => { 1 } Some(ref x) if b => { *x.clone() } @@ -17,8 +18,8 @@ fn foo(x: Option<~int>, b: bool) -> int { } pub fn main() { - foo(Some(~22), true); - foo(Some(~22), false); + foo(Some(box 22), true); + foo(Some(box 22), false); foo(None, true); foo(None, false); } diff --git a/src/test/run-pass/move-1-unique.rs b/src/test/run-pass/move-1-unique.rs index ac6dfa00f48..19153dd3742 100644 --- a/src/test/run-pass/move-1-unique.rs +++ b/src/test/run-pass/move-1-unique.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + #[deriving(Clone)] struct Triple { x: int, @@ -15,15 +16,15 @@ struct Triple { z: int, } -fn test(x: bool, foo: ~Triple) -> int { +fn test(x: bool, foo: Box<Triple>) -> int { let bar = foo; - let mut y: ~Triple; - if x { y = bar; } else { y = ~Triple{x: 4, y: 5, z: 6}; } + let mut y: Box<Triple>; + if x { y = bar; } else { y = box Triple{x: 4, y: 5, z: 6}; } return y.y; } pub fn main() { - let x = ~Triple{x: 1, y: 2, z: 3}; + let x = box Triple{x: 1, y: 2, z: 3}; assert_eq!(test(true, x.clone()), 2); assert_eq!(test(true, x.clone()), 2); assert_eq!(test(true, x.clone()), 2); diff --git a/src/test/run-pass/move-2-unique.rs b/src/test/run-pass/move-2-unique.rs index e3595d4ac9a..65d8281407c 100644 --- a/src/test/run-pass/move-2-unique.rs +++ b/src/test/run-pass/move-2-unique.rs @@ -11,4 +11,8 @@ struct X { x: int, y: int, z: int } -pub fn main() { let x = ~X{x: 1, y: 2, z: 3}; let y = x; assert!((y.y == 2)); } +pub fn main() { + let x = box X{x: 1, y: 2, z: 3}; + let y = x; + assert!((y.y == 2)); +} diff --git a/src/test/run-pass/move-3-unique.rs b/src/test/run-pass/move-3-unique.rs index 867f00aff53..19778425367 100644 --- a/src/test/run-pass/move-3-unique.rs +++ b/src/test/run-pass/move-3-unique.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + #[deriving(Clone)] struct Triple { x: int, @@ -15,15 +16,15 @@ struct Triple { z: int, } -fn test(x: bool, foo: ~Triple) -> int { +fn test(x: bool, foo: Box<Triple>) -> int { let bar = foo; - let mut y: ~Triple; - if x { y = bar; } else { y = ~Triple {x: 4, y: 5, z: 6}; } + let mut y: Box<Triple>; + if x { y = bar; } else { y = box Triple {x: 4, y: 5, z: 6}; } return y.y; } pub fn main() { - let x = ~Triple{x: 1, y: 2, z: 3}; + let x = box Triple{x: 1, y: 2, z: 3}; for _ in range(0u, 10000u) { assert_eq!(test(true, x.clone()), 2); } diff --git a/src/test/run-pass/move-4-unique.rs b/src/test/run-pass/move-4-unique.rs index 60537d99d84..286781a4822 100644 --- a/src/test/run-pass/move-4-unique.rs +++ b/src/test/run-pass/move-4-unique.rs @@ -8,9 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct Triple {a: int, b: int, c: int} -fn test(foo: ~Triple) -> ~Triple { +fn test(foo: Box<Triple>) -> Box<Triple> { let foo = foo; let bar = foo; let baz = bar; @@ -18,4 +19,8 @@ fn test(foo: ~Triple) -> ~Triple { return quux; } -pub fn main() { let x = ~Triple{a: 1, b: 2, c: 3}; let y = test(x); assert!((y.c == 3)); } +pub fn main() { + let x = box Triple{a: 1, b: 2, c: 3}; + let y = test(x); + assert!((y.c == 3)); +} diff --git a/src/test/run-pass/move-arg-2-unique.rs b/src/test/run-pass/move-arg-2-unique.rs index 6bc3605156c..ac90f8f6ecf 100644 --- a/src/test/run-pass/move-arg-2-unique.rs +++ b/src/test/run-pass/move-arg-2-unique.rs @@ -9,13 +9,13 @@ // except according to those terms. -fn test(foo: ~Vec<int> ) { assert!((*foo.get(0) == 10)); } +fn test(foo: Box<Vec<int>> ) { assert!((*foo.get(0) == 10)); } pub fn main() { - let x = ~vec!(10); + let x = box vec!(10); // Test forgetting a local by move-in test(x); // Test forgetting a temporary by move-in. - test(~vec!(10)); + test(box vec!(10)); } diff --git a/src/test/run-pass/mut-function-arguments.rs b/src/test/run-pass/mut-function-arguments.rs index 5801ccebb0f..39441227f60 100644 --- a/src/test/run-pass/mut-function-arguments.rs +++ b/src/test/run-pass/mut-function-arguments.rs @@ -8,20 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(mut y: ~int) { + +fn f(mut y: Box<int>) { *y = 5; assert_eq!(*y, 5); } fn g() { - let frob: |~int| = |mut q| { *q = 2; assert!(*q == 2); }; - let w = ~37; + let frob: |Box<int>| = |mut q| { *q = 2; assert!(*q == 2); }; + let w = box 37; frob(w); } pub fn main() { - let z = ~17; + let z = box 17; f(z); g(); } diff --git a/src/test/run-pass/new-box-syntax.rs b/src/test/run-pass/new-box-syntax.rs index 7a90ea436e0..cab3f36a9f4 100644 --- a/src/test/run-pass/new-box-syntax.rs +++ b/src/test/run-pass/new-box-syntax.rs @@ -14,7 +14,7 @@ // Tests that the new `box` syntax works with unique pointers and GC pointers. use std::gc::Gc; -use std::owned::HEAP; +use std::owned::{Box, HEAP}; struct Structure { x: int, @@ -22,14 +22,14 @@ struct Structure { } pub fn main() { - let x: ~int = box(HEAP) 2; - let y: ~int = box 2; + let x: Box<int> = box(HEAP) 2; + let y: Box<int> = box 2; let z: Gc<int> = box(GC) 2; let a: Gc<Structure> = box(GC) Structure { x: 10, y: 20, }; - let b: ~int = box()(1 + 2); + let b: Box<int> = box()(1 + 2); let c = box()(3 + 4); let d = box(GC)(5 + 6); } diff --git a/src/test/run-pass/new-box.rs b/src/test/run-pass/new-box.rs index 0202695841e..d41896ffb41 100644 --- a/src/test/run-pass/new-box.rs +++ b/src/test/run-pass/new-box.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::owned::Box; fn f(x: Box<int>) { let y: &int = x; diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs index 237212e7eb7..04b2e94f1a0 100644 --- a/src/test/run-pass/nullable-pointer-iotareduction.rs +++ b/src/test/run-pass/nullable-pointer-iotareduction.rs @@ -74,7 +74,7 @@ macro_rules! check_type { pub fn main() { check_type!(&17: &int); - check_type!(~18: ~int); + check_type!(box 18: Box<int>); check_type!(@19: @int); check_type!("foo".to_owned(): ~str); check_type!(vec!(20, 22): Vec<int> ); diff --git a/src/test/run-pass/nullable-pointer-size.rs b/src/test/run-pass/nullable-pointer-size.rs index 4e5627237fb..00edcd6a092 100644 --- a/src/test/run-pass/nullable-pointer-size.rs +++ b/src/test/run-pass/nullable-pointer-size.rs @@ -38,7 +38,7 @@ macro_rules! check_type { pub fn main() { check_type!(&'static int); - check_type!(~int); + check_type!(Box<int>); check_type!(@int); check_type!(~str); check_type!(extern fn()); diff --git a/src/test/run-pass/objects-owned-object-borrowed-method-header.rs b/src/test/run-pass/objects-owned-object-borrowed-method-header.rs index c39e79e0528..456a5c5d297 100644 --- a/src/test/run-pass/objects-owned-object-borrowed-method-header.rs +++ b/src/test/run-pass/objects-owned-object-borrowed-method-header.rs @@ -14,7 +14,7 @@ // Test invoked `&self` methods on owned objects where the values -// closed over contain managed values. This implies that the ~ boxes +// closed over contain managed values. This implies that the boxes // will have headers that must be skipped over. trait FooTrait { @@ -32,10 +32,10 @@ impl FooTrait for BarStruct { } pub fn main() { - let foos: Vec<~FooTrait:> = vec!( - ~BarStruct{ x: @0 } as ~FooTrait:, - ~BarStruct{ x: @1 } as ~FooTrait:, - ~BarStruct{ x: @2 } as ~FooTrait: + let foos: Vec<Box<FooTrait:>> = vec!( + box BarStruct{ x: @0 } as Box<FooTrait:>, + box BarStruct{ x: @1 } as Box<FooTrait:>, + box BarStruct{ x: @2 } as Box<FooTrait:> ); for i in range(0u, foos.len()) { diff --git a/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs b/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs index bd4a933205c..9ca6598b47c 100644 --- a/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs +++ b/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs @@ -9,7 +9,7 @@ // except according to those terms. // Test invoked `&self` methods on owned objects where the values -// closed over do not contain managed values, and thus the ~ boxes do +// closed over do not contain managed values, and thus the boxes do // not have headers. @@ -28,10 +28,10 @@ impl FooTrait for BarStruct { } pub fn main() { - let foos: Vec<~FooTrait> = vec!( - ~BarStruct{ x: 0 } as ~FooTrait, - ~BarStruct{ x: 1 } as ~FooTrait, - ~BarStruct{ x: 2 } as ~FooTrait + let foos: Vec<Box<FooTrait>> = vec!( + box BarStruct{ x: 0 } as Box<FooTrait>, + box BarStruct{ x: 1 } as Box<FooTrait>, + box BarStruct{ x: 2 } as Box<FooTrait> ); for i in range(0u, foos.len()) { diff --git a/src/test/run-pass/objects-owned-object-owned-method.rs b/src/test/run-pass/objects-owned-object-owned-method.rs index 0d675c16d1a..cac132b8e36 100644 --- a/src/test/run-pass/objects-owned-object-owned-method.rs +++ b/src/test/run-pass/objects-owned-object-owned-method.rs @@ -9,9 +9,10 @@ // except according to those terms. // Test invoked `&self` methods on owned objects where the values -// closed over contain managed values. This implies that the ~ boxes +// closed over contain managed values. This implies that the boxes // will have headers that must be skipped over. + trait FooTrait { fn foo(~self) -> uint; } @@ -27,6 +28,6 @@ impl FooTrait for BarStruct { } pub fn main() { - let foo = ~BarStruct{ x: 22 } as ~FooTrait; + let foo = box BarStruct{ x: 22 } as Box<FooTrait:>; assert_eq!(22, foo.foo()); } diff --git a/src/test/run-pass/overloaded-autoderef.rs b/src/test/run-pass/overloaded-autoderef.rs index 08cb2f57990..39566cbc6ed 100644 --- a/src/test/run-pass/overloaded-autoderef.rs +++ b/src/test/run-pass/overloaded-autoderef.rs @@ -20,7 +20,7 @@ struct Point { pub fn main() { assert_eq!(Rc::new(5u).to_uint(), Some(5)); - assert_eq!((~&~&Rc::new(~~&~5u)).to_uint(), Some(5)); + assert_eq!((box &box &Rc::new(box box &box 5u)).to_uint(), Some(5)); let point = Rc::new(Point {x: 2, y: 4}); assert_eq!(point.x, 2); assert_eq!(point.y, 4); diff --git a/src/test/run-pass/overloaded-deref.rs b/src/test/run-pass/overloaded-deref.rs index 5328b213810..47cdc8d247a 100644 --- a/src/test/run-pass/overloaded-deref.rs +++ b/src/test/run-pass/overloaded-deref.rs @@ -20,7 +20,7 @@ struct Point { pub fn main() { assert_eq!(*Rc::new(5), 5); - assert_eq!(***Rc::new(~~5), 5); + assert_eq!(***Rc::new(box box 5), 5); assert_eq!(*Rc::new(Point {x: 2, y: 4}), Point {x: 2, y: 4}); let i = Rc::new(RefCell::new(2)); diff --git a/src/test/run-pass/owned-implies-static.rs b/src/test/run-pass/owned-implies-static.rs index f327f6bc0dc..d1e9fb270d7 100644 --- a/src/test/run-pass/owned-implies-static.rs +++ b/src/test/run-pass/owned-implies-static.rs @@ -11,5 +11,5 @@ fn f<T: 'static>(_x: T) {} pub fn main() { - f(~5); + f(box 5); } diff --git a/src/test/run-pass/parameterized-trait-with-bounds.rs b/src/test/run-pass/parameterized-trait-with-bounds.rs index e22bc4247e0..6f33fb470e7 100644 --- a/src/test/run-pass/parameterized-trait-with-bounds.rs +++ b/src/test/run-pass/parameterized-trait-with-bounds.rs @@ -10,6 +10,7 @@ #![allow(dead_code)] + trait A<T> {} trait B<T, U> {} trait C<'a, U> {} @@ -19,9 +20,9 @@ mod foo { } fn foo1<T>(_: &A<T>: Send) {} -fn foo2<T>(_: ~A<T>: Send + Share) {} -fn foo3<T>(_: ~B<int, uint>: 'static) {} -fn foo4<'a, T>(_: ~C<'a, T>: 'static + Send) {} -fn foo5<'a, T>(_: ~foo::D<'a, T>: 'static + Send) {} +fn foo2<T>(_: Box<A<T>: Send + Share>) {} +fn foo3<T>(_: Box<B<int, uint>: 'static>) {} +fn foo4<'a, T>(_: Box<C<'a, T>: 'static + Send>) {} +fn foo5<'a, T>(_: Box<foo::D<'a, T>: 'static + Send>) {} pub fn main() {} diff --git a/src/test/run-pass/privacy-ns.rs b/src/test/run-pass/privacy-ns.rs index 0756d8214a6..5915b3e3a76 100644 --- a/src/test/run-pass/privacy-ns.rs +++ b/src/test/run-pass/privacy-ns.rs @@ -16,6 +16,7 @@ #![allow(dead_code)] #![allow(unused_imports)] + // public type, private value pub mod foo1 { pub trait Bar { @@ -34,19 +35,19 @@ fn test_unused1() { fn test_single1() { use foo1::Bar; - let _x: ~Bar; + let _x: Box<Bar>; } fn test_list1() { use foo1::{Bar,Baz}; - let _x: ~Bar; + let _x: Box<Bar>; } fn test_glob1() { use foo1::*; - let _x: ~Bar; + let _x: Box<Bar>; } // private type, public value @@ -101,21 +102,21 @@ fn test_single3() { use foo3::Bar; Bar(); - let _x: ~Bar; + let _x: Box<Bar>; } fn test_list3() { use foo3::{Bar,Baz}; Bar(); - let _x: ~Bar; + let _x: Box<Bar>; } fn test_glob3() { use foo3::*; Bar(); - let _x: ~Bar; + let _x: Box<Bar>; } fn main() { diff --git a/src/test/run-pass/pure-sum.rs b/src/test/run-pass/pure-sum.rs index ef569af1350..60eb3f9debd 100644 --- a/src/test/run-pass/pure-sum.rs +++ b/src/test/run-pass/pure-sum.rs @@ -23,7 +23,7 @@ fn sums_to(v: Vec<int> , sum: int) -> bool { fn sums_to_using_uniq(v: Vec<int> , sum: int) -> bool { let mut i = 0u; - let mut sum0 = ~0; + let mut sum0 = box 0; while i < v.len() { *sum0 += *v.get(i); i += 1u; @@ -45,7 +45,7 @@ struct F<T> { f: T } fn sums_to_using_uniq_rec(v: Vec<int> , sum: int) -> bool { let mut i = 0u; - let mut sum0 = F {f: ~0}; + let mut sum0 = F {f: box 0}; while i < v.len() { *sum0.f += *v.get(i); i += 1u; diff --git a/src/test/run-pass/rcvr-borrowed-to-region.rs b/src/test/run-pass/rcvr-borrowed-to-region.rs index 4b54c32fbd3..eab5ba61083 100644 --- a/src/test/run-pass/rcvr-borrowed-to-region.rs +++ b/src/test/run-pass/rcvr-borrowed-to-region.rs @@ -33,7 +33,7 @@ pub fn main() { println!("y={}", y); assert_eq!(y, 6); - let x = ~6; + let x = box 6; let y = x.get(); println!("y={}", y); assert_eq!(y, 6); diff --git a/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs b/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs index 7efe62236f3..47ae5c13d28 100644 --- a/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs +++ b/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs @@ -8,13 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct Point { x: int, y: int } struct Character { - pos: ~Point + pos: Box<Point>, } fn get_x<'r>(x: &'r Character) -> &'r int { diff --git a/src/test/run-pass/regions-borrow-uniq.rs b/src/test/run-pass/regions-borrow-uniq.rs index 10037d9dfe4..6b35c0768d7 100644 --- a/src/test/run-pass/regions-borrow-uniq.rs +++ b/src/test/run-pass/regions-borrow-uniq.rs @@ -13,7 +13,7 @@ fn foo(x: &uint) -> uint { } pub fn main() { - let p = ~3u; + let p = box 3u; let r = foo(p); assert_eq!(r, 3u); } diff --git a/src/test/run-pass/regions-bound-lists-feature-gate.rs b/src/test/run-pass/regions-bound-lists-feature-gate.rs index 163e6670c9c..3e23c1d4d64 100644 --- a/src/test/run-pass/regions-bound-lists-feature-gate.rs +++ b/src/test/run-pass/regions-bound-lists-feature-gate.rs @@ -12,9 +12,10 @@ #![feature(issue_5723_bootstrap)] + trait Foo { } -fn foo<'a>(x: ~Foo:'a) { +fn foo<'a>(x: Box<Foo:'a>) { } fn bar<'a, T:'a>() { diff --git a/src/test/run-pass/regions-dependent-addr-of.rs b/src/test/run-pass/regions-dependent-addr-of.rs index 256d12ccddf..400ab462f76 100644 --- a/src/test/run-pass/regions-dependent-addr-of.rs +++ b/src/test/run-pass/regions-dependent-addr-of.rs @@ -21,7 +21,7 @@ struct B { v2: [int, ..3], v3: Vec<int> , v4: C, - v5: ~C, + v5: Box<C>, v6: Option<C> } @@ -78,7 +78,7 @@ fn get_v6_c<'v>(a: &'v A, _i: uint) -> &'v int { fn get_v5_ref<'v>(a: &'v A, _i: uint) -> &'v int { match &a.value { - &B {v5: ~C {f: ref v}, ..} => v + &B {v5: box C {f: ref v}, ..} => v } } @@ -87,7 +87,7 @@ pub fn main() { v2: [23, 24, 25], v3: vec!(26, 27, 28), v4: C { f: 29 }, - v5: ~C { f: 30 }, + v5: box C { f: 30 }, v6: Some(C { f: 31 })}}; let p = get_v1(&a); diff --git a/src/test/run-pass/regions-early-bound-trait-param.rs b/src/test/run-pass/regions-early-bound-trait-param.rs index f3cfa0b9d33..a7ba496dc4a 100644 --- a/src/test/run-pass/regions-early-bound-trait-param.rs +++ b/src/test/run-pass/regions-early-bound-trait-param.rs @@ -11,6 +11,7 @@ // Tests that you can use an early-bound lifetime parameter as // on of the generic parameters in a trait. + trait Trait<'a> { fn long(&'a self) -> int; fn short<'b>(&'b self) -> int; @@ -77,8 +78,8 @@ impl<'s> Trait<'s> for (int,int) { } } -impl<'t> MakerTrait<'t> for ~Trait<'t> { - fn mk() -> ~Trait<'t> { ~(4,5) as ~Trait } +impl<'t> MakerTrait<'t> for Box<Trait<'t>> { + fn mk() -> Box<Trait<'t>> { box() (4,5) as Box<Trait> } } enum List<'l> { @@ -118,7 +119,7 @@ pub fn main() { assert_eq!(object_invoke2(&t), 3); assert_eq!(field_invoke2(&s2), 3); - let m : ~Trait = make_val(); + let m : Box<Trait> = make_val(); assert_eq!(object_invoke1(m), (4,5)); assert_eq!(object_invoke2(m), 5); diff --git a/src/test/run-pass/self-in-mut-slot-default-method.rs b/src/test/run-pass/self-in-mut-slot-default-method.rs index 08d10fd1170..8ab27cfb4ee 100644 --- a/src/test/run-pass/self-in-mut-slot-default-method.rs +++ b/src/test/run-pass/self-in-mut-slot-default-method.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct X { a: int } @@ -18,7 +19,7 @@ trait Changer { self } - fn change_again(mut ~self) -> ~Self { + fn change_again(mut ~self) -> Box<Self> { self.set_to(45); self } @@ -37,7 +38,7 @@ pub fn main() { let new_x = x.change(); assert_eq!(new_x.a, 55); - let x = ~new_x; + let x = box new_x; let new_x = x.change_again(); assert_eq!(new_x.a, 45); } diff --git a/src/test/run-pass/self-re-assign.rs b/src/test/run-pass/self-re-assign.rs index 4e1a9b665d0..e613a83737e 100644 --- a/src/test/run-pass/self-re-assign.rs +++ b/src/test/run-pass/self-re-assign.rs @@ -14,7 +14,7 @@ use std::rc::Rc; pub fn main() { - let mut x = ~3; + let mut x = box 3; x = x; assert!(*x == 3); diff --git a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs index a62c1ec3314..c03094d4f15 100644 --- a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs +++ b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs @@ -17,7 +17,7 @@ fn test05_start(f: proc(int)) { } fn test05() { - let three = ~3; + let three = box 3; let fn_to_send: proc(int):Send = proc(n) { println!("{}", *three + n); // will copy x into the closure assert_eq!(*three, 3); diff --git a/src/test/run-pass/sized-owned-pointer.rs b/src/test/run-pass/sized-owned-pointer.rs index 0c05fdd616b..e64917a97a6 100644 --- a/src/test/run-pass/sized-owned-pointer.rs +++ b/src/test/run-pass/sized-owned-pointer.rs @@ -10,6 +10,7 @@ // Possibly-dynamic size of typaram should be cleared at pointer boundary. + fn bar<T: Sized>() { } -fn foo<T>() { bar::<~T>() } +fn foo<T>() { bar::<Box<T>>() } pub fn main() { } diff --git a/src/test/run-pass/task-spawn-move-and-copy.rs b/src/test/run-pass/task-spawn-move-and-copy.rs index 18d7839652a..cf6c2754829 100644 --- a/src/test/run-pass/task-spawn-move-and-copy.rs +++ b/src/test/run-pass/task-spawn-move-and-copy.rs @@ -13,7 +13,7 @@ use std::task; pub fn main() { let (tx, rx) = channel::<uint>(); - let x = ~1; + let x = box 1; let x_in_parent = &(*x) as *int as uint; task::spawn(proc() { diff --git a/src/test/run-pass/trait-bounds-basic.rs b/src/test/run-pass/trait-bounds-basic.rs index 6059e5e95ee..68ebf2c6382 100644 --- a/src/test/run-pass/trait-bounds-basic.rs +++ b/src/test/run-pass/trait-bounds-basic.rs @@ -8,24 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait Foo { } -fn a(_x: ~Foo:) { +fn a(_x: Box<Foo:>) { } -fn b(_x: ~Foo:Send) { +fn b(_x: Box<Foo:Send>) { } -fn c(x: ~Foo:Share+Send) { +fn c(x: Box<Foo:Share+Send>) { a(x); } -fn d(x: ~Foo:Send) { +fn d(x: Box<Foo:Send>) { b(x); } -fn e(x: ~Foo) { // sugar for ~Foo:Owned +fn e(x: Box<Foo>) { // sugar for Box<Foo:Owned> a(x); } diff --git a/src/test/run-pass/trait-bounds-in-arc.rs b/src/test/run-pass/trait-bounds-in-arc.rs index 312978f00a0..0a6e5ce0b67 100644 --- a/src/test/run-pass/trait-bounds-in-arc.rs +++ b/src/test/run-pass/trait-bounds-in-arc.rs @@ -64,10 +64,10 @@ pub fn main() { let dogge1 = Dogge { bark_decibels: 100, tricks_known: 42, name: "alan_turing".to_owned() }; let dogge2 = Dogge { bark_decibels: 55, tricks_known: 11, name: "albert_einstein".to_owned() }; let fishe = Goldfyshe { swim_speed: 998, name: "alec_guinness".to_owned() }; - let arc = Arc::new(vec!(~catte as ~Pet:Share+Send, - ~dogge1 as ~Pet:Share+Send, - ~fishe as ~Pet:Share+Send, - ~dogge2 as ~Pet:Share+Send)); + let arc = Arc::new(vec!(box catte as Box<Pet:Share+Send>, + box dogge1 as Box<Pet:Share+Send>, + box fishe as Box<Pet:Share+Send>, + box dogge2 as Box<Pet:Share+Send>)); let (tx1, rx1) = channel(); let arc1 = arc.clone(); task::spawn(proc() { check_legs(arc1); tx1.send(()); }); @@ -82,21 +82,21 @@ pub fn main() { rx3.recv(); } -fn check_legs(arc: Arc<Vec<~Pet:Share+Send>>) { +fn check_legs(arc: Arc<Vec<Box<Pet:Share+Send>>>) { let mut legs = 0; for pet in arc.iter() { legs += pet.num_legs(); } assert!(legs == 12); } -fn check_names(arc: Arc<Vec<~Pet:Share+Send>>) { +fn check_names(arc: Arc<Vec<Box<Pet:Share+Send>>>) { for pet in arc.iter() { pet.name(|name| { assert!(name[0] == 'a' as u8 && name[1] == 'l' as u8); }) } } -fn check_pedigree(arc: Arc<Vec<~Pet:Share+Send>>) { +fn check_pedigree(arc: Arc<Vec<Box<Pet:Share+Send>>>) { for pet in arc.iter() { assert!(pet.of_good_pedigree()); } diff --git a/src/test/run-pass/trait-cast.rs b/src/test/run-pass/trait-cast.rs index 244459e2269..3d303bf1e5b 100644 --- a/src/test/run-pass/trait-cast.rs +++ b/src/test/run-pass/trait-cast.rs @@ -18,7 +18,7 @@ struct Tree(@RefCell<TreeR>); struct TreeR { left: Option<Tree>, right: Option<Tree>, - val: ~to_str:Send + val: Box<to_str:Send> } trait to_str { @@ -53,10 +53,10 @@ fn foo<T:to_str>(x: T) -> ~str { x.to_str_() } pub fn main() { let t1 = Tree(@RefCell::new(TreeR{left: None, right: None, - val: ~1 as ~to_str:Send})); + val: box 1 as Box<to_str:Send>})); let t2 = Tree(@RefCell::new(TreeR{left: Some(t1), right: Some(t1), - val: ~2 as ~to_str:Send})); + val: box 2 as Box<to_str:Send>})); let expected = "[2, some([1, none, none]), some([1, none, none])]".to_owned(); assert!(t2.to_str_() == expected); assert!(foo(t2) == expected); diff --git a/src/test/run-pass/trait-coercion-generic.rs b/src/test/run-pass/trait-coercion-generic.rs index 2d8a42005df..1e241ad2278 100644 --- a/src/test/run-pass/trait-coercion-generic.rs +++ b/src/test/run-pass/trait-coercion-generic.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + trait Trait<T> { fn f(&self, x: T); } @@ -25,7 +26,7 @@ impl Trait<&'static str> for Struct { pub fn main() { let a = Struct { x: 1, y: 2 }; - let b: ~Trait<&'static str> = ~a; + let b: Box<Trait<&'static str>> = box a; b.f("Mary"); let c: &Trait<&'static str> = &a; c.f("Joe"); diff --git a/src/test/run-pass/trait-coercion.rs b/src/test/run-pass/trait-coercion.rs index ea6d59a9068..1d229a8ae83 100644 --- a/src/test/run-pass/trait-coercion.rs +++ b/src/test/run-pass/trait-coercion.rs @@ -25,18 +25,18 @@ impl Trait for Struct { } } -fn foo(mut a: ~Writer) { +fn foo(mut a: Box<Writer>) { a.write(bytes!("Hello\n")); } pub fn main() { let a = Struct { x: 1, y: 2 }; - let b: ~Trait = ~a; + let b: Box<Trait> = box a; b.f(); let c: &Trait = &a; c.f(); let out = io::stdout(); - foo(~out); + foo(box out); } diff --git a/src/test/run-pass/trait-default-method-xc.rs b/src/test/run-pass/trait-default-method-xc.rs index 25b5b7fbd5f..27db6d2f3b8 100644 --- a/src/test/run-pass/trait-default-method-xc.rs +++ b/src/test/run-pass/trait-default-method-xc.rs @@ -50,7 +50,7 @@ impl TestEquality for stuff::thing { } -pub fn main () { +pub fn main() { // Some tests of random things f(0); @@ -72,7 +72,7 @@ pub fn main () { assert_eq!(g(0i, 3.14, 1), (3.14, 1)); assert_eq!(g(false, 3.14, 1), (3.14, 1)); - let obj = ~0i as ~A; + let obj = box 0i as Box<A>; assert_eq!(obj.h(), 11); diff --git a/src/test/run-pass/trait-object-generics.rs b/src/test/run-pass/trait-object-generics.rs index e2422a1dcf5..3c5ae6b57a3 100644 --- a/src/test/run-pass/trait-object-generics.rs +++ b/src/test/run-pass/trait-object-generics.rs @@ -10,6 +10,7 @@ // test for #8664 + pub trait Trait2<A> { fn doit(&self); } @@ -20,7 +21,7 @@ pub struct Impl<A1, A2, A3> { * task <unnamed> failed at 'index out of bounds: the len is 1 but the index is 1', * src/librustc/middle/subst.rs:58 */ - t: ~Trait2<A2> + t: Box<Trait2<A2>> } impl<A1, A2, A3> Impl<A1, A2, A3> { @@ -42,6 +43,6 @@ impl<V> Trait<u8,V> for () { } pub fn main() { - let a = ~() as ~Trait<u8, u8>; + let a = box() () as Box<Trait<u8, u8>>; assert_eq!(a.method(Constant), 0); } diff --git a/src/test/run-pass/type-param-constraints.rs b/src/test/run-pass/type-param-constraints.rs index 408a727b6f1..0fcf9b92ce0 100644 --- a/src/test/run-pass/type-param-constraints.rs +++ b/src/test/run-pass/type-param-constraints.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - #![feature(managed_boxes)] + fn p_foo<T>(_pinned: T) { } fn s_foo<T>(_shared: T) { } fn u_foo<T:Send>(_unique: T) { } @@ -33,16 +33,16 @@ pub fn main() { p_foo(r(10)); p_foo(@r(10)); - p_foo(~r(10)); + p_foo(box r(10)); p_foo(@10); - p_foo(~10); + p_foo(box 10); p_foo(10); s_foo(@r(10)); s_foo(@10); - s_foo(~10); + s_foo(box 10); s_foo(10); - u_foo(~10); + u_foo(box 10); u_foo(10); } diff --git a/src/test/run-pass/uniq-cc.rs b/src/test/run-pass/uniq-cc.rs index 1c7525f0754..06e9771aae4 100644 --- a/src/test/run-pass/uniq-cc.rs +++ b/src/test/run-pass/uniq-cc.rs @@ -19,14 +19,14 @@ enum maybe_pointy { struct Pointy { a : maybe_pointy, - c : ~int, + c : Box<int>, d : proc():Send->(), } fn empty_pointy() -> @RefCell<Pointy> { return @RefCell::new(Pointy { a : none, - c : ~22, + c : box 22, d : proc() {}, }) } diff --git a/src/test/run-pass/uniq-self-in-mut-slot.rs b/src/test/run-pass/uniq-self-in-mut-slot.rs index 7c2f5221176..3700e02051a 100644 --- a/src/test/run-pass/uniq-self-in-mut-slot.rs +++ b/src/test/run-pass/uniq-self-in-mut-slot.rs @@ -8,23 +8,24 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + struct X { a: int } trait Changer { - fn change(mut ~self) -> ~Self; + fn change(mut ~self) -> Box<Self>; } impl Changer for X { - fn change(mut ~self) -> ~X { + fn change(mut ~self) -> Box<X> { self.a = 55; self } } pub fn main() { - let x = ~X { a: 32 }; + let x = box X { a: 32 }; let new_x = x.change(); assert_eq!(new_x.a, 55); } diff --git a/src/test/run-pass/unique-assign-copy.rs b/src/test/run-pass/unique-assign-copy.rs index e59fe469dec..b295701d186 100644 --- a/src/test/run-pass/unique-assign-copy.rs +++ b/src/test/run-pass/unique-assign-copy.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let mut i = ~1; + let mut i = box 1; // Should be a copy let mut j; j = i.clone(); diff --git a/src/test/run-pass/unique-assign-drop.rs b/src/test/run-pass/unique-assign-drop.rs index df8036451d8..90e5e82f0d8 100644 --- a/src/test/run-pass/unique-assign-drop.rs +++ b/src/test/run-pass/unique-assign-drop.rs @@ -11,8 +11,8 @@ #![allow(dead_assignment)] pub fn main() { - let i = ~1; - let mut j = ~2; + let i = box 1; + let mut j = box 2; // Should drop the previous value of j j = i; assert_eq!(*j, 1); diff --git a/src/test/run-pass/unique-assign-generic.rs b/src/test/run-pass/unique-assign-generic.rs index 595c5fe82e7..94e3ea565d6 100644 --- a/src/test/run-pass/unique-assign-generic.rs +++ b/src/test/run-pass/unique-assign-generic.rs @@ -16,8 +16,8 @@ fn f<T>(t: T) -> T { } pub fn main() { - let t = f(~100); - assert_eq!(t, ~100); - let t = f(~@vec!(100)); - assert_eq!(t, ~@vec!(100)); + let t = f(box 100); + assert_eq!(t, box 100); + let t = f(box @vec!(100)); + assert_eq!(t, box @vec!(100)); } diff --git a/src/test/run-pass/unique-assign.rs b/src/test/run-pass/unique-assign.rs index 43df53c78a8..d332e235809 100644 --- a/src/test/run-pass/unique-assign.rs +++ b/src/test/run-pass/unique-assign.rs @@ -10,6 +10,6 @@ pub fn main() { let mut i; - i = ~1; + i = box 1; assert_eq!(*i, 1); } diff --git a/src/test/run-pass/unique-autoderef-field.rs b/src/test/run-pass/unique-autoderef-field.rs index 6836ba4e79b..67f96decaa9 100644 --- a/src/test/run-pass/unique-autoderef-field.rs +++ b/src/test/run-pass/unique-autoderef-field.rs @@ -11,7 +11,7 @@ struct J { j: int } pub fn main() { - let i = ~J { + let i = box J { j: 100 }; assert_eq!(i.j, 100); diff --git a/src/test/run-pass/unique-autoderef-index.rs b/src/test/run-pass/unique-autoderef-index.rs index 4971a42be30..fc5bac249ba 100644 --- a/src/test/run-pass/unique-autoderef-index.rs +++ b/src/test/run-pass/unique-autoderef-index.rs @@ -10,6 +10,6 @@ pub fn main() { - let i = ~vec!(100); + let i = box vec!(100); assert_eq!(*i.get(0), 100); } diff --git a/src/test/run-pass/unique-cmp.rs b/src/test/run-pass/unique-cmp.rs index b50d3154835..037faee9599 100644 --- a/src/test/run-pass/unique-cmp.rs +++ b/src/test/run-pass/unique-cmp.rs @@ -9,10 +9,10 @@ // except according to those terms. pub fn main() { - let i = ~100; - assert!(i == ~100); - assert!(i < ~101); - assert!(i <= ~100); - assert!(i > ~99); - assert!(i >= ~99); + let i = box 100; + assert!(i == box 100); + assert!(i < box 101); + assert!(i <= box 100); + assert!(i > box 99); + assert!(i >= box 99); } diff --git a/src/test/run-pass/unique-containing-tag.rs b/src/test/run-pass/unique-containing-tag.rs index 1ebd584aa5f..762a74b2455 100644 --- a/src/test/run-pass/unique-containing-tag.rs +++ b/src/test/run-pass/unique-containing-tag.rs @@ -11,7 +11,7 @@ pub fn main() { enum t { t1(int), t2(int), } - let _x = ~t1(10); + let _x = box t1(10); /*alt *x { t1(a) { @@ -21,7 +21,7 @@ pub fn main() { }*/ /*alt x { - ~t1(a) { + box t1(a) { assert_eq!(a, 10); } _ { fail!(); } diff --git a/src/test/run-pass/unique-create.rs b/src/test/run-pass/unique-create.rs index 023917ec2e9..834b549d4f4 100644 --- a/src/test/run-pass/unique-create.rs +++ b/src/test/run-pass/unique-create.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - ~100; + box 100; } fn vec() { diff --git a/src/test/run-pass/unique-decl-init-copy.rs b/src/test/run-pass/unique-decl-init-copy.rs index 13594d86f67..a5cb19ebad7 100644 --- a/src/test/run-pass/unique-decl-init-copy.rs +++ b/src/test/run-pass/unique-decl-init-copy.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let mut i = ~1; + let mut i = box 1; // Should be a copy let mut j = i.clone(); *i = 2; diff --git a/src/test/run-pass/unique-decl-init.rs b/src/test/run-pass/unique-decl-init.rs index c507d19fac1..9cf28415481 100644 --- a/src/test/run-pass/unique-decl-init.rs +++ b/src/test/run-pass/unique-decl-init.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let i = ~1; + let i = box 1; let j = i; assert_eq!(*j, 1); } diff --git a/src/test/run-pass/unique-decl-move-temp.rs b/src/test/run-pass/unique-decl-move-temp.rs index 6cf781d735c..346b7d0bfcc 100644 --- a/src/test/run-pass/unique-decl-move-temp.rs +++ b/src/test/run-pass/unique-decl-move-temp.rs @@ -9,6 +9,6 @@ // except according to those terms. pub fn main() { - let i = ~100; + let i = box 100; assert_eq!(*i, 100); } diff --git a/src/test/run-pass/unique-decl-move.rs b/src/test/run-pass/unique-decl-move.rs index 335275ff7c1..d2e8f991d21 100644 --- a/src/test/run-pass/unique-decl-move.rs +++ b/src/test/run-pass/unique-decl-move.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let i = ~100; + let i = box 100; let j = i; assert_eq!(*j, 100); } diff --git a/src/test/run-pass/unique-decl.rs b/src/test/run-pass/unique-decl.rs index 74b73d77369..7f894a8c324 100644 --- a/src/test/run-pass/unique-decl.rs +++ b/src/test/run-pass/unique-decl.rs @@ -8,10 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + pub fn main() { - let _: ~int; + let _: Box<int>; } -fn f(_i: ~int) -> ~int { +fn f(_i: Box<int>) -> Box<int> { fail!(); } diff --git a/src/test/run-pass/unique-deref.rs b/src/test/run-pass/unique-deref.rs index 6cf781d735c..346b7d0bfcc 100644 --- a/src/test/run-pass/unique-deref.rs +++ b/src/test/run-pass/unique-deref.rs @@ -9,6 +9,6 @@ // except according to those terms. pub fn main() { - let i = ~100; + let i = box 100; assert_eq!(*i, 100); } diff --git a/src/test/run-pass/unique-destructure.rs b/src/test/run-pass/unique-destructure.rs index 6c35cb4dba7..0b3041f2249 100644 --- a/src/test/run-pass/unique-destructure.rs +++ b/src/test/run-pass/unique-destructure.rs @@ -11,6 +11,6 @@ struct Foo { a: int, b: int } pub fn main() { - let ~Foo{a, b} = ~Foo{a: 100, b: 200}; + let box Foo{a, b} = box Foo{a: 100, b: 200}; assert_eq!(a + b, 300); } diff --git a/src/test/run-pass/unique-drop-complex.rs b/src/test/run-pass/unique-drop-complex.rs index eb8fa640a0f..01aac804bb6 100644 --- a/src/test/run-pass/unique-drop-complex.rs +++ b/src/test/run-pass/unique-drop-complex.rs @@ -9,5 +9,5 @@ // except according to those terms. pub fn main() { - let _x = ~vec!(0,0,0,0,0); + let _x = box vec!(0,0,0,0,0); } diff --git a/src/test/run-pass/unique-fn-arg-move.rs b/src/test/run-pass/unique-fn-arg-move.rs index 503bbae8c55..762c2c7ea0c 100644 --- a/src/test/run-pass/unique-fn-arg-move.rs +++ b/src/test/run-pass/unique-fn-arg-move.rs @@ -8,11 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(i: ~int) { + +fn f(i: Box<int>) { assert_eq!(*i, 100); } pub fn main() { - let i = ~100; + let i = box 100; f(i); } diff --git a/src/test/run-pass/unique-fn-arg-mut.rs b/src/test/run-pass/unique-fn-arg-mut.rs index c2d78c33039..ccf6a4fd7ae 100644 --- a/src/test/run-pass/unique-fn-arg-mut.rs +++ b/src/test/run-pass/unique-fn-arg-mut.rs @@ -8,12 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(i: &mut ~int) { - *i = ~200; + +fn f(i: &mut Box<int>) { + *i = box 200; } pub fn main() { - let mut i = ~100; + let mut i = box 100; f(&mut i); assert_eq!(*i, 200); } diff --git a/src/test/run-pass/unique-fn-arg.rs b/src/test/run-pass/unique-fn-arg.rs index 230131bae62..6769011cffe 100644 --- a/src/test/run-pass/unique-fn-arg.rs +++ b/src/test/run-pass/unique-fn-arg.rs @@ -8,12 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(i: ~int) { + +fn f(i: Box<int>) { assert_eq!(*i, 100); } pub fn main() { - f(~100); - let i = ~100; + f(box 100); + let i = box 100; f(i); } diff --git a/src/test/run-pass/unique-fn-ret.rs b/src/test/run-pass/unique-fn-ret.rs index dd39e136fc9..8493652cf8a 100644 --- a/src/test/run-pass/unique-fn-ret.rs +++ b/src/test/run-pass/unique-fn-ret.rs @@ -8,10 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f() -> ~int { - ~100 + +fn f() -> Box<int> { + box 100 } pub fn main() { - assert_eq!(f(), ~100); + assert_eq!(f(), box 100); } diff --git a/src/test/run-pass/unique-generic-assign.rs b/src/test/run-pass/unique-generic-assign.rs index 3805cbe47bf..58470637a11 100644 --- a/src/test/run-pass/unique-generic-assign.rs +++ b/src/test/run-pass/unique-generic-assign.rs @@ -10,7 +10,8 @@ // Issue #976 -fn f<T>(x: ~T) { + +fn f<T>(x: Box<T>) { let _x2 = x; } pub fn main() { } diff --git a/src/test/run-pass/unique-in-tag.rs b/src/test/run-pass/unique-in-tag.rs index c5d55ff0386..2045beb7f32 100644 --- a/src/test/run-pass/unique-in-tag.rs +++ b/src/test/run-pass/unique-in-tag.rs @@ -8,10 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. + fn test1() { - enum bar { u(~int), w(int), } + enum bar { u(Box<int>), w(int), } - let x = u(~10); + let x = u(box 10); assert!(match x { u(a) => { println!("{:?}", a); diff --git a/src/test/run-pass/unique-in-vec-copy.rs b/src/test/run-pass/unique-in-vec-copy.rs index c14af83ad87..f1f6a29dd22 100644 --- a/src/test/run-pass/unique-in-vec-copy.rs +++ b/src/test/run-pass/unique-in-vec-copy.rs @@ -10,7 +10,7 @@ pub fn main() { - let mut a = vec!(~10); + let mut a = vec!(box 10); let b = a.clone(); assert_eq!(**a.get(0), 10); diff --git a/src/test/run-pass/unique-in-vec.rs b/src/test/run-pass/unique-in-vec.rs index 82d3a29d901..9b2b66231e5 100644 --- a/src/test/run-pass/unique-in-vec.rs +++ b/src/test/run-pass/unique-in-vec.rs @@ -9,6 +9,6 @@ // except according to those terms. pub fn main() { - let vect = vec!(~100); - assert!(*vect.get(0) == ~100); + let vect = vec!(box 100); + assert!(*vect.get(0) == box 100); } diff --git a/src/test/run-pass/unique-init.rs b/src/test/run-pass/unique-init.rs index 6a87dd30f7a..d7105b472cc 100644 --- a/src/test/run-pass/unique-init.rs +++ b/src/test/run-pass/unique-init.rs @@ -9,5 +9,5 @@ // except according to those terms. pub fn main() { - let _i = ~100; + let _i = box 100; } diff --git a/src/test/run-pass/unique-kinds.rs b/src/test/run-pass/unique-kinds.rs index 118d0cd744d..6d088a1f6d4 100644 --- a/src/test/run-pass/unique-kinds.rs +++ b/src/test/run-pass/unique-kinds.rs @@ -20,11 +20,11 @@ fn sendable() { assert!(i != j); } - let i = ~100; - let j = ~100; + let i = box 100; + let j = box 100; f(i, j); - let i = ~100; - let j = ~101; + let i = box 100; + let j = box 101; g(i, j); } @@ -38,11 +38,11 @@ fn copyable() { assert!(i != j); } - let i = ~100; - let j = ~100; + let i = box 100; + let j = box 100; f(i, j); - let i = ~100; - let j = ~101; + let i = box 100; + let j = box 101; g(i, j); } @@ -56,11 +56,11 @@ fn noncopyable() { assert!(i != j); } - let i = ~100; - let j = ~100; + let i = box 100; + let j = box 100; f(i, j); - let i = ~100; - let j = ~101; + let i = box 100; + let j = box 101; g(i, j); } diff --git a/src/test/run-pass/unique-log.rs b/src/test/run-pass/unique-log.rs index 06f73777032..e2de566090d 100644 --- a/src/test/run-pass/unique-log.rs +++ b/src/test/run-pass/unique-log.rs @@ -9,6 +9,6 @@ // except according to those terms. pub fn main() { - let i = ~100; + let i = box 100; println!("{:?}", i); } diff --git a/src/test/run-pass/unique-match-discrim.rs b/src/test/run-pass/unique-match-discrim.rs index 1f0b13dfd01..68b46db3a94 100644 --- a/src/test/run-pass/unique-match-discrim.rs +++ b/src/test/run-pass/unique-match-discrim.rs @@ -11,7 +11,7 @@ // Issue #961 fn altsimple() { - match ~true { + match box true { _ => { } } } diff --git a/src/test/run-pass/unique-move-drop.rs b/src/test/run-pass/unique-move-drop.rs index c757011f935..7ec0ce62329 100644 --- a/src/test/run-pass/unique-move-drop.rs +++ b/src/test/run-pass/unique-move-drop.rs @@ -11,8 +11,8 @@ #![allow(unused_variable)] pub fn main() { - let i = ~100; - let j = ~200; + let i = box 100; + let j = box 200; let j = i; assert_eq!(*j, 100); } diff --git a/src/test/run-pass/unique-move-temp.rs b/src/test/run-pass/unique-move-temp.rs index 7c7ca1379ea..18cbbfa08df 100644 --- a/src/test/run-pass/unique-move-temp.rs +++ b/src/test/run-pass/unique-move-temp.rs @@ -10,6 +10,6 @@ pub fn main() { let mut i; - i = ~100; + i = box 100; assert_eq!(*i, 100); } diff --git a/src/test/run-pass/unique-move.rs b/src/test/run-pass/unique-move.rs index dbdfc5cb5bb..14f6077be7a 100644 --- a/src/test/run-pass/unique-move.rs +++ b/src/test/run-pass/unique-move.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let i = ~100; + let i = box 100; let mut j; j = i; assert_eq!(*j, 100); diff --git a/src/test/run-pass/unique-mutable.rs b/src/test/run-pass/unique-mutable.rs index 4f353c56671..01a3ba6a3b4 100644 --- a/src/test/run-pass/unique-mutable.rs +++ b/src/test/run-pass/unique-mutable.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let mut i = ~0; + let mut i = box 0; *i = 1; assert_eq!(*i, 1); } diff --git a/src/test/run-pass/unique-object-move.rs b/src/test/run-pass/unique-object-move.rs index f6a46741366..6d0432faf55 100644 --- a/src/test/run-pass/unique-object-move.rs +++ b/src/test/run-pass/unique-object-move.rs @@ -10,6 +10,7 @@ // Issue #5192 + pub trait EventLoop { } pub struct UvEventLoop { @@ -19,6 +20,6 @@ pub struct UvEventLoop { impl EventLoop for UvEventLoop { } pub fn main() { - let loop_: ~EventLoop = ~UvEventLoop { uvio: 0 } as ~EventLoop; + let loop_: Box<EventLoop> = box UvEventLoop { uvio: 0 } as Box<EventLoop>; let _loop2_ = loop_; } diff --git a/src/test/run-pass/unique-pat-2.rs b/src/test/run-pass/unique-pat-2.rs index 49a873e793a..3f7138006e5 100644 --- a/src/test/run-pass/unique-pat-2.rs +++ b/src/test/run-pass/unique-pat-2.rs @@ -11,11 +11,11 @@ struct Foo {a: int, b: uint} -enum bar { u(~Foo), w(int), } +enum bar { u(Box<Foo>), w(int), } pub fn main() { - assert!(match u(~Foo{a: 10, b: 40u}) { - u(~Foo{a: a, b: b}) => { a + (b as int) } + assert!(match u(box Foo{a: 10, b: 40u}) { + u(box Foo{a: a, b: b}) => { a + (b as int) } _ => { 66 } } == 50); } diff --git a/src/test/run-pass/unique-pat-3.rs b/src/test/run-pass/unique-pat-3.rs index 7f11e7b7df5..55fda4c1106 100644 --- a/src/test/run-pass/unique-pat-3.rs +++ b/src/test/run-pass/unique-pat-3.rs @@ -9,10 +9,10 @@ // except according to those terms. -enum bar { u(~int), w(int), } +enum bar { u(Box<int>), w(int), } pub fn main() { - assert!(match u(~10) { + assert!(match u(box 10) { u(a) => { println!("{:?}", a); *a diff --git a/src/test/run-pass/unique-pat.rs b/src/test/run-pass/unique-pat.rs index 0b9ad6ee194..297ded0222d 100644 --- a/src/test/run-pass/unique-pat.rs +++ b/src/test/run-pass/unique-pat.rs @@ -9,8 +9,8 @@ // except according to those terms. fn simple() { - match ~true { - ~true => { } + match box true { + box true => { } _ => { fail!(); } } } diff --git a/src/test/run-pass/unique-rec.rs b/src/test/run-pass/unique-rec.rs index f740dd2a22c..ff7f009990d 100644 --- a/src/test/run-pass/unique-rec.rs +++ b/src/test/run-pass/unique-rec.rs @@ -11,7 +11,7 @@ struct X { x: int } pub fn main() { - let x = ~X {x: 1}; + let x = box X {x: 1}; let bar = x; assert_eq!(bar.x, 1); } diff --git a/src/test/run-pass/unique-send-2.rs b/src/test/run-pass/unique-send-2.rs index eec68dae108..432a0527ada 100644 --- a/src/test/run-pass/unique-send-2.rs +++ b/src/test/run-pass/unique-send-2.rs @@ -10,8 +10,8 @@ use std::task; -fn child(tx: &Sender<~uint>, i: uint) { - tx.send(~i); +fn child(tx: &Sender<Box<uint>>, i: uint) { + tx.send(box i); } pub fn main() { diff --git a/src/test/run-pass/unique-send.rs b/src/test/run-pass/unique-send.rs index aced7a33da7..5d622f5cfe8 100644 --- a/src/test/run-pass/unique-send.rs +++ b/src/test/run-pass/unique-send.rs @@ -10,7 +10,7 @@ pub fn main() { let (tx, rx) = channel(); - tx.send(~100); + tx.send(box 100); let v = rx.recv(); - assert_eq!(v, ~100); + assert_eq!(v, box 100); } diff --git a/src/test/run-pass/unique-swap.rs b/src/test/run-pass/unique-swap.rs index 779606dba0c..1299b28a67e 100644 --- a/src/test/run-pass/unique-swap.rs +++ b/src/test/run-pass/unique-swap.rs @@ -11,9 +11,9 @@ use std::mem::swap; pub fn main() { - let mut i = ~100; - let mut j = ~200; + let mut i = box 100; + let mut j = box 200; swap(&mut i, &mut j); - assert_eq!(i, ~200); - assert_eq!(j, ~100); + assert_eq!(i, box 200); + assert_eq!(j, box 100); } diff --git a/src/test/run-pass/unsized2.rs b/src/test/run-pass/unsized2.rs index 7883adad46a..53db7f37e8d 100644 --- a/src/test/run-pass/unsized2.rs +++ b/src/test/run-pass/unsized2.rs @@ -9,6 +9,7 @@ // except according to those terms. #![feature(struct_variant)] + // Test sized-ness checking in substitution. // Unbounded. @@ -32,33 +33,33 @@ fn f4<X: T>(x: &X) { // Self type. trait T2 for type { - fn f() -> ~Self; + fn f() -> Box<Self>; } struct S; impl T2 for S { - fn f() -> ~S { - ~S + fn f() -> Box<S> { + box S } } fn f5<type X: T2>(x: &X) { - let _: ~X = T2::f(); + let _: Box<X> = T2::f(); } fn f6<X: T2>(x: &X) { - let _: ~X = T2::f(); + let _: Box<X> = T2::f(); } trait T3 for type { - fn f() -> ~Self; + fn f() -> Box<Self>; } impl T3 for S { - fn f() -> ~S { - ~S + fn f() -> Box<S> { + box S } } fn f7<type X: T3>(x: &X) { // This is valid, but the unsized bound on X is irrelevant because any type // which implements T3 must have statically known size. - let _: ~X = T3::f(); + let _: Box<X> = T3::f(); } trait T4<X> { diff --git a/src/test/run-pass/unused-move-capture.rs b/src/test/run-pass/unused-move-capture.rs index ceb91d557f6..83795e64467 100644 --- a/src/test/run-pass/unused-move-capture.rs +++ b/src/test/run-pass/unused-move-capture.rs @@ -9,7 +9,7 @@ // except according to those terms. pub fn main() { - let _x = ~1; + let _x = box 1; let lam_move: || = || {}; lam_move(); } diff --git a/src/test/run-pass/unused-move.rs b/src/test/run-pass/unused-move.rs index 163726fd06a..bac9ce814bc 100644 --- a/src/test/run-pass/unused-move.rs +++ b/src/test/run-pass/unused-move.rs @@ -16,6 +16,6 @@ pub fn main() { - let y = ~1; + let y = box 1; y; } diff --git a/src/test/run-pass/unwind-unique.rs b/src/test/run-pass/unwind-unique.rs index 8bc95b233f1..ce252439618 100644 --- a/src/test/run-pass/unwind-unique.rs +++ b/src/test/run-pass/unwind-unique.rs @@ -11,7 +11,7 @@ use std::task; fn f() { - let _a = ~0; + let _a = box 0; fail!(); } |
