diff options
| author | bors <bors@rust-lang.org> | 2014-10-03 05:02:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-10-03 05:02:37 +0000 |
| commit | aa034cd3bac3155e0f6c74c399314b5ee32f88fc (patch) | |
| tree | 891acff8f9158a69e1884707ca3bfb70d749db2e /src/test/compile-fail | |
| parent | d0af3feebb57bc58c52de69ab51f92dc7082500b (diff) | |
| parent | d911936dbdc645133ad9605f45d2bf10b73e2b20 (diff) | |
| download | rust-aa034cd3bac3155e0f6c74c399314b5ee32f88fc.tar.gz rust-aa034cd3bac3155e0f6c74c399314b5ee32f88fc.zip | |
auto merge of #17725 : alexcrichton/rust/rollup, r=alexcrichton
Diffstat (limited to 'src/test/compile-fail')
39 files changed, 105 insertions, 497 deletions
diff --git a/src/test/compile-fail/autoderef-full-lval.rs b/src/test/compile-fail/autoderef-full-lval.rs index 276c830cf5d..7aa3b30ce49 100644 --- a/src/test/compile-fail/autoderef-full-lval.rs +++ b/src/test/compile-fail/autoderef-full-lval.rs @@ -8,30 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -extern crate debug; - -use std::gc::{Gc, GC}; - struct clam { - x: Gc<int>, - y: Gc<int>, + x: Box<int>, + y: Box<int>, } struct fish { - a: Gc<int>, + a: Box<int>, } fn main() { - 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 `Gc<int>` - println!("{:?}", z); + let a: clam = clam{x: box 1, y: box 2}; + let b: clam = clam{x: box 10, y: box 20}; + let z: int = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `Box<int>` + println!("{}", z); assert_eq!(z, 21); - let forty: fish = fish{a: box(GC) 40}; - let two: fish = fish{a: box(GC) 2}; + let forty: fish = fish{a: box 40}; + let two: fish = fish{a: box 2}; let answer: int = forty.a + two.a; - //~^ ERROR binary operation `+` cannot be applied to type `Gc<int>` - println!("{:?}", answer); + //~^ ERROR binary operation `+` cannot be applied to type `Box<int>` + println!("{}", answer); assert_eq!(answer, 42); } diff --git a/src/test/compile-fail/borrowck-preserve-box-in-field.rs b/src/test/compile-fail/borrowck-preserve-box-in-field.rs deleted file mode 100644 index ad1ac3cc15e..00000000000 --- a/src/test/compile-fail/borrowck-preserve-box-in-field.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2012-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. - -// exec-env:RUST_POISON_ON_FREE=1 - - -use std::gc::GC; - -fn borrow(x: &int, f: |x: &int|) { - let before = *x; - f(x); - let after = *x; - assert_eq!(before, after); -} - -struct F { f: Box<int> } - -pub fn main() { - 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 *const int, &(*b_x) as *const int); - //~^ NOTE borrow occurs due to use of `x` in closure - x = box(GC) F {f: box 4}; - - println!("&*b_x = {:p}", &(*b_x)); - assert_eq!(*b_x, 3); - assert!(&(*x.f) as *const int != &(*b_x) as *const int); - }) -} diff --git a/src/test/compile-fail/borrowck-preserve-box-in-uniq.rs b/src/test/compile-fail/borrowck-preserve-box-in-uniq.rs deleted file mode 100644 index ec52f058836..00000000000 --- a/src/test/compile-fail/borrowck-preserve-box-in-uniq.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2012-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. - -// exec-env:RUST_POISON_ON_FREE=1 - - -use std::gc::GC; - -fn borrow(x: &int, f: |x: &int|) { - let before = *x; - f(x); - let after = *x; - assert_eq!(before, after); -} - -struct F { f: Box<int> } - -pub fn main() { - 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 *const int, &(*b_x) as *const int); - //~^ NOTE borrow occurs due to use of `x` in closure - *x = box(GC) F{f: box 4}; - - println!("&*b_x = {:p}", &(*b_x)); - assert_eq!(*b_x, 3); - assert!(&(*x.f) as *const int != &(*b_x) as *const int); - }) -} diff --git a/src/test/compile-fail/borrowck-preserve-box.rs b/src/test/compile-fail/borrowck-preserve-box.rs deleted file mode 100644 index 5aff482a323..00000000000 --- a/src/test/compile-fail/borrowck-preserve-box.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2012-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. - -// exec-env:RUST_POISON_ON_FREE=1 - - -use std::gc::GC; - -fn borrow(x: &int, f: |x: &int|) { - let before = *x; - f(x); - let after = *x; - assert_eq!(before, after); -} - -pub fn main() { - 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 *const int, &(*b_x) as *const int); - //~^ NOTE borrow occurs due to use of `x` in closure - x = box(GC) 22; - - println!("&*b_x = {:p}", &(*b_x)); - assert_eq!(*b_x, 3); - assert!(&(*x) as *const int != &(*b_x) as *const int); - }) -} diff --git a/src/test/compile-fail/borrowck-preserve-cond-box.rs b/src/test/compile-fail/borrowck-preserve-cond-box.rs deleted file mode 100644 index 6c3c340b97a..00000000000 --- a/src/test/compile-fail/borrowck-preserve-cond-box.rs +++ /dev/null @@ -1,46 +0,0 @@ -// 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. - -// exec-env:RUST_POISON_ON_FREE=1 - - -use std::gc::GC; - -fn testfn(cond: bool) { - let mut x = box(GC) 3i; - let mut y = box(GC) 4i; - - // borrow x and y - let r_x = &*x; - let r_y = &*y; - let mut r = r_x; - let mut exp = 3; - - if cond { - r = r_y; - exp = 4; - } - - println!("*r = {}, exp = {}", *r, exp); - assert_eq!(*r, exp); - - x = box(GC) 5i; //~ERROR cannot assign to `x` because it is borrowed - y = box(GC) 6i; //~ERROR cannot assign to `y` because it is borrowed - - println!("*r = {}, exp = {}", *r, exp); - assert_eq!(*r, exp); - assert_eq!(x, box(GC) 5i); - assert_eq!(y, box(GC) 6i); -} - -pub fn main() { - testfn(true); - testfn(false); -} diff --git a/src/test/compile-fail/borrowck-preserve-expl-deref.rs b/src/test/compile-fail/borrowck-preserve-expl-deref.rs deleted file mode 100644 index 2ad042c69c3..00000000000 --- a/src/test/compile-fail/borrowck-preserve-expl-deref.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2012-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. - -// exec-env:RUST_POISON_ON_FREE=1 - - -use std::gc::GC; - -fn borrow(x: &int, f: |x: &int|) { - let before = *x; - f(x); - let after = *x; - assert_eq!(before, after); -} - -struct F { f: Box<int> } - -pub fn main() { - 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 *const int, &(*b_x) as *const int); - //~^ NOTE borrow occurs due to use of `x` in closure - x = box(GC) F {f: box 4}; - - println!("&*b_x = {:p}", &(*b_x)); - assert_eq!(*b_x, 3); - assert!(&(*x.f) as *const int != &(*b_x) as *const int); - }) -} diff --git a/src/test/compile-fail/check-static-values-constraints.rs b/src/test/compile-fail/check-static-values-constraints.rs index 3e67419843c..e29be22ca9a 100644 --- a/src/test/compile-fail/check-static-values-constraints.rs +++ b/src/test/compile-fail/check-static-values-constraints.rs @@ -11,7 +11,6 @@ // Verifies all possible restrictions for static items values. use std::kinds::marker; -use std::gc::{Gc, GC}; struct WithDtor; @@ -124,9 +123,6 @@ static STATIC16: (&'static Box<MyOwned>, &'static Box<MyOwned>) = static mut STATIC17: SafeEnum = Variant1; //~^ ERROR mutable static items are not allowed to have destructors -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 custom pointers diff --git a/src/test/compile-fail/core-tls-store-pointer.rs b/src/test/compile-fail/core-tls-store-pointer.rs index 06079a5487f..d77c552be03 100644 --- a/src/test/compile-fail/core-tls-store-pointer.rs +++ b/src/test/compile-fail/core-tls-store-pointer.rs @@ -8,11 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Testing that we can't store a reference it task-local storage +// Testing that we can't store a reference in task-local storage -use std::gc::{GC, Gc}; - -local_data_key!(key: Gc<&int>) +local_data_key!(key: Box<&int>) //~^ ERROR missing lifetime specifier fn main() {} diff --git a/src/test/compile-fail/lint-managed-heap-memory.rs b/src/test/compile-fail/issue-13497-2.rs index 0a28242fb1b..c7a8c87bb23 100644 --- a/src/test/compile-fail/lint-managed-heap-memory.rs +++ b/src/test/compile-fail/issue-13497-2.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -8,16 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(dead_code)] -#![forbid(managed_heap_memory)] - -use std::gc::{Gc, GC}; - -struct Foo { - x: Gc<int> //~ ERROR type uses managed +fn read_lines_borrowed<'a>() -> Vec<&'a str> { + let rawLines: Vec<String> = vec!["foo ".to_string(), " bar".to_string()]; + rawLines //~ ERROR `rawLines` does not live long enough + .iter().map(|l| l.as_slice().trim()).collect() } -fn main() { - let _x : Foo = Foo {x : box(GC) 10}; - //~^ ERROR type uses managed -} +fn main() {} diff --git a/src/test/compile-fail/borrowck-borrow-immut-deref-of-gc-as-mut.rs b/src/test/compile-fail/issue-13497.rs index 91eb20d19ed..da8b93e3c93 100644 --- a/src/test/compile-fail/borrowck-borrow-immut-deref-of-gc-as-mut.rs +++ b/src/test/compile-fail/issue-13497.rs @@ -8,18 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -use std::gc::GC; - -struct A; - -impl A { - fn foo(&mut self) { - } +fn read_lines_borrowed1() -> Vec< + &str //~ ERROR missing lifetime specifier +> { + let rawLines: Vec<String> = vec!["foo ".to_string(), " bar".to_string()]; + rawLines.iter().map(|l| l.as_slice().trim()).collect() } -pub fn main() { - let a = box(GC) A; - a.foo(); - //~^ ERROR cannot borrow immutable dereference of `Gc` `*a` as mutable -} +fn main() {} diff --git a/src/test/compile-fail/borrowck-managed-pointer-deref-scope.rs b/src/test/compile-fail/issue-14366.rs index a8a79056fb1..ceb6daac65e 100644 --- a/src/test/compile-fail/borrowck-managed-pointer-deref-scope.rs +++ b/src/test/compile-fail/issue-14366.rs @@ -8,27 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Verify that managed pointers scope is treated like owned pointers. -// regression test for #11586 - - -use std::gc::{GC, Gc}; - -fn foo(x: &Gc<int>) -> &int { - match x { - &ref y => { - &**y // Do not expect an error here - } - } +fn main() { + let _x = "test" as &::std::any::Any; +//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `str` +//~^^ NOTE the trait `core::kinds::Sized` must be implemented for the cast to the object type +//~^^^ ERROR the trait `core::kinds::Sized` is not implemented for the type `str` +//~^^^^ NOTE the trait `core::kinds::Sized` must be implemented for the cast to the object type } - -fn bar() { - let a = 3i; - let mut y = &a; - if true { - let x = box(GC) 3i; - y = &*x; //~ ERROR `*x` does not live long enough - } -} - -fn main() {} diff --git a/src/test/compile-fail/new-box-syntax-bad.rs b/src/test/compile-fail/issue-14853.rs index 602ffe2680b..4243b98e0dd 100644 --- a/src/test/compile-fail/new-box-syntax-bad.rs +++ b/src/test/compile-fail/issue-14853.rs @@ -8,17 +8,23 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ +use std::fmt::Show; -// Tests that the new `box` syntax works with unique pointers and GC pointers. +trait Something { + fn yay<T: Show>(_: Option<Self>, thing: &[T]) -> String { + } +} -use std::gc::{Gc, GC}; -use std::boxed::{Box, HEAP}; +struct X { data: u32 } -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: Box<int> = box(GC)(4 + 5); //~ ERROR mismatched types +impl Something for X { + fn yay<T: Str>(_:Option<X>, thing: &[T]) -> String { +//~^ ERROR in method `yay`, type parameter 0 requires bound `core::str::Str`, which is not required + format!("{:s}", thing[0]) + } } +fn main() { + let arr = &["one", "two", "three"]; + println!("{}", Something::yay(None::<X>, arr)); +} diff --git a/src/test/compile-fail/issue-14915.rs b/src/test/compile-fail/issue-14915.rs index 4512eb3f70a..8cbbfb7b83a 100644 --- a/src/test/compile-fail/issue-14915.rs +++ b/src/test/compile-fail/issue-14915.rs @@ -8,12 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::gc::{GC,Gc}; - fn main() { let x: Box<int> = box 0; - let y: Gc<int> = box (GC) 0; println!("{}", x + 1); //~ ERROR binary operation `+` cannot be applied to type `Box<int>` - println!("{}", y + 1); //~ ERROR binary operation `+` cannot be applied to type `Gc<int>` } diff --git a/src/test/compile-fail/box-static-bound.rs b/src/test/compile-fail/issue-17444.rs index 29ee79b0079..33777e820ed 100644 --- a/src/test/compile-fail/box-static-bound.rs +++ b/src/test/compile-fail/issue-17444.rs @@ -8,15 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -use std::gc::{Gc, GC}; - -fn f<T>(x: T) -> Gc<T> { - box(GC) x //~ ERROR the parameter type `T` may not live long enough +enum Test { + Foo = 0 } -fn g<T:'static>(x: T) -> Gc<T> { - box(GC) x // ok +fn main() { + let _x = Foo as *const int; + //~^ ERROR illegal cast; cast through an integer first: `Test` as `*const int` } - -fn main() {} diff --git a/src/test/compile-fail/issue-2063-resource.rs b/src/test/compile-fail/issue-2063-resource.rs index 577ac480f60..30cf7ee7d88 100644 --- a/src/test/compile-fail/issue-2063-resource.rs +++ b/src/test/compile-fail/issue-2063-resource.rs @@ -9,17 +9,14 @@ // except according to those terms. -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. -struct t { //~ ERROR this type cannot be instantiated - x: x, +struct S { //~ ERROR this type cannot be instantiated + x: X, to_str: (), } -struct x(Gc<t>); //~ ERROR this type cannot be instantiated +struct X(Box<S>); //~ ERROR this type cannot be instantiated -fn main() { -} +fn main() {} diff --git a/src/test/compile-fail/issue-3668.rs b/src/test/compile-fail/issue-3668.rs index d3bd17a7742..cccf730095b 100644 --- a/src/test/compile-fail/issue-3668.rs +++ b/src/test/compile-fail/issue-3668.rs @@ -8,17 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -use std::gc::Gc; - -struct P { child: Option<Gc<P>> } +struct P { child: Option<Box<P>> } trait PTrait { - fn getChildOption(&self) -> Option<Gc<P>>; + fn getChildOption(&self) -> Option<Box<P>>; } impl PTrait for P { - fn getChildOption(&self) -> Option<Gc<P>> { - static childVal: Gc<P> = self.child.get(); + fn getChildOption(&self) -> Option<Box<P>> { + static childVal: Box<P> = self.child.get(); //~^ ERROR attempt to use a non-constant value in a constant fail!(); } diff --git a/src/test/compile-fail/issue-3763.rs b/src/test/compile-fail/issue-3763.rs index 9003578a0bb..73d42aa0de1 100644 --- a/src/test/compile-fail/issue-3763.rs +++ b/src/test/compile-fail/issue-3763.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - mod my_mod { pub struct MyStruct { priv_field: int @@ -29,11 +27,8 @@ 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 = (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 - (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 } diff --git a/src/test/compile-fail/issue-7061.rs b/src/test/compile-fail/issue-7061.rs index a9e9416beb3..c6869c44057 100644 --- a/src/test/compile-fail/issue-7061.rs +++ b/src/test/compile-fail/issue-7061.rs @@ -8,14 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -use std::gc::Gc; - struct BarStruct; impl<'a> BarStruct { - fn foo(&'a mut self) -> Gc<BarStruct> { self } - //~^ ERROR: error: mismatched types: expected `Gc<BarStruct>`, found `&'a mut BarStruct + fn foo(&'a mut self) -> Box<BarStruct> { self } + //~^ ERROR: error: mismatched types: expected `Box<BarStruct>`, found `&'a mut BarStruct } fn main() {} diff --git a/src/test/compile-fail/issue-7364.rs b/src/test/compile-fail/issue-7364.rs index 1c0295974c9..e29b8bc04d8 100644 --- a/src/test/compile-fail/issue-7364.rs +++ b/src/test/compile-fail/issue-7364.rs @@ -10,10 +10,9 @@ use std::cell::RefCell; -use std::gc::{Gc, GC}; // Regresion test for issue 7364 -static managed: Gc<RefCell<int>> = box(GC) RefCell::new(0); +static boxed: Box<RefCell<int>> = box RefCell::new(0); //~^ ERROR static items are not allowed to have custom pointers fn main() { } diff --git a/src/test/compile-fail/kindck-copy.rs b/src/test/compile-fail/kindck-copy.rs index 3524d11d184..499144698fb 100644 --- a/src/test/compile-fail/kindck-copy.rs +++ b/src/test/compile-fail/kindck-copy.rs @@ -12,7 +12,6 @@ use std::rc::Rc; -use std::gc::Gc; fn assert_copy<T:Copy>() { } trait Dummy { } @@ -76,8 +75,7 @@ fn test<'a,T,U:Copy>(_: &'a int) { // structs containing non-POD are not ok assert_copy::<MyNoncopyStruct>(); //~ ERROR `core::kinds::Copy` is not implemented - // managed or ref counted types are not ok - assert_copy::<Gc<int>>(); //~ ERROR `core::kinds::Copy` is not implemented + // ref counted types are not ok assert_copy::<Rc<int>>(); //~ ERROR `core::kinds::Copy` is not implemented } diff --git a/src/test/compile-fail/kindck-destructor-owned.rs b/src/test/compile-fail/kindck-destructor-owned.rs index e50bb8fbede..26b0c5503e3 100644 --- a/src/test/compile-fail/kindck-destructor-owned.rs +++ b/src/test/compile-fail/kindck-destructor-owned.rs @@ -9,10 +9,10 @@ // except according to those terms. -use std::gc::Gc; +use std::rc::Rc; struct Foo { - f: Gc<int>, + f: Rc<int>, } impl Drop for Foo { diff --git a/src/test/compile-fail/kindck-nonsendable-1.rs b/src/test/compile-fail/kindck-nonsendable-1.rs index f292d159982..6ca3f0174bb 100644 --- a/src/test/compile-fail/kindck-nonsendable-1.rs +++ b/src/test/compile-fail/kindck-nonsendable-1.rs @@ -9,12 +9,12 @@ // except according to those terms. -use std::gc::{Gc, GC}; +use std::rc::Rc; -fn foo(_x: Gc<uint>) {} +fn foo(_x: Rc<uint>) {} fn main() { - let x = box(GC) 3u; + let x = Rc::new(3u); let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented let _: proc():Send = proc() foo(x); //~ ERROR `core::kinds::Send` is not implemented diff --git a/src/test/compile-fail/lint-heap-memory.rs b/src/test/compile-fail/lint-heap-memory.rs deleted file mode 100644 index 375969ffb52..00000000000 --- a/src/test/compile-fail/lint-heap-memory.rs +++ /dev/null @@ -1,30 +0,0 @@ -// 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. - -#![forbid(heap_memory)] -#![allow(dead_code)] - -use std::gc::{Gc, GC}; - -struct Foo { - x: Gc<int>, //~ ERROR type uses managed -} - -struct Bar { x: Box<int> } //~ ERROR type uses owned - -fn main() { - let _x : Bar = Bar {x : box 10i}; //~ ERROR type uses owned - - box(GC) 2i; //~ ERROR type uses managed - - box 2i; //~ ERROR type uses owned - fn g(_: Box<Clone>) {} //~ ERROR type uses owned - proc() {}; //~ ERROR type uses owned -} diff --git a/src/test/compile-fail/no-send-res-ports.rs b/src/test/compile-fail/no-send-res-ports.rs index ddbfbc41eca..83dbd9ac1bf 100644 --- a/src/test/compile-fail/no-send-res-ports.rs +++ b/src/test/compile-fail/no-send-res-ports.rs @@ -10,14 +10,14 @@ #![feature(unsafe_destructor)] -extern crate debug; - use std::task; -use std::gc::{Gc, GC}; +use std::rc::Rc; -struct Port<T>(Gc<T>); +#[deriving(Show)] +struct Port<T>(Rc<T>); fn main() { + #[deriving(Show)] struct foo { _x: Port<()>, } @@ -33,11 +33,11 @@ fn main() { } } - let x = foo(Port(box(GC) ())); + let x = foo(Port(Rc::new(()))); task::spawn(proc() { let y = x; //~^ ERROR `core::kinds::Send` is not implemented - println!("{:?}", y); + println!("{}", y); }); } diff --git a/src/test/compile-fail/occurs-check-2.rs b/src/test/compile-fail/occurs-check-2.rs index 69c012e0d8e..2765182225f 100644 --- a/src/test/compile-fail/occurs-check-2.rs +++ b/src/test/compile-fail/occurs-check-2.rs @@ -8,11 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::gc::GC; fn main() { let f; let g; g = f; - f = box(GC) g; //~ ERROR cyclic type of infinite size + f = box g; //~ ERROR cyclic type of infinite size } diff --git a/src/test/compile-fail/occurs-check.rs b/src/test/compile-fail/occurs-check.rs index a00528616c3..44318b36f4b 100644 --- a/src/test/compile-fail/occurs-check.rs +++ b/src/test/compile-fail/occurs-check.rs @@ -9,9 +9,7 @@ // except according to those terms. -use std::gc::GC; - fn main() { let f; - f = box(GC) f; //~ ERROR cyclic type of infinite size + f = box f; //~ ERROR cyclic type of infinite size } diff --git a/src/test/compile-fail/pat-range-bad-dots.rs b/src/test/compile-fail/pat-range-bad-dots.rs index b3c436f6d2b..5605caaeeed 100644 --- a/src/test/compile-fail/pat-range-bad-dots.rs +++ b/src/test/compile-fail/pat-range-bad-dots.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test - pub fn main() { match 22i { 0 .. 3 => {} //~ ERROR expected `=>`, found `..` diff --git a/src/test/compile-fail/pinned-deep-copy.rs b/src/test/compile-fail/pinned-deep-copy.rs deleted file mode 100644 index 0e8bb40e0ff..00000000000 --- a/src/test/compile-fail/pinned-deep-copy.rs +++ /dev/null @@ -1,50 +0,0 @@ -// 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(unsafe_destructor)] - -extern crate debug; - -use std::cell::Cell; -use std::gc::{Gc, GC}; - -struct r { - i: Gc<Cell<int>>, -} - -#[unsafe_destructor] -impl Drop for r { - fn drop(&mut self) { - unsafe { - self.i.set(self.i.get() + 1); - } - } -} - -fn r(i: Gc<Cell<int>>) -> r { - r { - i: i - } -} - -struct A { - y: r, -} - -fn main() { - let i = box(GC) Cell::new(0); - { - // Can't do this copy - let x = box box box A {y: r(i)}; - let _z = x.clone(); //~ ERROR not implemented - println!("{:?}", x); - } - println!("{:?}", *i); -} diff --git a/src/test/compile-fail/regions-appearance-constraint.rs b/src/test/compile-fail/regions-appearance-constraint.rs deleted file mode 100644 index 2c068052c54..00000000000 --- a/src/test/compile-fail/regions-appearance-constraint.rs +++ /dev/null @@ -1,36 +0,0 @@ -// 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. - -// Test no-special rooting is used for managed boxes - - -use std::gc::GC; - -fn testfn(cond: bool) { - let mut x = box(GC) 3i; - let mut y = box(GC) 4i; - - let mut a = &*x; - - let mut exp = 3i; - if cond { - a = &*y; - - exp = 4; - } - - x = box(GC) 5i; //~ERROR cannot assign to `x` because it is borrowed - y = box(GC) 6i; //~ERROR cannot assign to `y` because it is borrowed - assert_eq!(*a, exp); - assert_eq!(x, box(GC) 5i); - assert_eq!(y, box(GC) 6i); -} - -pub fn main() {} diff --git a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs index fc513b91f89..b710578969b 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-too-big.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::Gc; - struct point { x: int, y: int, @@ -20,7 +18,7 @@ fn x_coord<'r>(p: &'r point) -> &'r int { return &p.x; } -fn foo<'a>(p: Gc<point>) -> &'a int { +fn foo<'a>(p: Box<point>) -> &'a int { let xc = x_coord(&*p); //~ ERROR `*p` does not live long enough assert_eq!(*xc, 3); return xc; diff --git a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs index 623b8e6319f..cf1fa2cfc4c 100644 --- a/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs +++ b/src/test/compile-fail/regions-infer-borrow-scope-within-loop.rs @@ -9,11 +9,9 @@ // except according to those terms. -use std::gc::Gc; - fn borrow<T>(x: &T) -> &T {x} -fn foo(cond: || -> bool, make_box: || -> Gc<int>) { +fn foo(cond: || -> bool, make_box: || -> Box<int>) { let mut y: ∫ loop { let x = make_box(); diff --git a/src/test/compile-fail/regions-infer-paramd-indirect.rs b/src/test/compile-fail/regions-infer-paramd-indirect.rs index e862b36dcd1..f93907f5e5c 100644 --- a/src/test/compile-fail/regions-infer-paramd-indirect.rs +++ b/src/test/compile-fail/regions-infer-paramd-indirect.rs @@ -12,27 +12,25 @@ // 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> = Gc<a<'a>>; +type b<'a> = Box<a<'a>>; struct c<'a> { - f: Gc<b<'a>> + f: Box<b<'a>> } trait set_f<'a> { - fn set_f_ok(&mut self, b: Gc<b<'a>>); - fn set_f_bad(&mut self, b: Gc<b>); + fn set_f_ok(&mut self, b: Box<b<'a>>); + fn set_f_bad(&mut self, b: Box<b>); } impl<'a> set_f<'a> for c<'a> { - fn set_f_ok(&mut self, b: Gc<b<'a>>) { + fn set_f_ok(&mut self, b: Box<b<'a>>) { self.f = b; } - fn set_f_bad(&mut self, b: Gc<b>) { - self.f = b; //~ ERROR mismatched types: expected `Gc<Gc<&'a int>>`, found `Gc<Gc<&int>>` + fn set_f_bad(&mut self, b: Box<b>) { + self.f = b; //~ ERROR mismatched types: expected `Box<Box<&'a int>>`, found `Box<Box<&int>>` } } diff --git a/src/test/compile-fail/static-region-bound.rs b/src/test/compile-fail/static-region-bound.rs index 2cb1f462e1d..1e5a5ecc08e 100644 --- a/src/test/compile-fail/static-region-bound.rs +++ b/src/test/compile-fail/static-region-bound.rs @@ -9,12 +9,10 @@ // except according to those terms. -use std::gc::GC; - fn f<T:'static>(_: T) {} fn main() { - let x = box(GC) 3i; + let x = box 3i; f(x); let x = &3i; //~ ERROR borrowed value does not live long enough f(x); diff --git a/src/test/compile-fail/struct-field-assignability.rs b/src/test/compile-fail/struct-field-assignability.rs index 557341fd4f0..2c3d48e9bf7 100644 --- a/src/test/compile-fail/struct-field-assignability.rs +++ b/src/test/compile-fail/struct-field-assignability.rs @@ -11,13 +11,11 @@ // except according to those terms. -use std::gc::{Gc, GC}; - struct Foo<'a> { x: &'a int } pub fn main() { - let f = Foo { x: &*(box(GC) 3) }; //~ ERROR borrowed value does not live long enough + let f = Foo { x: &*(box 3) }; //~ ERROR borrowed value does not live long enough assert_eq!(*f.x, 3); } diff --git a/src/test/compile-fail/terr-sorts.rs b/src/test/compile-fail/terr-sorts.rs index 0817d7c610a..53ebe1f9b5b 100644 --- a/src/test/compile-fail/terr-sorts.rs +++ b/src/test/compile-fail/terr-sorts.rs @@ -9,18 +9,16 @@ // except according to those terms. -use std::gc::Gc; - struct foo { a: int, b: int, } -type bar = Gc<foo>; +type bar = Box<foo>; fn want_foo(f: foo) {} fn have_bar(b: bar) { - want_foo(b); //~ ERROR (expected struct foo, found Gc-ptr) + want_foo(b); //~ ERROR (expected struct foo, found box) } fn main() {} diff --git a/src/test/compile-fail/trait-impl-method-mismatch.rs b/src/test/compile-fail/trait-impl-method-mismatch.rs index bd844cc5860..73224c7b45c 100644 --- a/src/test/compile-fail/trait-impl-method-mismatch.rs +++ b/src/test/compile-fail/trait-impl-method-mismatch.rs @@ -9,15 +9,13 @@ // except according to those terms. -use std::gc::Gc; - trait Mumbo { - fn jumbo(&self, x: Gc<uint>) -> uint; + fn jumbo(&self, x: &uint) -> uint; } impl Mumbo for uint { // Cannot have a larger effect than the trait: - unsafe fn jumbo(&self, x: Gc<uint>) { *self + *x; } + unsafe fn jumbo(&self, x: &uint) { *self + *x; } //~^ ERROR expected normal fn, found unsafe fn } diff --git a/src/test/compile-fail/unique-unique-kind.rs b/src/test/compile-fail/unique-unique-kind.rs index 7d6cdaef85b..4c2805bf4bd 100644 --- a/src/test/compile-fail/unique-unique-kind.rs +++ b/src/test/compile-fail/unique-unique-kind.rs @@ -9,12 +9,12 @@ // except according to those terms. -use std::gc::GC; +use std::rc::Rc; fn f<T:Send>(_i: T) { } fn main() { - let i = box box(GC) 100i; + let i = box Rc::new(100i); f(i); //~ ERROR `core::kinds::Send` is not implemented } diff --git a/src/test/compile-fail/unique-vec-res.rs b/src/test/compile-fail/unique-vec-res.rs index 54b1fdea719..79f29c6b359 100644 --- a/src/test/compile-fail/unique-vec-res.rs +++ b/src/test/compile-fail/unique-vec-res.rs @@ -10,16 +10,15 @@ #![feature(unsafe_destructor)] -extern crate debug; use std::cell::Cell; -use std::gc::{Gc, GC}; -struct r { - i: Gc<Cell<int>>, +#[deriving(Show)] +struct r<'a> { + i: &'a Cell<int>, } #[unsafe_destructor] -impl Drop for r { +impl<'a> Drop for r<'a> { fn drop(&mut self) { unsafe { self.i.set(self.i.get() + 1); @@ -31,13 +30,13 @@ fn f<T>(_i: Vec<T> , _j: Vec<T> ) { } fn main() { - let i1 = box(GC) Cell::new(0); - let i2 = box(GC) Cell::new(1); + let i1 = &Cell::new(0); + let i2 = &Cell::new(1); let r1 = vec!(box r { i: i1 }); let r2 = vec!(box r { i: i2 }); f(r1.clone(), r2.clone()); //~^ ERROR the trait `core::clone::Clone` is not implemented //~^^ ERROR the trait `core::clone::Clone` is not implemented - println!("{:?}", (r2, i1.get())); - println!("{:?}", (r1, i2.get())); + println!("{}", (r2, i1.get())); + println!("{}", (r1, i2.get())); } diff --git a/src/test/compile-fail/unsendable-class.rs b/src/test/compile-fail/unsendable-class.rs index c3fea8e86d4..102cb636550 100644 --- a/src/test/compile-fail/unsendable-class.rs +++ b/src/test/compile-fail/unsendable-class.rs @@ -12,14 +12,14 @@ // Test that a class with an unsendable field can't be // sent -use std::gc::{Gc, GC}; +use std::rc::Rc; struct foo { i: int, - j: Gc<String>, + j: Rc<String>, } -fn foo(i:int, j: Gc<String>) -> foo { +fn foo(i:int, j: Rc<String>) -> foo { foo { i: i, j: j @@ -29,5 +29,5 @@ fn foo(i:int, j: Gc<String>) -> foo { fn main() { let cat = "kitty".to_string(); let (tx, _) = channel(); //~ ERROR `core::kinds::Send` is not implemented - tx.send(foo(42, box(GC) (cat))); //~ ERROR `core::kinds::Send` is not implemented + tx.send(foo(42, Rc::new(cat))); //~ ERROR `core::kinds::Send` is not implemented } |
