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
|
|
@ -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`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue