rustc: Obsolete the @ syntax entirely
This removes all remnants of `@` pointers from rustc. Additionally, this removes the `GC` structure from the prelude as it seems odd exporting an experimental type in the prelude by default. Closes #14193 [breaking-change]
This commit is contained in:
parent
f20b1293fc
commit
ade807c6dc
239 changed files with 922 additions and 561 deletions
|
|
@ -11,6 +11,7 @@
|
|||
#![feature(managed_boxes)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
pub struct Entry<A,B> {
|
||||
key: A,
|
||||
|
|
@ -19,7 +20,7 @@ pub struct Entry<A,B> {
|
|||
|
||||
pub struct alist<A,B> {
|
||||
eq_fn: extern "Rust" fn(A,A) -> bool,
|
||||
data: @RefCell<Vec<Entry<A,B>> >,
|
||||
data: Gc<RefCell<Vec<Entry<A,B>>>>,
|
||||
}
|
||||
|
||||
pub fn alist_add<A:'static,B:'static>(lst: &alist<A,B>, k: A, v: B) {
|
||||
|
|
@ -47,7 +48,7 @@ pub fn new_int_alist<B:'static>() -> alist<int, B> {
|
|||
fn eq_int(a: int, b: int) -> bool { a == b }
|
||||
return alist {
|
||||
eq_fn: eq_int,
|
||||
data: @RefCell::new(Vec::new()),
|
||||
data: box(GC) RefCell::new(Vec::new()),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -57,6 +58,6 @@ pub fn new_int_alist_2<B:'static>() -> alist<int, B> {
|
|||
fn eq_int(a: int, b: int) -> bool { a == b }
|
||||
return alist {
|
||||
eq_fn: eq_int,
|
||||
data: @RefCell::new(Vec::new()),
|
||||
data: box(GC) RefCell::new(Vec::new()),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,9 @@ pub mod name_pool {
|
|||
|
||||
pub mod rust {
|
||||
pub use name_pool::add;
|
||||
use std::gc::Gc;
|
||||
|
||||
pub type rt = @();
|
||||
pub type rt = Gc<()>;
|
||||
|
||||
pub trait cx {
|
||||
fn cx(&self);
|
||||
|
|
|
|||
|
|
@ -14,8 +14,9 @@
|
|||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::gc::Gc;
|
||||
|
||||
pub type header_map = HashMap<String, @RefCell<Vec<@String>>>;
|
||||
pub type header_map = HashMap<String, Gc<RefCell<Vec<Gc<String>>>>>;
|
||||
|
||||
// the unused ty param is necessary so this gets monomorphized
|
||||
pub fn request<T>(req: &header_map) {
|
||||
|
|
|
|||
|
|
@ -11,5 +11,7 @@
|
|||
#![feature(managed_boxes)]
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::gc::Gc;
|
||||
|
||||
pub type map = Gc<HashMap<uint, uint>>;
|
||||
|
||||
pub type map = @HashMap<uint, uint>;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ use syntax::ext::base::*;
|
|||
use syntax::parse::token;
|
||||
use rustc::plugin::Registry;
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! exported_macro (() => (2))
|
||||
|
||||
|
|
@ -42,9 +44,9 @@ fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree])
|
|||
MacExpr::new(quote_expr!(cx, 1i))
|
||||
}
|
||||
|
||||
fn expand_into_foo(cx: &mut ExtCtxt, sp: Span, attr: @MetaItem, it: @Item)
|
||||
-> @Item {
|
||||
@Item {
|
||||
fn expand_into_foo(cx: &mut ExtCtxt, sp: Span, attr: Gc<MetaItem>, it: Gc<Item>)
|
||||
-> Gc<Item> {
|
||||
box(GC) Item {
|
||||
attrs: it.attrs.clone(),
|
||||
..(*quote_item!(cx, enum Foo { Bar, Baz }).unwrap()).clone()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use time::precise_time_s;
|
|||
use std::os;
|
||||
use std::task;
|
||||
use std::vec;
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
#[deriving(Clone)]
|
||||
enum List<T> {
|
||||
|
|
@ -53,10 +53,10 @@ type nillist = List<()>;
|
|||
// Filled with things that have to be unwound
|
||||
|
||||
struct State {
|
||||
managed: @nillist,
|
||||
managed: Gc<nillist>,
|
||||
unique: Box<nillist>,
|
||||
tuple: (@nillist, Box<nillist>),
|
||||
vec: Vec<@nillist>,
|
||||
tuple: (Gc<nillist>, Box<nillist>),
|
||||
vec: Vec<Gc<nillist>>,
|
||||
res: r
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,23 +12,25 @@
|
|||
|
||||
extern crate debug;
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct clam {
|
||||
x: @int,
|
||||
y: @int,
|
||||
x: Gc<int>,
|
||||
y: Gc<int>,
|
||||
}
|
||||
|
||||
struct fish {
|
||||
a: @int,
|
||||
a: Gc<int>,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a: clam = clam{x: @1, y: @2};
|
||||
let b: clam = clam{x: @10, y: @20};
|
||||
let a: clam = clam{x: box(GC) 1, y: box(GC) 2};
|
||||
let b: clam = clam{x: box(GC) 10, y: box(GC) 20};
|
||||
let z: int = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `@int`
|
||||
println!("{:?}", z);
|
||||
assert_eq!(z, 21);
|
||||
let forty: fish = fish{a: @40};
|
||||
let two: fish = fish{a: @2};
|
||||
let forty: fish = fish{a: box(GC) 40};
|
||||
let two: fish = fish{a: box(GC) 2};
|
||||
let answer: int = forty.a + two.a;
|
||||
//~^ ERROR binary operation `+` cannot be applied to type `@int`
|
||||
println!("{:?}", answer);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
fn foo<'a>(x: &'a @int) -> &'a int {
|
||||
use std::gc::{GC, Gc};
|
||||
|
||||
fn foo<'a>(x: &'a Gc<int>) -> &'a int {
|
||||
match x {
|
||||
&ref y => {
|
||||
&**y // Do not expect an error here
|
||||
|
|
@ -25,7 +27,7 @@ fn bar() {
|
|||
let a = 3;
|
||||
let mut y = &a;
|
||||
if true {
|
||||
let x = @3;
|
||||
let x = box(GC) 3;
|
||||
y = &*x; //~ ERROR `*x` does not live long enough
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn borrow(x: &int, f: |x: &int|) {
|
||||
let before = *x;
|
||||
|
|
@ -23,13 +24,13 @@ fn borrow(x: &int, f: |x: &int|) {
|
|||
struct F { f: Box<int> }
|
||||
|
||||
pub fn main() {
|
||||
let mut x = @F {f: box 3};
|
||||
let mut x = box(GC) 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: box 4};
|
||||
x = box(GC) F {f: box 4};
|
||||
|
||||
println!("&*b_x = {:p}", &(*b_x));
|
||||
assert_eq!(*b_x, 3);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn borrow(x: &int, f: |x: &int|) {
|
||||
let before = *x;
|
||||
|
|
@ -23,13 +24,13 @@ fn borrow(x: &int, f: |x: &int|) {
|
|||
struct F { f: Box<int> }
|
||||
|
||||
pub fn main() {
|
||||
let mut x = box @F{f: box 3};
|
||||
let mut x = box box(GC) 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: box 4};
|
||||
*x = box(GC) F{f: box 4};
|
||||
|
||||
println!("&*b_x = {:p}", &(*b_x));
|
||||
assert_eq!(*b_x, 3);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn borrow(x: &int, f: |x: &int|) {
|
||||
let before = *x;
|
||||
f(x);
|
||||
|
|
@ -20,13 +22,13 @@ fn borrow(x: &int, f: |x: &int|) {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let mut x = @3;
|
||||
let mut x = box(GC) 3;
|
||||
borrow(x, |b_x| {
|
||||
//~^ ERROR cannot borrow `x` as mutable because `*x` is also borrowed as immutable
|
||||
assert_eq!(*b_x, 3);
|
||||
assert_eq!(&(*x) as *int, &(*b_x) as *int);
|
||||
//~^ NOTE borrow occurs due to use of `x` in closure
|
||||
x = @22;
|
||||
x = box(GC) 22;
|
||||
|
||||
println!("&*b_x = {:p}", &(*b_x));
|
||||
assert_eq!(*b_x, 3);
|
||||
|
|
|
|||
|
|
@ -12,9 +12,11 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn testfn(cond: bool) {
|
||||
let mut x = @3;
|
||||
let mut y = @4;
|
||||
let mut x = box(GC) 3;
|
||||
let mut y = box(GC) 4;
|
||||
|
||||
// borrow x and y
|
||||
let r_x = &*x;
|
||||
|
|
@ -30,13 +32,13 @@ fn testfn(cond: bool) {
|
|||
println!("*r = {}, exp = {}", *r, exp);
|
||||
assert_eq!(*r, exp);
|
||||
|
||||
x = @5; //~ERROR cannot assign to `x` because it is borrowed
|
||||
y = @6; //~ERROR cannot assign to `y` because it is borrowed
|
||||
x = box(GC) 5; //~ERROR cannot assign to `x` because it is borrowed
|
||||
y = box(GC) 6; //~ERROR cannot assign to `y` because it is borrowed
|
||||
|
||||
println!("*r = {}, exp = {}", *r, exp);
|
||||
assert_eq!(*r, exp);
|
||||
assert_eq!(x, @5);
|
||||
assert_eq!(y, @6);
|
||||
assert_eq!(x, box(GC) 5);
|
||||
assert_eq!(y, box(GC) 6);
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn borrow(x: &int, f: |x: &int|) {
|
||||
let before = *x;
|
||||
|
|
@ -23,13 +24,13 @@ fn borrow(x: &int, f: |x: &int|) {
|
|||
struct F { f: Box<int> }
|
||||
|
||||
pub fn main() {
|
||||
let mut x = @F {f: box 3};
|
||||
let mut x = box(GC) 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: box 4};
|
||||
x = box(GC) F {f: box 4};
|
||||
|
||||
println!("&*b_x = {:p}", &(*b_x));
|
||||
assert_eq!(*b_x, 3);
|
||||
|
|
|
|||
|
|
@ -10,12 +10,14 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
fn f<T>(x: T) -> @T {
|
||||
@x //~ ERROR value may contain references
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn f<T>(x: T) -> Gc<T> {
|
||||
box(GC) x //~ ERROR value may contain references
|
||||
}
|
||||
|
||||
fn g<T:'static>(x: T) -> @T {
|
||||
@x // ok
|
||||
fn g<T:'static>(x: T) -> Gc<T> {
|
||||
box(GC) x // ok
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
// Verifies all possible restrictions for static items values.
|
||||
|
||||
use std::kinds::marker;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct WithDtor;
|
||||
|
||||
|
|
@ -95,7 +96,7 @@ static STATIC10: UnsafeStruct = UnsafeStruct;
|
|||
struct MyOwned;
|
||||
|
||||
static STATIC11: Box<MyOwned> = box MyOwned;
|
||||
//~^ ERROR static items are not allowed to have owned pointers
|
||||
//~^ ERROR static items are not allowed to have custom pointers
|
||||
|
||||
// The following examples test that mutable structs are just forbidden
|
||||
// to have types with destructors
|
||||
|
|
@ -113,24 +114,24 @@ static mut STATIC14: SafeStruct = SafeStruct {
|
|||
};
|
||||
|
||||
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
|
||||
//~^ ERROR static items are not allowed to have custom pointers
|
||||
//~^^ ERROR static items are not allowed to have custom pointers
|
||||
|
||||
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
|
||||
//~^ ERROR static items are not allowed to have custom pointers
|
||||
//~^^ ERROR static items are not allowed to have custom pointers
|
||||
|
||||
static mut STATIC17: SafeEnum = Variant1;
|
||||
//~^ ERROR mutable static items are not allowed to have destructors
|
||||
|
||||
static STATIC18: @SafeStruct = @SafeStruct{field1: Variant1, field2: Variant2(0)};
|
||||
//~^ ERROR static items are not allowed to have managed pointers
|
||||
static STATIC18: Gc<SafeStruct> = box(GC) SafeStruct{field1: Variant1, field2: Variant2(0)};
|
||||
//~^ ERROR static items are not allowed to have custom pointers
|
||||
|
||||
static STATIC19: Box<int> = box 3;
|
||||
//~^ ERROR static items are not allowed to have owned pointers
|
||||
//~^ ERROR static items are not allowed to have custom pointers
|
||||
|
||||
pub fn main() {
|
||||
let y = { static x: Box<int> = box 3; x };
|
||||
//~^ ERROR static items are not allowed to have owned pointers
|
||||
//~^ ERROR static items are not allowed to have custom pointers
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@
|
|||
|
||||
// Testing that we can't store a reference it task-local storage
|
||||
|
||||
local_data_key!(key: @&int)
|
||||
use std::gc::{GC, Gc};
|
||||
|
||||
local_data_key!(key: Gc<&int>)
|
||||
//~^ ERROR missing lifetime specifier
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
// 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.
|
||||
|
|
@ -18,7 +20,7 @@ struct t { //~ ERROR this type cannot be instantiated
|
|||
to_str: (),
|
||||
}
|
||||
|
||||
struct x(@t); //~ ERROR this type cannot be instantiated
|
||||
struct x(Gc<t>); //~ ERROR this type cannot be instantiated
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,14 +10,16 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
struct P { child: Option<@P> }
|
||||
use std::gc::Gc;
|
||||
|
||||
struct P { child: Option<Gc<P>> }
|
||||
trait PTrait {
|
||||
fn getChildOption(&self) -> Option<@P>;
|
||||
fn getChildOption(&self) -> Option<Gc<P>>;
|
||||
}
|
||||
|
||||
impl PTrait for P {
|
||||
fn getChildOption(&self) -> Option<@P> {
|
||||
static childVal: @P = self.child.get();
|
||||
fn getChildOption(&self) -> Option<Gc<P>> {
|
||||
static childVal: Gc<P> = self.child.get();
|
||||
//~^ ERROR attempt to use a non-constant value in a constant
|
||||
fail!();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
mod my_mod {
|
||||
pub struct MyStruct {
|
||||
priv_field: int
|
||||
|
|
@ -28,11 +30,11 @@ fn main() {
|
|||
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
||||
let _woohoo = (box my_struct).priv_field;
|
||||
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` is private
|
||||
let _woohoo = (@my_struct).priv_field;
|
||||
let _woohoo = (box(GC) my_struct).priv_field;
|
||||
//~^ ERROR field `priv_field` of struct `my_mod::MyStruct` 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
|
||||
(box(GC) 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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
struct BarStruct;
|
||||
|
||||
impl<'a> BarStruct {
|
||||
fn foo(&'a mut self) -> @BarStruct { self }
|
||||
fn foo(&'a mut self) -> Gc<BarStruct> { self }
|
||||
//~^ ERROR: error: mismatched types: expected `@BarStruct` but found `&'a mut BarStruct
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,9 +11,10 @@
|
|||
#![feature(managed_boxes)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
// Regresion test for issue 7364
|
||||
static managed: @RefCell<int> = @RefCell::new(0);
|
||||
//~^ ERROR static items are not allowed to have managed pointers
|
||||
static managed: Gc<RefCell<int>> = box(GC) RefCell::new(0);
|
||||
//~^ ERROR static items are not allowed to have custom pointers
|
||||
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#![feature(managed_boxes)]
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::gc::Gc;
|
||||
|
||||
fn assert_copy<T:Copy>() { }
|
||||
trait Dummy { }
|
||||
|
|
@ -77,7 +78,7 @@ fn test<'a,T,U:Copy>(_: &'a int) {
|
|||
assert_copy::<MyNoncopyStruct>(); //~ ERROR does not fulfill
|
||||
|
||||
// managed or ref counted types are not ok
|
||||
assert_copy::<@int>(); //~ ERROR does not fulfill
|
||||
assert_copy::<Gc<int>>(); //~ ERROR does not fulfill
|
||||
assert_copy::<Rc<int>>(); //~ ERROR does not fulfill
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
struct Foo {
|
||||
f: @int,
|
||||
f: Gc<int>,
|
||||
}
|
||||
|
||||
impl Drop for Foo {
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
fn foo(_x: @uint) {}
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn foo(_x: Gc<uint>) {}
|
||||
|
||||
fn main() {
|
||||
let x = @3u;
|
||||
let x = box(GC) 3u;
|
||||
let _: proc():Send = proc() foo(x); //~ ERROR does not fulfill `Send`
|
||||
let _: proc():Send = proc() foo(x); //~ ERROR does not fulfill `Send`
|
||||
let _: proc():Send = proc() foo(x); //~ ERROR does not fulfill `Send`
|
||||
|
|
|
|||
|
|
@ -12,9 +12,10 @@
|
|||
#![forbid(heap_memory)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct Foo {
|
||||
x: @int //~ ERROR type uses managed
|
||||
x: Gc<int>, //~ ERROR type uses managed
|
||||
}
|
||||
|
||||
struct Bar { x: Box<int> } //~ ERROR type uses owned
|
||||
|
|
@ -22,7 +23,7 @@ struct Bar { x: Box<int> } //~ ERROR type uses owned
|
|||
fn main() {
|
||||
let _x : Bar = Bar {x : box 10}; //~ ERROR type uses owned
|
||||
|
||||
@2; //~ ERROR type uses managed
|
||||
box(GC) 2; //~ ERROR type uses managed
|
||||
|
||||
box 2; //~ ERROR type uses owned
|
||||
fn g(_: Box<Clone>) {} //~ ERROR type uses owned
|
||||
|
|
|
|||
|
|
@ -12,11 +12,13 @@
|
|||
#![feature(managed_boxes)]
|
||||
#![forbid(managed_heap_memory)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct Foo {
|
||||
x: @int //~ ERROR type uses managed
|
||||
x: Gc<int> //~ ERROR type uses managed
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _x : Foo = Foo {x : @10};
|
||||
let _x : Foo = Foo {x : box(GC) 10};
|
||||
//~^ ERROR type uses managed
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
// Tests that the new `box` syntax works with unique pointers and GC pointers.
|
||||
|
||||
use std::gc::Gc;
|
||||
use std::gc::{Gc, GC};
|
||||
use std::owned::{Box, HEAP};
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
|
|
@ -13,8 +13,9 @@
|
|||
extern crate debug;
|
||||
|
||||
use std::task;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct Port<T>(@T);
|
||||
struct Port<T>(Gc<T>);
|
||||
|
||||
fn main() {
|
||||
struct foo {
|
||||
|
|
@ -32,7 +33,7 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
let x = foo(Port(@()));
|
||||
let x = foo(Port(box(GC) ()));
|
||||
|
||||
task::spawn(proc() {
|
||||
let y = x; //~ ERROR does not fulfill `Send`
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn main() {
|
||||
let f; //~ ERROR cyclic type of infinite size
|
||||
f = @f;
|
||||
f = box(GC) f;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,10 @@
|
|||
extern crate debug;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct r {
|
||||
i: @Cell<int>,
|
||||
i: Gc<Cell<int>>,
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
|
|
@ -27,7 +28,7 @@ impl Drop for r {
|
|||
}
|
||||
}
|
||||
|
||||
fn r(i: @Cell<int>) -> r {
|
||||
fn r(i: Gc<Cell<int>>) -> r {
|
||||
r {
|
||||
i: i
|
||||
}
|
||||
|
|
@ -38,7 +39,7 @@ struct A {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let i = @Cell::new(0);
|
||||
let i = box(GC) Cell::new(0);
|
||||
{
|
||||
// Can't do this copy
|
||||
let x = box box box A {y: r(i)};
|
||||
|
|
|
|||
|
|
@ -12,9 +12,11 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn testfn(cond: bool) {
|
||||
let mut x = @3;
|
||||
let mut y = @4;
|
||||
let mut x = box(GC) 3;
|
||||
let mut y = box(GC) 4;
|
||||
|
||||
let mut a = &*x;
|
||||
|
||||
|
|
@ -25,11 +27,11 @@ fn testfn(cond: bool) {
|
|||
exp = 4;
|
||||
}
|
||||
|
||||
x = @5; //~ERROR cannot assign to `x` because it is borrowed
|
||||
y = @6; //~ERROR cannot assign to `y` because it is borrowed
|
||||
x = box(GC) 5; //~ERROR cannot assign to `x` because it is borrowed
|
||||
y = box(GC) 6; //~ERROR cannot assign to `y` because it is borrowed
|
||||
assert_eq!(*a, exp);
|
||||
assert_eq!(x, @5);
|
||||
assert_eq!(y, @6);
|
||||
assert_eq!(x, box(GC) 5);
|
||||
assert_eq!(y, box(GC) 6);
|
||||
}
|
||||
|
||||
pub fn main() {}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
struct point {
|
||||
x: int,
|
||||
y: int,
|
||||
|
|
@ -19,7 +21,7 @@ fn x_coord<'r>(p: &'r point) -> &'r int {
|
|||
return &p.x;
|
||||
}
|
||||
|
||||
fn foo(p: @point) -> &int {
|
||||
fn foo(p: Gc<point>) -> &int {
|
||||
let xc = x_coord(p); //~ ERROR `*p` does not live long enough
|
||||
assert_eq!(*xc, 3);
|
||||
return xc;
|
||||
|
|
|
|||
|
|
@ -10,9 +10,11 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
fn borrow<'r, T>(x: &'r T) -> &'r T {x}
|
||||
|
||||
fn foo(cond: || -> bool, make_box: || -> @int) {
|
||||
fn foo(cond: || -> bool, make_box: || -> Gc<int>) {
|
||||
let mut y: ∫
|
||||
loop {
|
||||
let x = make_box();
|
||||
|
|
|
|||
|
|
@ -13,24 +13,26 @@
|
|||
// Check that we correctly infer that b and c must be region
|
||||
// parameterized because they reference a which requires a region.
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
type a<'a> = &'a int;
|
||||
type b<'a> = @a<'a>;
|
||||
type b<'a> = Gc<a<'a>>;
|
||||
|
||||
struct c<'a> {
|
||||
f: @b<'a>
|
||||
f: Gc<b<'a>>
|
||||
}
|
||||
|
||||
trait set_f<'a> {
|
||||
fn set_f_ok(&self, b: @b<'a>);
|
||||
fn set_f_bad(&self, b: @b);
|
||||
fn set_f_ok(&self, b: Gc<b<'a>>);
|
||||
fn set_f_bad(&self, b: Gc<b>);
|
||||
}
|
||||
|
||||
impl<'a> set_f<'a> for c<'a> {
|
||||
fn set_f_ok(&self, b: @b<'a>) {
|
||||
fn set_f_ok(&self, b: Gc<b<'a>>) {
|
||||
self.f = b;
|
||||
}
|
||||
|
||||
fn set_f_bad(&self, b: @b) {
|
||||
fn set_f_bad(&self, b: Gc<b>) {
|
||||
self.f = b; //~ ERROR mismatched types: expected `@@&'a int` but found `@@&int`
|
||||
//~^ ERROR cannot infer
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn f<T:'static>(_: T) {}
|
||||
|
||||
fn main() {
|
||||
let x = @3;
|
||||
let x = box(GC) 3;
|
||||
f(x);
|
||||
let x = &3;
|
||||
f(x); //~ ERROR instantiating a type parameter with an incompatible type
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct Foo<'a> {
|
||||
x: &'a int
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let f = Foo { x: @3 }; //~ ERROR borrowed value does not live long enough
|
||||
let f = Foo { x: box(GC) 3 }; //~ ERROR borrowed value does not live long enough
|
||||
assert_eq!(*f.x, 3);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,14 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
struct foo {
|
||||
a: int,
|
||||
b: int,
|
||||
}
|
||||
|
||||
type bar = @foo;
|
||||
type bar = Gc<foo>;
|
||||
|
||||
fn want_foo(f: foo) {}
|
||||
fn have_bar(b: bar) {
|
||||
|
|
|
|||
|
|
@ -10,13 +10,15 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
trait Mumbo {
|
||||
fn jumbo(&self, x: @uint) -> uint;
|
||||
fn jumbo(&self, x: Gc<uint>) -> uint;
|
||||
}
|
||||
|
||||
impl Mumbo for uint {
|
||||
// Cannot have a larger effect than the trait:
|
||||
unsafe fn jumbo(&self, x: @uint) { *self + *x; }
|
||||
unsafe fn jumbo(&self, x: Gc<uint>) { *self + *x; }
|
||||
//~^ ERROR expected normal fn but found unsafe fn
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn f<T:Send>(_i: T) {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let i = box @100;
|
||||
let i = box box(GC) 100;
|
||||
f(i); //~ ERROR does not fulfill `Send`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,9 +12,10 @@
|
|||
|
||||
extern crate debug;
|
||||
use std::cell::Cell;
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct r {
|
||||
i: @Cell<int>,
|
||||
i: Gc<Cell<int>>,
|
||||
}
|
||||
|
||||
#[unsafe_destructor]
|
||||
|
|
@ -30,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 i1 = box(GC) Cell::new(0);
|
||||
let i2 = box(GC) Cell::new(1);
|
||||
let r1 = vec!(box r { i: i1 });
|
||||
let r2 = vec!(box r { i: i2 });
|
||||
f(r1.clone(), r2.clone());
|
||||
|
|
|
|||
|
|
@ -13,12 +13,14 @@
|
|||
// Test that a class with an unsendable field can't be
|
||||
// sent
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct foo {
|
||||
i: int,
|
||||
j: @String,
|
||||
j: Gc<String>,
|
||||
}
|
||||
|
||||
fn foo(i:int, j: @String) -> foo {
|
||||
fn foo(i:int, j: Gc<String>) -> foo {
|
||||
foo {
|
||||
i: i,
|
||||
j: j
|
||||
|
|
@ -28,5 +30,5 @@ fn foo(i:int, j: @String) -> foo {
|
|||
fn main() {
|
||||
let cat = "kitty".to_string();
|
||||
let (tx, _) = channel(); //~ ERROR does not fulfill `Send`
|
||||
tx.send(foo(42, @(cat))); //~ ERROR does not fulfill `Send`
|
||||
tx.send(foo(42, box(GC) (cat))); //~ ERROR does not fulfill `Send`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,47 +63,49 @@
|
|||
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn main() {
|
||||
let bool_box: @bool = @true;
|
||||
let bool_box: Gc<bool> = box(GC) true;
|
||||
let bool_ref: &bool = bool_box;
|
||||
|
||||
let int_box: @int = @-1;
|
||||
let int_box: Gc<int> = box(GC) -1;
|
||||
let int_ref: &int = int_box;
|
||||
|
||||
let char_box: @char = @'a';
|
||||
let char_box: Gc<char> = box(GC) 'a';
|
||||
let char_ref: &char = char_box;
|
||||
|
||||
let i8_box: @i8 = @68;
|
||||
let i8_box: Gc<i8> = box(GC) 68;
|
||||
let i8_ref: &i8 = i8_box;
|
||||
|
||||
let i16_box: @i16 = @-16;
|
||||
let i16_box: Gc<i16> = box(GC) -16;
|
||||
let i16_ref: &i16 = i16_box;
|
||||
|
||||
let i32_box: @i32 = @-32;
|
||||
let i32_box: Gc<i32> = box(GC) -32;
|
||||
let i32_ref: &i32 = i32_box;
|
||||
|
||||
let i64_box: @i64 = @-64;
|
||||
let i64_box: Gc<i64> = box(GC) -64;
|
||||
let i64_ref: &i64 = i64_box;
|
||||
|
||||
let uint_box: @uint = @1;
|
||||
let uint_box: Gc<uint> = box(GC) 1;
|
||||
let uint_ref: &uint = uint_box;
|
||||
|
||||
let u8_box: @u8 = @100;
|
||||
let u8_box: Gc<u8> = box(GC) 100;
|
||||
let u8_ref: &u8 = u8_box;
|
||||
|
||||
let u16_box: @u16 = @16;
|
||||
let u16_box: Gc<u16> = box(GC) 16;
|
||||
let u16_ref: &u16 = u16_box;
|
||||
|
||||
let u32_box: @u32 = @32;
|
||||
let u32_box: Gc<u32> = box(GC) 32;
|
||||
let u32_ref: &u32 = u32_box;
|
||||
|
||||
let u64_box: @u64 = @64;
|
||||
let u64_box: Gc<u64> = box(GC) 64;
|
||||
let u64_ref: &u64 = u64_box;
|
||||
|
||||
let f32_box: @f32 = @2.5;
|
||||
let f32_box: Gc<f32> = box(GC) 2.5;
|
||||
let f32_ref: &f32 = f32_box;
|
||||
|
||||
let f64_box: @f64 = @3.5;
|
||||
let f64_box: Gc<f64> = box(GC) 3.5;
|
||||
let f64_ref: &f64 = f64_box;
|
||||
zzz();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@
|
|||
#![feature(managed_boxes)]
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
struct SomeStruct {
|
||||
x: int,
|
||||
y: f64
|
||||
|
|
@ -60,7 +62,7 @@ fn main() {
|
|||
let stack_val_interior_ref_2: &f64 = &stack_val.y;
|
||||
let ref_to_unnamed: &SomeStruct = &SomeStruct { x: 11, y: 24.5 };
|
||||
|
||||
let managed_val = @SomeStruct { x: 12, y: 25.5 };
|
||||
let managed_val = box(GC) SomeStruct { x: 12, y: 25.5 };
|
||||
let managed_val_ref: &SomeStruct = managed_val;
|
||||
let managed_val_interior_ref_1: &int = &managed_val.x;
|
||||
let managed_val_interior_ref_2: &f64 = &managed_val.y;
|
||||
|
|
|
|||
|
|
@ -31,13 +31,14 @@
|
|||
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn main() {
|
||||
let stack_val: (i16, f32) = (-14, -19f32);
|
||||
let stack_val_ref: &(i16, f32) = &stack_val;
|
||||
let ref_to_unnamed: &(i16, f32) = &(-15, -20f32);
|
||||
|
||||
let managed_val: @(i16, f32) = @(-16, -21f32);
|
||||
let managed_val: Gc<(i16, f32)> = box(GC) (-16, -21f32);
|
||||
let managed_val_ref: &(i16, f32) = managed_val;
|
||||
|
||||
let unique_val: Box<(i16, f32)> = box() (-17, -22f32);
|
||||
|
|
|
|||
|
|
@ -27,11 +27,13 @@
|
|||
#![feature(managed_boxes)]
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn main() {
|
||||
let a = box 1;
|
||||
let b = box() (2, 3.5);
|
||||
let c = @4;
|
||||
let d = @false;
|
||||
let c = box(GC) 4;
|
||||
let d = box(GC) false;
|
||||
_zzz();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#![feature(managed_boxes)]
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
struct StructWithSomePadding {
|
||||
x: i16,
|
||||
|
|
@ -52,10 +53,10 @@ impl Drop for StructWithDestructor {
|
|||
fn main() {
|
||||
|
||||
let unique = box StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 };
|
||||
let managed = @StructWithSomePadding { x: 88, y: 888, z: 8888, w: 88888 };
|
||||
let managed = box(GC) StructWithSomePadding { x: 88, y: 888, z: 8888, w: 88888 };
|
||||
|
||||
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 };
|
||||
let managed_dtor = box(GC) StructWithDestructor { x: 33, y: 333, z: 3333, w: 33333 };
|
||||
|
||||
zzz();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@
|
|||
// gdb-check:$4 = 8888
|
||||
// gdb-command:continue
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
trait Trait {
|
||||
fn method(self) -> Self;
|
||||
}
|
||||
|
|
@ -66,8 +68,8 @@ impl Trait for (f64, int, int, f64) {
|
|||
}
|
||||
}
|
||||
|
||||
impl Trait for @int {
|
||||
fn method(self) -> @int {
|
||||
impl Trait for Gc<int> {
|
||||
fn method(self) -> Gc<int> {
|
||||
zzz();
|
||||
self
|
||||
}
|
||||
|
|
@ -77,7 +79,7 @@ fn main() {
|
|||
let _ = (1111 as int).method();
|
||||
let _ = Struct { x: 2222, y: 3333 }.method();
|
||||
let _ = (4444.5, 5555, 6666, 7777.5).method();
|
||||
let _ = (@8888).method();
|
||||
let _ = (box(GC) 8888).method();
|
||||
}
|
||||
|
||||
fn zzz() {()}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
#![allow(unused_variable)]
|
||||
#![feature(struct_variant, managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
|
||||
// the size of the discriminant value is machine dependent, this has be taken into account when
|
||||
// datatype layout should be predictable as in this case.
|
||||
|
|
@ -50,15 +52,15 @@ fn main() {
|
|||
// 0b01111100011111000111110001111100 = 2088533116
|
||||
// 0b0111110001111100 = 31868
|
||||
// 0b01111100 = 124
|
||||
let the_a = @TheA { x: 0, y: 8970181431921507452 };
|
||||
let the_a = box(GC) TheA { x: 0, y: 8970181431921507452 };
|
||||
|
||||
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
|
||||
// 0b00010001000100010001000100010001 = 286331153
|
||||
// 0b0001000100010001 = 4369
|
||||
// 0b00010001 = 17
|
||||
let the_b = @TheB (0, 286331153, 286331153);
|
||||
let the_b = box(GC) TheB (0, 286331153, 286331153);
|
||||
|
||||
let univariant = @TheOnlyCase(-9747455);
|
||||
let univariant = box(GC) TheOnlyCase(-9747455);
|
||||
|
||||
zzz();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,9 +31,11 @@
|
|||
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn main() {
|
||||
|
||||
let unique: Vec<@i64> = vec!(@10, @11, @12, @13);
|
||||
let unique: Vec<Gc<i64>> = vec!(box(GC) 10, box(GC) 11, box(GC) 12, box(GC) 13);
|
||||
|
||||
zzz();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,15 +29,17 @@
|
|||
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::{GC, Gc};
|
||||
|
||||
struct ContainsManaged {
|
||||
x: int,
|
||||
y: @int
|
||||
y: Gc<int>,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let ordinary_unique = box() (-1, -2);
|
||||
|
||||
let managed_within_unique = box ContainsManaged { x: -3, y: @-4 };
|
||||
let managed_within_unique = box ContainsManaged { x: -3, y: box(GC) -4 };
|
||||
|
||||
zzz();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@
|
|||
#![allow(unused_variable)]
|
||||
#![feature(struct_variant)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
enum Opt<T> {
|
||||
Empty,
|
||||
|
|
@ -118,7 +119,7 @@ struct UniqueNode<T> {
|
|||
}
|
||||
|
||||
struct ManagedNode<T> {
|
||||
next: Opt<@ManagedNode<T>>,
|
||||
next: Opt<Gc<ManagedNode<T>>>,
|
||||
value: T
|
||||
}
|
||||
|
||||
|
|
@ -183,7 +184,7 @@ fn main() {
|
|||
value: 2,
|
||||
};
|
||||
|
||||
let box_unique: @UniqueNode<u64> = @UniqueNode {
|
||||
let box_unique: Gc<UniqueNode<u64>> = box(GC) UniqueNode {
|
||||
next: Val {
|
||||
val: box UniqueNode {
|
||||
next: Empty,
|
||||
|
|
@ -215,7 +216,7 @@ fn main() {
|
|||
|
||||
let stack_managed: ManagedNode<u16> = ManagedNode {
|
||||
next: Val {
|
||||
val: @ManagedNode {
|
||||
val: box(GC) ManagedNode {
|
||||
next: Empty,
|
||||
value: 11,
|
||||
}
|
||||
|
|
@ -225,7 +226,7 @@ fn main() {
|
|||
|
||||
let unique_managed: Box<ManagedNode<u32>> = box ManagedNode {
|
||||
next: Val {
|
||||
val: @ManagedNode {
|
||||
val: box(GC) ManagedNode {
|
||||
next: Empty,
|
||||
value: 13,
|
||||
}
|
||||
|
|
@ -233,9 +234,9 @@ fn main() {
|
|||
value: 12,
|
||||
};
|
||||
|
||||
let box_managed: @ManagedNode<u64> = @ManagedNode {
|
||||
let box_managed: Gc<ManagedNode<u64>> = box(GC) ManagedNode {
|
||||
next: Val {
|
||||
val: @ManagedNode {
|
||||
val: box(GC) ManagedNode {
|
||||
next: Empty,
|
||||
value: 15,
|
||||
}
|
||||
|
|
@ -245,7 +246,7 @@ fn main() {
|
|||
|
||||
let vec_managed: [ManagedNode<f32>, ..1] = [ManagedNode {
|
||||
next: Val {
|
||||
val: @ManagedNode {
|
||||
val: box(GC) ManagedNode {
|
||||
next: Empty,
|
||||
value: 17.5,
|
||||
}
|
||||
|
|
@ -255,7 +256,7 @@ fn main() {
|
|||
|
||||
let borrowed_managed: &ManagedNode<f64> = &ManagedNode {
|
||||
next: Val {
|
||||
val: @ManagedNode {
|
||||
val: box(GC) ManagedNode {
|
||||
next: Empty,
|
||||
value: 19.5,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@
|
|||
#![feature(managed_boxes)]
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
struct Struct {
|
||||
a: int,
|
||||
b: f64,
|
||||
|
|
@ -69,7 +71,7 @@ fn main() {
|
|||
|
||||
let struct_ref = &a_struct;
|
||||
let owned = box 6;
|
||||
let managed = @7;
|
||||
let managed = box(GC) 7;
|
||||
|
||||
let closure = || {
|
||||
let closure_local = 8;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
#![feature(managed_boxes)]
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
struct Struct {
|
||||
a: int,
|
||||
b: f64,
|
||||
|
|
@ -49,7 +51,7 @@ fn main() {
|
|||
|
||||
let struct_ref = &a_struct;
|
||||
let owned = box 6;
|
||||
let managed = @7;
|
||||
let managed = box(GC) 7;
|
||||
|
||||
let closure = || {
|
||||
zzz();
|
||||
|
|
|
|||
|
|
@ -15,33 +15,34 @@
|
|||
#![feature(managed_boxes)]
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::gc::GC;
|
||||
|
||||
fn test1() { let val = @0; { } *val; }
|
||||
fn test1() { let val = box(GC) 0; { } *val; }
|
||||
|
||||
fn test2() -> int { let val = @0; { } *val }
|
||||
fn test2() -> int { let val = box(GC) 0; { } *val }
|
||||
|
||||
struct S { eax: int }
|
||||
|
||||
fn test3() {
|
||||
let regs = @Cell::new(S {eax: 0});
|
||||
let regs = box(GC) Cell::new(S {eax: 0});
|
||||
match true { true => { } _ => { } }
|
||||
regs.set(S {eax: 1});
|
||||
}
|
||||
|
||||
fn test4() -> bool { let regs = @true; if true { } *regs || false }
|
||||
fn test4() -> bool { let regs = box(GC) true; if true { } *regs || false }
|
||||
|
||||
fn test5() -> (int, int) { { } (0, 1) }
|
||||
|
||||
fn test6() -> bool { { } (true || false) && true }
|
||||
|
||||
fn test7() -> uint {
|
||||
let regs = @0;
|
||||
let regs = box(GC) 0;
|
||||
match true { true => { } _ => { } }
|
||||
(*regs < 2) as uint
|
||||
}
|
||||
|
||||
fn test8() -> int {
|
||||
let val = @0;
|
||||
let val = box(GC) 0;
|
||||
match true {
|
||||
true => { }
|
||||
_ => { }
|
||||
|
|
@ -54,12 +55,12 @@ fn test8() -> int {
|
|||
}
|
||||
|
||||
fn test9() {
|
||||
let regs = @Cell::new(0);
|
||||
let regs = box(GC) Cell::new(0);
|
||||
match true { true => { } _ => { } } regs.set(regs.get() + 1);
|
||||
}
|
||||
|
||||
fn test10() -> int {
|
||||
let regs = @vec!(0);
|
||||
let regs = box(GC) vec!(0);
|
||||
match true { true => { } _ => { } }
|
||||
*(*regs).get(0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@
|
|||
#![feature(managed_boxes)]
|
||||
|
||||
// error-pattern:meep
|
||||
fn f(_a: int, _b: int, _c: @int) { fail!("moop"); }
|
||||
|
||||
fn main() { f(1, fail!("meep"), @42); }
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn f(_a: int, _b: int, _c: Gc<int>) { fail!("moop"); }
|
||||
|
||||
fn main() { f(1, fail!("meep"), box(GC) 42); }
|
||||
|
|
|
|||
|
|
@ -13,15 +13,16 @@
|
|||
// error-pattern:explicit failure
|
||||
// Issue #2272 - unwind this without leaking the unique pointer
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct X { y: Y, a: Box<int> }
|
||||
|
||||
struct Y { z: @int }
|
||||
struct Y { z: Gc<int> }
|
||||
|
||||
fn main() {
|
||||
let _x = X {
|
||||
y: Y {
|
||||
z: @0
|
||||
z: box(GC) 0
|
||||
},
|
||||
a: box 0
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn main() {
|
||||
let _a = @0;
|
||||
let _a = box(GC) 0;
|
||||
assert!(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,13 +14,15 @@
|
|||
|
||||
extern crate debug;
|
||||
|
||||
use std::gc::{GC, Gc};
|
||||
|
||||
fn failfn() {
|
||||
fail!();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let y = box 0;
|
||||
let x: @proc():Send = @(proc() {
|
||||
let x: Gc<proc():Send> = box(GC) (proc() {
|
||||
println!("{:?}", y.clone());
|
||||
});
|
||||
failfn();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
extern crate debug;
|
||||
|
||||
use std::mem;
|
||||
use std::gc::GC;
|
||||
|
||||
fn failfn() {
|
||||
fail!();
|
||||
|
|
@ -43,7 +44,7 @@ fn main() {
|
|||
let i1 = box 0;
|
||||
let i1p = mem::transmute_copy(&i1);
|
||||
mem::forget(i1);
|
||||
let x = @r(i1p);
|
||||
let x = box(GC) r(i1p);
|
||||
failfn();
|
||||
println!("{:?}", x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,12 +14,14 @@
|
|||
|
||||
extern crate debug;
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn failfn() {
|
||||
fail!();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = @"hi".to_string();
|
||||
let x = box(GC) "hi".to_string();
|
||||
failfn();
|
||||
println!("{:?}", x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,12 +14,14 @@
|
|||
|
||||
extern crate debug;
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn failfn() {
|
||||
fail!();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = @box box 0;
|
||||
let x = box(GC) box box 0;
|
||||
failfn();
|
||||
println!("{:?}", x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,12 +14,14 @@
|
|||
|
||||
extern crate debug;
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn failfn() {
|
||||
fail!();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = @box 0;
|
||||
let x = box(GC) box 0;
|
||||
failfn();
|
||||
println!("{:?}", x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,12 +14,14 @@
|
|||
|
||||
extern crate debug;
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn failfn() {
|
||||
fail!();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = @vec!(0, 1, 2, 3, 4, 5);
|
||||
let x = box(GC) vec!(0, 1, 2, 3, 4, 5);
|
||||
failfn();
|
||||
println!("{:?}", x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,11 +12,13 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn failfn() {
|
||||
fail!();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@0;
|
||||
box(GC) 0;
|
||||
failfn();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn main() {
|
||||
@0;
|
||||
box(GC) 0;
|
||||
fail!();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
// error-pattern:fail
|
||||
|
||||
fn f() -> @int { fail!(); }
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
fn f() -> Gc<int> { fail!(); }
|
||||
|
||||
fn main() {
|
||||
let _a: @int = f();
|
||||
let _a: Gc<int> = f();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,12 +8,14 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
// error-pattern:fail
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
fn main() {
|
||||
let _a: @int = {
|
||||
let _a: Gc<int> = {
|
||||
fail!();
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,12 +14,14 @@
|
|||
#![allow(unreachable_code)]
|
||||
#![allow(unused_variable)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn x(it: |int|) {
|
||||
fail!();
|
||||
it(0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a = @0;
|
||||
let a = box(GC) 0;
|
||||
x(|_i| { } );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,10 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::{GC};
|
||||
|
||||
fn x(it: |int|) {
|
||||
let _a = @0;
|
||||
let _a = box(GC) 0;
|
||||
it(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,15 +8,17 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern:fail
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
// error-pattern:fail
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn main() {
|
||||
let cheese = "roquefort".to_string();
|
||||
let carrots = @"crunchy".to_string();
|
||||
let carrots = box(GC) "crunchy".to_string();
|
||||
|
||||
let result: |@String, |String||: 'static = (|tasties, macerate| {
|
||||
let result: |Gc<String>, |String||: 'static = (|tasties, macerate| {
|
||||
macerate((*tasties).clone());
|
||||
});
|
||||
result(carrots, |food| {
|
||||
|
|
|
|||
|
|
@ -8,12 +8,15 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
// Issue #945
|
||||
// error-pattern:non-exhaustive match failure
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn test_box() {
|
||||
@0;
|
||||
box(GC) 0;
|
||||
}
|
||||
fn test_str() {
|
||||
let res = match false { true => { "happy".to_string() },
|
||||
|
|
|
|||
|
|
@ -15,15 +15,16 @@
|
|||
|
||||
use std::vec;
|
||||
use std::collections;
|
||||
use std::gc::GC;
|
||||
|
||||
fn main() {
|
||||
let _count = @0u;
|
||||
let _count = box(GC) 0u;
|
||||
let mut map = collections::HashMap::new();
|
||||
let mut arr = Vec::new();
|
||||
for _i in range(0u, 10u) {
|
||||
arr.push(@"key stuff".to_string());
|
||||
arr.push(box(GC) "key stuff".to_string());
|
||||
map.insert(arr.clone(),
|
||||
arr.clone().append([@"value stuff".to_string()]));
|
||||
arr.clone().append([box(GC) "value stuff".to_string()]));
|
||||
if arr.len() == 5 {
|
||||
fail!();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,14 +8,17 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern:fail
|
||||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
// error-pattern:fail
|
||||
fn f(_a: @int) {
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn f(_a: Gc<int>) {
|
||||
fail!();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a = @0;
|
||||
let a = box(GC) 0;
|
||||
f(a);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,12 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn main() {
|
||||
let _a = @0;
|
||||
let _a = box(GC) 0;
|
||||
{
|
||||
let _b = @0;
|
||||
let _b = box(GC) 0;
|
||||
{
|
||||
fail!();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,17 +12,18 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn f() -> Vec<int> { fail!(); }
|
||||
|
||||
// Voodoo. In unwind-alt we had to do this to trigger the bug. Might
|
||||
// have been to do with memory allocation patterns.
|
||||
fn prime() {
|
||||
@0;
|
||||
box(GC) 0;
|
||||
}
|
||||
|
||||
fn partial() {
|
||||
let _x = @f();
|
||||
let _x = box(GC) f();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -12,13 +12,14 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn f() -> Vec<int> { fail!(); }
|
||||
|
||||
// Voodoo. In unwind-alt we had to do this to trigger the bug. Might
|
||||
// have been to do with memory allocation patterns.
|
||||
fn prime() {
|
||||
@0;
|
||||
box(GC) 0;
|
||||
}
|
||||
|
||||
fn partial() {
|
||||
|
|
|
|||
|
|
@ -12,13 +12,14 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn f() -> Vec<int> { fail!(); }
|
||||
|
||||
// Voodoo. In unwind-alt we had to do this to trigger the bug. Might
|
||||
// have been to do with memory allocation patterns.
|
||||
fn prime() {
|
||||
@0;
|
||||
box(GC) 0;
|
||||
}
|
||||
|
||||
fn partial() {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
// error-pattern:squirrel
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
struct r {
|
||||
i: int,
|
||||
}
|
||||
|
|
@ -23,6 +25,6 @@ impl Drop for r {
|
|||
fn r(i: int) -> r { r { i: i } }
|
||||
|
||||
fn main() {
|
||||
@0;
|
||||
box(GC) 0;
|
||||
let _r = r(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
// ignore-test leaks
|
||||
// error-pattern:wombat
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
struct r {
|
||||
i: int,
|
||||
}
|
||||
|
|
@ -22,7 +24,7 @@ impl Drop for r {
|
|||
fn r(i: int) -> r { r { i: i } }
|
||||
|
||||
fn main() {
|
||||
@0;
|
||||
box(GC) 0;
|
||||
let r = r(0);
|
||||
fail!();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,12 +12,14 @@
|
|||
|
||||
// error-pattern:quux
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct faily_box {
|
||||
i: @int
|
||||
i: Gc<int>
|
||||
}
|
||||
// What happens to the box pointer owned by this class?
|
||||
|
||||
fn faily_box(i: @int) -> faily_box { faily_box { i: i } }
|
||||
fn faily_box(i: Gc<int>) -> faily_box { faily_box { i: i } }
|
||||
|
||||
#[unsafe_destructor]
|
||||
impl Drop for faily_box {
|
||||
|
|
@ -27,5 +29,5 @@ impl Drop for faily_box {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
faily_box(@10);
|
||||
faily_box(box(GC) 10);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,17 +12,19 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn f() {
|
||||
let _a = @0;
|
||||
let _a = box(GC) 0;
|
||||
fail!();
|
||||
}
|
||||
|
||||
fn g() {
|
||||
let _b = @0;
|
||||
let _b = box(GC) 0;
|
||||
f();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _a = @0;
|
||||
let _a = box(GC) 0;
|
||||
g();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::Gc;
|
||||
|
||||
// error-pattern:fail
|
||||
|
||||
fn fold_local() -> @Vec<int> {
|
||||
fn fold_local() -> Gc<Vec<int>> {
|
||||
fail!();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,14 +10,15 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
// error-pattern:fail
|
||||
|
||||
fn fold_local() -> @Vec<int> {
|
||||
@vec!(0,0,0,0,0,0)
|
||||
fn fold_local() -> Gc<Vec<int>> {
|
||||
box(GC) vec!(0,0,0,0,0,0)
|
||||
}
|
||||
|
||||
fn fold_remote() -> @Vec<int> {
|
||||
fn fold_remote() -> Gc<Vec<int>> {
|
||||
fail!();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,13 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn f() {
|
||||
fail!();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
f();
|
||||
let _a = @0;
|
||||
let _a = box(GC) 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,22 +17,23 @@
|
|||
extern crate syntax;
|
||||
|
||||
use syntax::ext::base::ExtCtxt;
|
||||
use std::gc::Gc;
|
||||
|
||||
fn syntax_extension(cx: &ExtCtxt) {
|
||||
let e_toks : Vec<syntax::ast::TokenTree> = quote_tokens!(cx, 1 + 2);
|
||||
let p_toks : Vec<syntax::ast::TokenTree> = quote_tokens!(cx, (x, 1 .. 4, *));
|
||||
|
||||
let a: @syntax::ast::Expr = quote_expr!(cx, 1 + 2);
|
||||
let _b: Option<@syntax::ast::Item> = quote_item!(cx, static foo : int = $e_toks; );
|
||||
let _c: @syntax::ast::Pat = quote_pat!(cx, (x, 1 .. 4, *) );
|
||||
let _d: @syntax::ast::Stmt = quote_stmt!(cx, let x = $a; );
|
||||
let _e: @syntax::ast::Expr = quote_expr!(cx, match foo { $p_toks => 10 } );
|
||||
let a: Gc<syntax::ast::Expr> = quote_expr!(cx, 1 + 2);
|
||||
let _b: Option<Gc<syntax::ast::Item>> = quote_item!(cx, static foo : int = $e_toks; );
|
||||
let _c: Gc<syntax::ast::Pat> = quote_pat!(cx, (x, 1 .. 4, *) );
|
||||
let _d: Gc<syntax::ast::Stmt> = quote_stmt!(cx, let x = $a; );
|
||||
let _e: Gc<syntax::ast::Expr> = quote_expr!(cx, match foo { $p_toks => 10 } );
|
||||
|
||||
let _f: @syntax::ast::Expr = quote_expr!(cx, ());
|
||||
let _g: @syntax::ast::Expr = quote_expr!(cx, true);
|
||||
let _h: @syntax::ast::Expr = quote_expr!(cx, 'a');
|
||||
let _f: Gc<syntax::ast::Expr> = quote_expr!(cx, ());
|
||||
let _g: Gc<syntax::ast::Expr> = quote_expr!(cx, true);
|
||||
let _h: Gc<syntax::ast::Expr> = quote_expr!(cx, 'a');
|
||||
|
||||
let i: Option<@syntax::ast::Item> = quote_item!(cx, #[deriving(Eq)] struct Foo; );
|
||||
let i: Option<Gc<syntax::ast::Item>> = quote_item!(cx, #[deriving(Eq)] struct Foo; );
|
||||
assert!(i.is_some());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
#[deriving(PartialEq, Show)]
|
||||
struct Point { x : int }
|
||||
|
||||
|
|
@ -18,5 +20,5 @@ pub fn main() {
|
|||
assert_eq!("abc".to_string(),"abc".to_string());
|
||||
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});
|
||||
assert_eq!(box(GC) Point{x:34},box(GC) Point{x:34});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::{GC, Gc};
|
||||
|
||||
trait double {
|
||||
fn double(self) -> uint;
|
||||
}
|
||||
|
|
@ -18,11 +20,11 @@ impl double for uint {
|
|||
fn double(self) -> uint { self }
|
||||
}
|
||||
|
||||
impl double for @uint {
|
||||
impl double for Gc<uint> {
|
||||
fn double(self) -> uint { *self * 2u }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = @3u;
|
||||
let x = box(GC) 3u;
|
||||
assert_eq!(x.double(), 6u);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,15 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
trait Foo {
|
||||
fn foo(&self) -> String;
|
||||
}
|
||||
|
||||
impl<T:Foo> Foo for @T {
|
||||
impl<T:Foo> Foo for Gc<T> {
|
||||
fn foo(&self) -> String {
|
||||
format!("@{}", (**self).foo())
|
||||
format!("box(GC) {}", (**self).foo())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -27,6 +29,6 @@ impl Foo for uint {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
let x = @3u;
|
||||
assert_eq!(x.foo(), "@3".to_string());
|
||||
let x = box(GC) 3u;
|
||||
assert_eq!(x.foo(), "box(GC) 3".to_string());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
fn test_nil() {
|
||||
assert_eq!((), ());
|
||||
assert!((!(() != ())));
|
||||
|
|
@ -45,7 +47,7 @@ fn test_bool() {
|
|||
}
|
||||
|
||||
fn test_box() {
|
||||
assert_eq!(@10, @10);
|
||||
assert_eq!(box(GC) 10, box(GC) 10);
|
||||
}
|
||||
|
||||
fn test_ptr() {
|
||||
|
|
|
|||
|
|
@ -10,12 +10,13 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn borrow(x: &int, f: |x: &int|) {
|
||||
f(x)
|
||||
}
|
||||
|
||||
fn test1(x: @Box<int>) {
|
||||
fn test1(x: Gc<Box<int>>) {
|
||||
borrow(&*(*x).clone(), |p| {
|
||||
let x_a = &**x as *int;
|
||||
assert!((x_a as uint) != (p as *int as uint));
|
||||
|
|
@ -24,5 +25,5 @@ fn test1(x: @Box<int>) {
|
|||
}
|
||||
|
||||
pub fn main() {
|
||||
test1(@box 22);
|
||||
test1(box(GC) box 22);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,22 +15,24 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
fn free<T>(x: @T) {}
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn free<T>(x: Gc<T>) {}
|
||||
|
||||
struct Foo {
|
||||
f: @Bar
|
||||
f: Gc<Bar>
|
||||
}
|
||||
|
||||
struct Bar {
|
||||
g: int
|
||||
}
|
||||
|
||||
fn lend(x: @Foo) -> int {
|
||||
fn lend(x: Gc<Foo>) -> int {
|
||||
let y = &x.f.g;
|
||||
free(x); // specifically here, if x is not rooted, it will be freed
|
||||
*y
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!(lend(@Foo {f: @Bar {g: 22}}), 22);
|
||||
assert_eq!(lend(box(GC) Foo {f: box(GC) Bar {g: 22}}), 22);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,12 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::{GC, Gc};
|
||||
|
||||
struct F { f: @G }
|
||||
struct F { f: Gc<G> }
|
||||
struct G { g: Vec<int> }
|
||||
|
||||
pub fn main() {
|
||||
let rec = @F {f: @G {g: vec!(1, 2, 3)}};
|
||||
let rec = box(GC) F {f: box(GC) G {g: vec!(1, 2, 3)}};
|
||||
while rec.f.g.len() == 23 {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,13 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn borrow<'r,T>(x: &'r T) -> &'r T {x}
|
||||
|
||||
struct Rec { f: @int }
|
||||
struct Rec { f: Gc<int> }
|
||||
|
||||
pub fn main() {
|
||||
let rec = @Rec {f: @22};
|
||||
let rec = box(GC) Rec {f: box(GC) 22};
|
||||
while *borrow(rec.f) == 23 {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#![feature(managed_boxes)]
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::gc::GC;
|
||||
|
||||
enum newtype {
|
||||
newtype(int)
|
||||
|
|
@ -21,8 +22,8 @@ pub fn main() {
|
|||
// Test that borrowck treats enums with a single variant
|
||||
// specially.
|
||||
|
||||
let x = @Cell::new(5);
|
||||
let y = @Cell::new(newtype(3));
|
||||
let x = box(GC) Cell::new(5);
|
||||
let y = box(GC) Cell::new(newtype(3));
|
||||
let z = match y.get() {
|
||||
newtype(b) => {
|
||||
x.set(x.get() + 1);
|
||||
|
|
|
|||
|
|
@ -10,8 +10,12 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::GC;
|
||||
|
||||
pub fn main() {
|
||||
assert!((@1 < @3));
|
||||
assert!((@@"hello ".to_string() > @@"hello".to_string()));
|
||||
assert!((@@@"hello".to_string() != @@@"there".to_string()));
|
||||
assert!((box(GC) 1 < box(GC) 3));
|
||||
assert!((box(GC) box(GC) "hello ".to_string() >
|
||||
box(GC) box(GC) "hello".to_string()));
|
||||
assert!((box(GC) box(GC) box(GC) "hello".to_string() !=
|
||||
box(GC) box(GC) box(GC) "there".to_string()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
pub fn main() {
|
||||
let i: (@int, int) = (@10, 10);
|
||||
let i: (Gc<int>, int) = (box(GC) 10, 10);
|
||||
let (_a, _) = i;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
fn some_box(x: int) -> @int { return @x; }
|
||||
use std::gc::{GC, Gc};
|
||||
|
||||
fn some_box(x: int) -> Gc<int> { return box(GC) x; }
|
||||
|
||||
fn is_odd(_n: int) -> bool { return true; }
|
||||
|
||||
fn length_is_even(_vs: @int) -> bool { return true; }
|
||||
fn length_is_even(_vs: Gc<int>) -> bool { return true; }
|
||||
|
||||
fn foo(_acc: int, n: int) {
|
||||
if is_odd(n) && length_is_even(some_box(1)) { println!("bloop"); }
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
fn some_box(x: int) -> @int { return @x; }
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
fn some_box(x: int) -> Gc<int> { return box(GC) x; }
|
||||
|
||||
fn is_odd(_n: int) -> bool { return true; }
|
||||
|
||||
fn length_is_even(_vs: @int) -> bool { return true; }
|
||||
fn length_is_even(_vs: Gc<int>) -> bool { return true; }
|
||||
|
||||
fn foo(_acc: int, n: int) {
|
||||
if is_odd(n) || length_is_even(some_box(1)) { println!("bloop"); }
|
||||
|
|
|
|||
|
|
@ -10,13 +10,15 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
struct Box<T> {c: @T}
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
struct Box<T> {c: Gc<T>}
|
||||
|
||||
fn unbox<T:Clone>(b: Box<T>) -> T { return (*b.c).clone(); }
|
||||
|
||||
pub fn main() {
|
||||
let foo: int = 17;
|
||||
let bfoo: Box<int> = Box {c: @foo};
|
||||
let bfoo: Box<int> = Box {c: box(GC) foo};
|
||||
println!("see what's in our box");
|
||||
assert_eq!(unbox::<int>(bfoo), foo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,4 +10,6 @@
|
|||
|
||||
#![feature(managed_boxes)]
|
||||
|
||||
pub fn main() { let x: @int = @10; assert!((*x == 10)); }
|
||||
use std::gc::{Gc, GC};
|
||||
|
||||
pub fn main() { let x: Gc<int> = box(GC) 10; assert!((*x == 10)); }
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue