// reference. That would allow creating a mutable pointer to a
// temporary, which would be a source of confusion
- let mut a = @[0];
+ let mut a = ~[0];
a.test_mut(); //~ ERROR does not implement any method in scope named `test_mut`
}
#[feature(managed_boxes)];
-type Foo = @[u8];
+type Foo = ~[u8];
impl Drop for Foo { //~ ERROR the Drop trait may only be implemented
//~^ ERROR cannot provide an extension implementation
#[feature(managed_boxes)];
-fn wants_box(x: @[uint]) { }
fn wants_uniq(x: ~[uint]) { }
fn wants_three(x: [uint, ..3]) { }
-fn has_box(x: @[uint]) {
- wants_box(x);
- wants_uniq(x); //~ ERROR [] storage differs: expected `~` but found `@`
- wants_three(x); //~ ERROR [] storage differs: expected `3` but found `@`
-}
-
fn has_uniq(x: ~[uint]) {
- wants_box(x); //~ ERROR [] storage differs: expected `@` but found `~`
wants_uniq(x);
wants_three(x); //~ ERROR [] storage differs: expected `3` but found `~`
}
fn has_three(x: [uint, ..3]) {
- wants_box(x); //~ ERROR [] storage differs: expected `@` but found `3`
wants_uniq(x); //~ ERROR [] storage differs: expected `~` but found `3`
wants_three(x);
}
fn has_four(x: [uint, ..4]) {
- wants_box(x); //~ ERROR [] storage differs: expected `@` but found `4`
wants_uniq(x); //~ ERROR [] storage differs: expected `~` but found `4`
wants_three(x); //~ ERROR [] storage differs: expected `3` but found `4`
}
#[feature(managed_boxes)];
static x: ~[int] = ~[123, 456]; //~ ERROR: cannot allocate vectors in constant expressions
-static y: @[int] = @[123, 456]; //~ ERROR: cannot allocate vectors in constant expressions
fn main() {}
let _x : Bar = Bar {x : ~10}; //~ ERROR type uses owned
@2; //~ ERROR type uses managed
- @[1]; //~ ERROR type uses managed
- //~^ ERROR type uses managed
+
fn f(_: @Clone) {} //~ ERROR type uses managed
~2; //~ ERROR type uses owned
touch(&x); //~ ERROR use of moved value: `x`
}
-fn f90() {
- let x = ~"hi";
- let _y = @[x];
- touch(&x); //~ ERROR use of moved value: `x`
-}
-
fn f100() {
let x = ~[~"hi"];
let _y = x[0];
// debugger:run
// debugger:finish
-// debugger:print managed->val.fill
-// check:$1 = 24
-// debugger:print *((uint64_t[3]*)(managed->val.elements))
-// check:$2 = {7, 8, 9}
-
// debugger:print unique->fill
-// check:$3 = 32
+// check:$1 = 32
// debugger:print *((uint64_t[4]*)(unique->elements))
-// check:$4 = {10, 11, 12, 13}
+// check:$2 = {10, 11, 12, 13}
#[allow(unused_variable)];
fn main() {
- let managed: @[i64] = @[7, 8, 9];
let unique: ~[i64] = ~[10, 11, 12, 13];
zzz();
let a = &Point {x: 3u, y: 5u};
test_ebml(a);
- let a = &@[1u, 2u, 3u];
- test_ebml(a);
-
let a = &Top(22u);
test_ebml(a);
([1]).test_imm();
(~[1]).test_imm();
- (@[1]).test_imm();
(&[1]).test_imm();
("test").test_imm();
(~"test").test_imm();
+++ /dev/null
-// Copyright 2012 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.
-
-#[feature(managed_boxes)];
-
-fn sum_slice(x: &[int]) -> int {
- let mut sum = 0;
- for i in x.iter() { sum += *i; }
- return sum;
-}
-
-pub fn main() {
- let x = @[1, 2, 3];
- assert_eq!(sum_slice(x), 6);
-}
println!("{}", v[2]);
println!("{}", v[3]);
println!("{}", v[4]);
- let v: @[int] = @[ 2, ..5 ];
- println!("{}", v[0]);
- println!("{}", v[1]);
- println!("{}", v[2]);
- println!("{}", v[3]);
- println!("{}", v[4]);
}
+++ /dev/null
-// Copyright 2013 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.
-
-#[feature(managed_boxes)];
-#[allow(unused_mut)];
-
-pub fn main() {
- let mut your_favorite_numbers = @[1,2,3];
- let mut my_favorite_numbers = @[4,5,6];
- let f = your_favorite_numbers + my_favorite_numbers;
- println!("The third favorite number is {:?}.", f)
-}
-
baz: ~[],
bar: ~32,
};
- let _t1_at = Thing1 {
- baz: @[],
- bar: ~32,
- };
let _t2_fixed = Thing2 {
baz: &[],
bar: 32,
baz: ~[],
bar: 32,
};
- let _t2_at = Thing2 {
- baz: @[],
- bar: 32,
- };
}
check_type!(@19: @int);
check_type!(~"foo": ~str);
check_type!(~[20, 22]: ~[int]);
- check_type!(@[]: @[int]);
- check_type!(@[24, 26]: @[int]);
let mint: uint = unsafe { cast::transmute(main) };
check_type!(main: extern fn(), |pthing| {
assert!(mint == unsafe { cast::transmute(*pthing) })
check_type!(@int);
check_type!(~str);
check_type!(~[int]);
- check_type!(@[int]);
check_type!(extern fn());
}
assert_eq!(mem::size_of::<S<u64, u16>>(), 11);
- assert_eq!(mem::size_of::<S<~str, @[int]>>(),
- 1 + mem::size_of::<~str>() + mem::size_of::<@[int]>());
+ assert_eq!(mem::size_of::<S<~str, ~[int]>>(),
+ 1 + mem::size_of::<~str>() + mem::size_of::<~[int]>());
}
}
fn visit_evec_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
- self.align_to::<@[u8]>();
- if ! self.inner().visit_evec_box(mtbl, inner) { return false; }
- self.bump_past::<@[u8]>();
true
}
+++ /dev/null
-// Copyright 2012 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.
-
-#[feature(managed_boxes)];
-
-fn foo(x: &[uint]) -> uint {
- x[0]
-}
-
-pub fn main() {
- let p = @[22u];
- let r = foo(p);
- assert_eq!(r, 22u);
-}
}
pub fn main() {
- let x = [ @[true], ..512 ];
+ let x = [ [true], ..512 ];
let y = [ 0, ..1 ];
error!("{:?}", x);
-#[feature(managed_boxes)];
-
pub fn main() {
- let x = @[1, 2, 3];
+ let x = ~[1, 2, 3];
match x {
[2, ..] => fail!(),
[1, ..tail] => {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#[feature(managed_boxes)];
-
pub fn main() {
assert_eq!((~[0, 1]).to_str(), ~"[0, 1]");
assert_eq!((&[1, 2]).to_str(), ~"[1, 2]");
- assert_eq!((@[2, 3]).to_str(), ~"[2, 3]");
let foo = ~[3, 4];
let bar = &[4, 5];
- let baz = @[5, 6];
assert_eq!(foo.to_str(), ~"[3, 4]");
assert_eq!(bar.to_str(), ~"[4, 5]");
- assert_eq!(baz.to_str(), ~"[5, 6]");
-
}