diff --git a/src/doc/guide-pointers.md b/src/doc/guide-pointers.md index b920ffbdd1a18..dd9c687172247 100644 --- a/src/doc/guide-pointers.md +++ b/src/doc/guide-pointers.md @@ -632,19 +632,6 @@ This part is coming soon. This part is coming soon. -# Gc - -The `Gc` type exists for historical reasons, and is [still used -internally](https://github.com/rust-lang/rust/issues/7929) by the compiler. -It is not even a 'real' garbage collected type at the moment. - -In the future, Rust may have a real garbage collected type, and so it -has not yet been removed for that reason. - -## Best practices - -There is currently no legitimate use case for the `Gc` type. - # Raw Pointers This part is coming soon. diff --git a/src/doc/guide-runtime.md b/src/doc/guide-runtime.md index 66a1e46c82acb..578ff0edf144b 100644 --- a/src/doc/guide-runtime.md +++ b/src/doc/guide-runtime.md @@ -31,7 +31,6 @@ list): * Task synchronization * Task-local storage * Logging -* Local heaps (GC heaps) * Task unwinding ## What is the runtime accomplishing? diff --git a/src/doc/guide-unsafe.md b/src/doc/guide-unsafe.md index 1e67c8a13e9df..fe6664bd8480a 100644 --- a/src/doc/guide-unsafe.md +++ b/src/doc/guide-unsafe.md @@ -208,9 +208,7 @@ pub struct Unique { // Implement methods for creating and using the values in the box. // NB: For simplicity and correctness, we require that T has kind Send -// (owned boxes relax this restriction, and can contain managed (GC) boxes). -// This is because, as implemented, the garbage collector would not know -// about any shared boxes stored in the malloc'd region of memory. +// (owned boxes relax this restriction). impl Unique { pub fn new(value: T) -> Unique { unsafe { diff --git a/src/doc/reference.md b/src/doc/reference.md index c3b61f6435c49..ecd583937f4aa 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -3381,7 +3381,7 @@ fn main() { ``` -Patterns can also dereference pointers by using the `&`, `box` or `@` symbols, +Patterns can also dereference pointers by using the `&`, `box` symbols, as appropriate. For example, these two matches on `x: &int` are equivalent: ``` diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 503c484e469d7..c31d746d8f2a7 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -92,7 +92,6 @@ pub use boxed as owned; pub mod heap; pub mod libc_heap; -pub mod util; // Primitive types using the heaps above diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index ec19844a24abd..049bf4eb1b02d 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -541,14 +541,6 @@ mod tests { assert!(y.upgrade().is_none()); } - #[test] - fn gc_inside() { - // see issue #11532 - use std::gc::GC; - let a = Rc::new(RefCell::new(box(GC) 1i)); - assert!(a.try_borrow_mut().is_some()); - } - #[test] fn weak_self_cyclic() { struct Cycle { diff --git a/src/liballoc/util.rs b/src/liballoc/util.rs deleted file mode 100644 index d5f0d25fb01f9..0000000000000 --- a/src/liballoc/util.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![doc(hidden)] - -use core::mem; -use core::raw; - -#[inline] -#[deprecated] -pub fn get_box_size(body_size: uint, body_align: uint) -> uint { - let header_size = mem::size_of::>(); - let total_size = align_to(header_size, body_align) + body_size; - total_size -} - -// Rounds size to the next alignment. Alignment is required to be a power of -// two. -#[inline] -fn align_to(size: uint, align: uint) -> uint { - assert!(align != 0); - (size + align - 1) & !(align - 1) -} diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 4d0aaf8390707..b74324c85c03a 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -20,7 +20,7 @@ html_playground_url = "http://play.rust-lang.org/")] #![allow(unknown_features)] -#![feature(macro_rules, managed_boxes, default_type_params, phase, globs)] +#![feature(macro_rules, default_type_params, phase, globs)] #![feature(unsafe_destructor, import_shadowing, slicing_syntax)] #![no_std] diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index 0e1c39535bed4..c9c824ac9cebf 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -532,7 +532,6 @@ impl fmt::Show for RingBuf { mod tests { use std::fmt::Show; use std::prelude::*; - use std::gc::{GC, Gc}; use std::hash; use test::Bencher; use test; @@ -587,43 +586,6 @@ mod tests { assert_eq!(*d.get(3), 4); } - #[test] - #[allow(deprecated)] - fn test_boxes() { - let a: Gc = box(GC) 5; - let b: Gc = box(GC) 72; - let c: Gc = box(GC) 64; - let d: Gc = box(GC) 175; - - let mut deq = RingBuf::new(); - assert_eq!(deq.len(), 0); - deq.push_front(a); - deq.push_front(b); - deq.push(c); - assert_eq!(deq.len(), 3); - deq.push(d); - assert_eq!(deq.len(), 4); - assert_eq!(deq.front(), Some(&b)); - assert_eq!(deq.back(), Some(&d)); - assert_eq!(deq.pop_front(), Some(b)); - assert_eq!(deq.pop(), Some(d)); - assert_eq!(deq.pop(), Some(c)); - assert_eq!(deq.pop(), Some(a)); - assert_eq!(deq.len(), 0); - deq.push(c); - assert_eq!(deq.len(), 1); - deq.push_front(b); - assert_eq!(deq.len(), 2); - deq.push(d); - assert_eq!(deq.len(), 3); - deq.push_front(a); - assert_eq!(deq.len(), 4); - assert_eq!(*deq.get(0), a); - assert_eq!(*deq.get(1), b); - assert_eq!(*deq.get(2), c); - assert_eq!(*deq.get(3), d); - } - #[cfg(test)] fn test_parameterized(a: T, b: T, c: T, d: T) { let mut deq = RingBuf::new(); @@ -755,12 +717,6 @@ mod tests { test_parameterized::(5, 72, 64, 175); } - #[test] - fn test_param_at_int() { - test_parameterized::>(box(GC) 5, box(GC) 72, - box(GC) 64, box(GC) 175); - } - #[test] fn test_param_taggy() { test_parameterized::(One(1), Two(1, 2), Three(1, 2, 3), Two(17, 42)); diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 4890dc2bb7393..584d09c75c8ea 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -58,7 +58,7 @@ #![no_std] #![allow(unknown_features)] -#![feature(globs, intrinsics, lang_items, macro_rules, managed_boxes, phase)] +#![feature(globs, intrinsics, lang_items, macro_rules, phase)] #![feature(simd, unsafe_destructor, slicing_syntax)] #![deny(missing_doc)] diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index 86b96ff15f156..a62e2ecdca032 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -20,15 +20,6 @@ use mem; -/// The representation of `std::gc::Gc`. -pub struct GcBox { - pub ref_count: uint, - pub drop_glue: fn(ptr: *mut u8), - pub prev: *mut GcBox, - pub next: *mut GcBox, - pub data: T, -} - /// The representation of a Rust slice pub struct Slice { pub data: *const T, diff --git a/src/libcoretest/iter.rs b/src/libcoretest/iter.rs index e84c894796736..9e47142478e6b 100644 --- a/src/libcoretest/iter.rs +++ b/src/libcoretest/iter.rs @@ -529,9 +529,8 @@ fn test_rposition() { #[test] #[should_fail] fn test_rposition_fail() { - use std::gc::GC; - let v = [(box 0i, box(GC) 0i), (box 0i, box(GC) 0i), - (box 0i, box(GC) 0i), (box 0i, box(GC) 0i)]; + let v = [(box 0i, box 0i), (box 0i, box 0i), + (box 0i, box 0i), (box 0i, box 0i)]; let mut i = 0i; v.iter().rposition(|_elt| { if i == 2 { diff --git a/src/libdebug/lib.rs b/src/libdebug/lib.rs index 6341a38056359..21abfae8be963 100644 --- a/src/libdebug/lib.rs +++ b/src/libdebug/lib.rs @@ -25,7 +25,7 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/master/")] #![experimental] -#![feature(managed_boxes, macro_rules)] +#![feature(macro_rules)] #![allow(experimental)] pub mod fmt; diff --git a/src/libdebug/reflect.rs b/src/libdebug/reflect.rs index 80d0f8a879412..1e771a2b40a23 100644 --- a/src/libdebug/reflect.rs +++ b/src/libdebug/reflect.rs @@ -18,7 +18,6 @@ Runtime type reflection use std::intrinsics::{Disr, Opaque, TyDesc, TyVisitor}; use std::mem; -use std::gc::Gc; /** * Trait for visitor that wishes to reflect on data. @@ -194,9 +193,9 @@ impl TyVisitor for MovePtrAdaptor { } fn visit_box(&mut self, mtbl: uint, inner: *const TyDesc) -> bool { - self.align_to::>(); + self.align_to::>(); if ! self.inner.visit_box(mtbl, inner) { return false; } - self.bump_past::>(); + self.bump_past::>(); true } diff --git a/src/libdebug/repr.rs b/src/libdebug/repr.rs index 5fbba286feadf..e27816c816539 100644 --- a/src/libdebug/repr.rs +++ b/src/libdebug/repr.rs @@ -274,13 +274,9 @@ impl<'a> TyVisitor for ReprVisitor<'a> { self.get::<&str>(|this, s| this.write_escaped_slice(*s)) } - fn visit_box(&mut self, mtbl: uint, inner: *const TyDesc) -> bool { - try!(self, self.writer.write("box(GC) ".as_bytes())); - self.write_mut_qualifier(mtbl); - self.get::<&raw::GcBox<()>>(|this, b| { - let p = &b.data as *const () as *const u8; - this.visit_ptr_inner(p, inner) - }) + fn visit_box(&mut self, _mtbl: uint, _inner: *const TyDesc) -> bool { + try!(self, self.writer.write("box(GC) ???".as_bytes())); + true } fn visit_uniq(&mut self, _mtbl: uint, inner: *const TyDesc) -> bool { @@ -576,7 +572,6 @@ fn test_repr() { use std::io::stdio::println; use std::char::is_alphabetic; use std::mem::swap; - use std::gc::GC; fn exact_test(t: &T, e:&str) { let mut m = io::MemWriter::new(); @@ -591,7 +586,6 @@ fn test_repr() { exact_test(&1.234f64, "1.234f64"); exact_test(&("hello"), "\"hello\""); - exact_test(&(box(GC) 10i), "box(GC) 10"); exact_test(&(box 10i), "box 10"); exact_test(&(&10i), "&10"); let mut x = 10i; @@ -605,8 +599,6 @@ fn test_repr() { "&[\"hi\", \"there\"]"); exact_test(&(P{a:10, b:1.234}), "repr::P{a: 10, b: 1.234f64}"); - exact_test(&(box(GC) P{a:10, b:1.234}), - "box(GC) repr::P{a: 10, b: 1.234f64}"); exact_test(&(box P{a:10, b:1.234}), "box repr::P{a: 10, b: 1.234f64}"); diff --git a/src/libfourcc/lib.rs b/src/libfourcc/lib.rs index 3aa4005879232..388373807d856 100644 --- a/src/libfourcc/lib.rs +++ b/src/libfourcc/lib.rs @@ -50,7 +50,7 @@ fn main() { html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/master/")] -#![feature(plugin_registrar, managed_boxes)] +#![feature(plugin_registrar)] extern crate syntax; extern crate rustc; diff --git a/src/libhexfloat/lib.rs b/src/libhexfloat/lib.rs index ae7a3e66dfdf8..2fcc3b9691a25 100644 --- a/src/libhexfloat/lib.rs +++ b/src/libhexfloat/lib.rs @@ -46,7 +46,7 @@ fn main() { #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/master/")] -#![feature(plugin_registrar, managed_boxes)] +#![feature(plugin_registrar)] extern crate syntax; extern crate rustc; diff --git a/src/libregex_macros/lib.rs b/src/libregex_macros/lib.rs index 3535038b6a5a0..67018769fb371 100644 --- a/src/libregex_macros/lib.rs +++ b/src/libregex_macros/lib.rs @@ -19,7 +19,7 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/master/")] -#![feature(plugin_registrar, managed_boxes, quote)] +#![feature(plugin_registrar, quote)] extern crate regex; extern crate syntax; diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 277ecfc686b4d..213e8b44813a0 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -412,26 +412,16 @@ impl LintPass for CTypes { } } -declare_lint!(MANAGED_HEAP_MEMORY, Allow, - "use of managed (@ type) heap memory") - declare_lint!(OWNED_HEAP_MEMORY, Allow, "use of owned (Box type) heap memory") -declare_lint!(HEAP_MEMORY, Allow, - "use of any (Box type or @ type) heap memory") - pub struct HeapMemory; impl HeapMemory { fn check_heap_type(&self, cx: &Context, span: Span, ty: ty::t) { - let mut n_box = 0i; let mut n_uniq = 0i; ty::fold_ty(cx.tcx, ty, |t| { match ty::get(t).sty { - ty::ty_box(_) => { - n_box += 1; - } ty::ty_uniq(_) | ty::ty_closure(box ty::ClosureTy { store: ty::UniqTraitStore, @@ -449,21 +439,13 @@ impl HeapMemory { let s = ty_to_string(cx.tcx, ty); let m = format!("type uses owned (Box type) pointers: {}", s); cx.span_lint(OWNED_HEAP_MEMORY, span, m.as_slice()); - cx.span_lint(HEAP_MEMORY, span, m.as_slice()); - } - - if n_box > 0 { - let s = ty_to_string(cx.tcx, ty); - let m = format!("type uses managed (@ type) pointers: {}", s); - cx.span_lint(MANAGED_HEAP_MEMORY, span, m.as_slice()); - cx.span_lint(HEAP_MEMORY, span, m.as_slice()); } } } impl LintPass for HeapMemory { fn get_lints(&self) -> LintArray { - lint_array!(MANAGED_HEAP_MEMORY, OWNED_HEAP_MEMORY, HEAP_MEMORY) + lint_array!(OWNED_HEAP_MEMORY) } fn check_item(&mut self, cx: &Context, it: &ast::Item) { @@ -1289,7 +1271,7 @@ impl LintPass for UnnecessaryAllocation { fn check_expr(&mut self, cx: &Context, e: &ast::Expr) { match e.node { - ast::ExprUnary(ast::UnUniq, _) | ast::ExprUnary(ast::UnBox, _) => (), + ast::ExprUnary(ast::UnUniq, _) => (), _ => return } diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index ce5494ef477cf..a07518cf3f2d3 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -397,7 +397,6 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t { assert_eq!(next(st), '|'); return ty::mk_param(st.tcx, space, index, did); } - '@' => return ty::mk_box(st.tcx, parse_ty(st, |x,y| conv(x,y))), '~' => return ty::mk_uniq(st.tcx, parse_ty(st, |x,y| conv(x,y))), '*' => return ty::mk_ptr(st.tcx, parse_mt(st, |x,y| conv(x,y))), '&' => { diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index fd3e4fe6738c7..e3d8d0e53757d 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -244,7 +244,6 @@ fn enc_sty(w: &mut SeekableMemWriter, cx: &ctxt, st: &ty::sty) { for t in ts.iter() { enc_ty(w, cx, *t); } mywrite!(w, "]"); } - ty::ty_box(typ) => { mywrite!(w, "@"); enc_ty(w, cx, typ); } ty::ty_uniq(typ) => { mywrite!(w, "~"); enc_ty(w, cx, typ); } ty::ty_ptr(mt) => { mywrite!(w, "*"); enc_mt(w, cx, mt); } ty::ty_rptr(r, mt) => { diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index a5111cdf7c8f5..e114eb88705bf 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -815,11 +815,6 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { return; } - mc::cat_deref(_, _, mc::GcPtr) => { - assert_eq!(cmt.mutbl, mc::McImmutable); - return; - } - mc::cat_rvalue(..) | mc::cat_static_item | mc::cat_deref(_, _, mc::UnsafePtr(..)) | diff --git a/src/librustc/middle/borrowck/doc.rs b/src/librustc/middle/borrowck/doc.rs index 9fc291d397191..882b6bc842644 100644 --- a/src/librustc/middle/borrowck/doc.rs +++ b/src/librustc/middle/borrowck/doc.rs @@ -74,7 +74,7 @@ to an `LV` of `(*a).f`. Here is the formal grammar for the types we'll consider: ```text -TY = () | S<'LT...> | Box | & 'LT MQ TY | @ MQ TY +TY = () | S<'LT...> | Box | & 'LT MQ TY MQ = mut | imm | const ``` @@ -263,9 +263,7 @@ compatible with the aliasability of `LV`. The goal is to prevent `&mut` borrows of aliasability data. 3. `LIFETIME(LV, LT, MQ)`: The lifetime of the borrow does not exceed -the lifetime of the value being borrowed. This pass is also -responsible for inserting root annotations to keep managed values -alive. +the lifetime of the value being borrowed. 4. `RESTRICTIONS(LV, LT, ACTIONS) = RS`: This pass checks and computes the restrictions to maintain memory safety. These are the restrictions @@ -316,17 +314,13 @@ MUTABILITY(*LV, MQ) // M-Deref-Unique ### Checking mutability of immutable pointer types -Immutable pointer types like `&T` and `@T` can only +Immutable pointer types like `&T` can only be borrowed if MQ is immutable or const: ```text MUTABILITY(*LV, MQ) // M-Deref-Borrowed-Imm TYPE(LV) = &Ty MQ == imm | const - -MUTABILITY(*LV, MQ) // M-Deref-Managed-Imm - TYPE(LV) = @Ty - MQ == imm | const ``` ### Checking mutability of mutable pointer types @@ -390,11 +384,10 @@ ALIASABLE(*LV, MQ) // M-Deref-Borrowed-Mut ## Checking lifetime These rules aim to ensure that no data is borrowed for a scope that exceeds -its lifetime. In addition, these rules manage the rooting of `@` values. -These two computations wind up being intimately related. Formally, we define -a predicate `LIFETIME(LV, LT, MQ)`, which states that "the lvalue `LV` can be -safely borrowed for the lifetime `LT` with mutability `MQ`". The Rust -code corresponding to this predicate is the module +its lifetime. These two computations wind up being intimately related. +Formally, we define a predicate `LIFETIME(LV, LT, MQ)`, which states that +"the lvalue `LV` can be safely borrowed for the lifetime `LT` with mutability +`MQ`". The Rust code corresponding to this predicate is the module `middle::borrowck::gather_loans::lifetime`. ### The Scope function @@ -423,14 +416,6 @@ the pointer itself `LV` goes out of scope: SCOPE(*LV) = SCOPE(LV) if LV has type Box ``` -The scope of a managed referent is also the scope of the pointer. This -is a conservative approximation, since there may be other aliases for -that same managed box that would cause it to live longer: - -```text - SCOPE(*LV) = SCOPE(LV) if LV has type @T -``` - The scope of a borrowed referent is the scope associated with the pointer. This is a conservative approximation, since the data that the pointer points at may actually live longer: @@ -477,59 +462,6 @@ LIFETIME(*LV, LT, MQ) // L-Deref-Borrowed LT <= LT' ``` -### Checking lifetime for derefs of managed, immutable pointers - -Managed pointers are valid so long as the data within them is -*rooted*. There are two ways that this can be achieved. The first is -when the user guarantees such a root will exist. For this to be true, -three conditions must be met: - -```text -LIFETIME(*LV, LT, MQ) // L-Deref-Managed-Imm-User-Root - TYPE(LV) = @Ty - LT <= SCOPE(LV) // (1) - LV is immutable // (2) - LV is not moved or not movable // (3) -``` - -Condition (1) guarantees that the managed box will be rooted for at -least the lifetime `LT` of the borrow, presuming that no mutation or -moves occur. Conditions (2) and (3) then serve to guarantee that the -value is not mutated or moved. Note that lvalues are either -(ultimately) owned by a local variable, in which case we can check -whether that local variable is ever moved in its scope, or they are -owned by the referent of an (immutable, due to condition 2) managed or -references, in which case moves are not permitted because the -location is aliasable. - -If the conditions of `L-Deref-Managed-Imm-User-Root` are not met, then -there is a second alternative. The compiler can attempt to root the -managed pointer itself. This permits great flexibility, because the -location `LV` where the managed pointer is found does not matter, but -there are some limitations. The lifetime of the borrow can only extend -to the innermost enclosing loop or function body. This guarantees that -the compiler never requires an unbounded amount of stack space to -perform the rooting; if this condition were violated, the compiler -might have to accumulate a list of rooted objects, for example if the -borrow occurred inside the body of a loop but the scope of the borrow -extended outside the loop. More formally, the requirement is that -there is no path starting from the borrow that leads back to the -borrow without crossing the exit from the scope `LT`. - -The rule for compiler rooting is as follows: - -```text -LIFETIME(*LV, LT, MQ) // L-Deref-Managed-Imm-Compiler-Root - TYPE(LV) = @Ty - LT <= innermost enclosing loop/func - ROOT LV at *LV for LT -``` - -Here I have written `ROOT LV at *LV FOR LT` to indicate that the code -makes a note in a side-table that the box `LV` must be rooted into the -stack when `*LV` is evaluated, and that this root can be released when -the scope `LT` exits. - ## Computing the restrictions The final rules govern the computation of *restrictions*, meaning that @@ -599,22 +531,18 @@ RESTRICTIONS(*LV, LT, ACTIONS) = RS, (*LV, ACTIONS) // R-Deref-Send-Pointer RESTRICTIONS(LV, LT, ACTIONS|MUTATE|CLAIM) = RS ``` -### Restrictions for loans of immutable managed/borrowed referents +### Restrictions for loans of immutable borrowed referents -Immutable managed/borrowed referents are freely aliasable, meaning that +Immutable borrowed referents are freely aliasable, meaning that the compiler does not prevent you from copying the pointer. This implies that issuing restrictions is useless. We might prevent the user from acting on `*LV` itself, but there could be another path `*LV1` that refers to the exact same memory, and we would not be -restricting that path. Therefore, the rule for `&Ty` and `@Ty` -pointers always returns an empty set of restrictions, and it only -permits restricting `MUTATE` and `CLAIM` actions: +restricting that path. Therefore, the rule for `&Ty` pointers +always returns an empty set of restrictions, and it only permits +restricting `MUTATE` and `CLAIM` actions: ```text -RESTRICTIONS(*LV, LT, ACTIONS) = [] // R-Deref-Imm-Managed - TYPE(LV) = @Ty - ACTIONS subset of [MUTATE, CLAIM] - RESTRICTIONS(*LV, LT, ACTIONS) = [] // R-Deref-Imm-Borrowed TYPE(LV) = <' Ty LT <= LT' // (1) @@ -623,8 +551,8 @@ RESTRICTIONS(*LV, LT, ACTIONS) = [] // R-Deref-Imm-Borrowed The reason that we can restrict `MUTATE` and `CLAIM` actions even without a restrictions list is that it is never legal to mutate nor to -borrow mutably the contents of a `&Ty` or `@Ty` pointer. In other -words, those restrictions are already inherent in the type. +borrow mutably the contents of a `&Ty` pointer. In other words, +those restrictions are already inherent in the type. Clause (1) in the rule for `&Ty` deserves mention. Here I specify that the lifetime of the loan must be less than the lifetime @@ -729,13 +657,12 @@ are affine.) Freeze pointers are read-only. There may be `&mut` or `&` aliases, and we can not prevent *anything* but moves in that case. So the `RESTRICTIONS` function is only defined if `ACTIONS` is the empty set. -Because moves from a `&const` or `@const` lvalue are never legal, it -is not necessary to add any restrictions at all to the final -result. +Because moves from a `&const` lvalue are never legal, it is not +necessary to add any restrictions at all to the final result. ```text RESTRICTIONS(*LV, LT, []) = [] // R-Deref-Freeze-Borrowed - TYPE(LV) = &const Ty or @const Ty + TYPE(LV) = &const Ty ``` ### Restrictions for loans of mutable borrowed referents @@ -957,8 +884,7 @@ moves and the declaration of uninitialized variables. For each of these points, we create a bit in the dataflow set. Assignments to a variable `x` or path `a.b.c` kill the move/uninitialization bits for those paths and any subpaths (e.g., `x`, `x.y`, `a.b.c`, `*a.b.c`). -The bits are also killed when the root variables (`x`, `a`) go out of -scope. Bits are unioned when two control-flow paths join. Thus, the +Bits are unioned when two control-flow paths join. Thus, the presence of a bit indicates that the move may have occurred without an intervening assignment to the same memory. At each use of a variable, we examine the bits in scope, and check that none of them are diff --git a/src/librustc/middle/borrowck/gather_loans/gather_moves.rs b/src/librustc/middle/borrowck/gather_loans/gather_moves.rs index 25439fce68c9f..1ae512a244c0f 100644 --- a/src/librustc/middle/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc/middle/borrowck/gather_loans/gather_moves.rs @@ -132,7 +132,6 @@ fn check_and_get_illegal_move_origin(bccx: &BorrowckCtxt, match cmt.cat { mc::cat_deref(_, _, mc::BorrowedPtr(..)) | mc::cat_deref(_, _, mc::Implicit(..)) | - mc::cat_deref(_, _, mc::GcPtr) | mc::cat_deref(_, _, mc::UnsafePtr(..)) | mc::cat_upvar(..) | mc::cat_static_item | mc::cat_copied_upvar(mc::CopiedUpvar { onceness: ast::Many, .. }) => { diff --git a/src/librustc/middle/borrowck/gather_loans/lifetime.rs b/src/librustc/middle/borrowck/gather_loans/lifetime.rs index c07123325253b..8ec58fe0eeedc 100644 --- a/src/librustc/middle/borrowck/gather_loans/lifetime.rs +++ b/src/librustc/middle/borrowck/gather_loans/lifetime.rs @@ -82,8 +82,7 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> { mc::cat_downcast(ref base) | mc::cat_deref(ref base, _, mc::OwnedPtr) | // L-Deref-Send - mc::cat_interior(ref base, _) | // L-Field - mc::cat_deref(ref base, _, mc::GcPtr) => { + mc::cat_interior(ref base, _) => { // L-Field self.check(base, discr_scope) } @@ -185,7 +184,6 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> { } mc::cat_downcast(ref cmt) | mc::cat_deref(ref cmt, _, mc::OwnedPtr) | - mc::cat_deref(ref cmt, _, mc::GcPtr) | mc::cat_interior(ref cmt, _) | mc::cat_discr(ref cmt, _) => { self.scope(cmt) diff --git a/src/librustc/middle/borrowck/gather_loans/move_error.rs b/src/librustc/middle/borrowck/gather_loans/move_error.rs index b826768c93728..1b18d07f59053 100644 --- a/src/librustc/middle/borrowck/gather_loans/move_error.rs +++ b/src/librustc/middle/borrowck/gather_loans/move_error.rs @@ -114,7 +114,6 @@ fn report_cannot_move_out_of(bccx: &BorrowckCtxt, move_from: mc::cmt) { match move_from.cat { mc::cat_deref(_, _, mc::BorrowedPtr(..)) | mc::cat_deref(_, _, mc::Implicit(..)) | - mc::cat_deref(_, _, mc::GcPtr) | mc::cat_deref(_, _, mc::UnsafePtr(..)) | mc::cat_upvar(..) | mc::cat_static_item | mc::cat_copied_upvar(mc::CopiedUpvar { onceness: ast::Many, .. }) => { diff --git a/src/librustc/middle/borrowck/gather_loans/restrictions.rs b/src/librustc/middle/borrowck/gather_loans/restrictions.rs index e0018919b9823..067a73fcc9b7e 100644 --- a/src/librustc/middle/borrowck/gather_loans/restrictions.rs +++ b/src/librustc/middle/borrowck/gather_loans/restrictions.rs @@ -101,16 +101,13 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> { self.extend(result, cmt.mutbl, LpInterior(i)) } - mc::cat_deref(cmt_base, _, pk @ mc::OwnedPtr) | - mc::cat_deref(cmt_base, _, pk @ mc::GcPtr) => { + mc::cat_deref(cmt_base, _, pk @ mc::OwnedPtr) => { // R-Deref-Send-Pointer // // When we borrow the interior of an owned pointer, we // cannot permit the base to be mutated, because that // would cause the unique pointer to be freed. // - // For a managed pointer, the rules are basically the - // same, because this could be the last ref. // Eventually we should make these non-special and // just rely on Deref implementation. let result = self.restrict(cmt_base); diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index b411620dac0e7..234afc7ae7a83 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -730,11 +730,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { span, format!("{} in a static location", prefix).as_slice()); } - mc::AliasableManaged => { - self.tcx.sess.span_err( - span, - format!("{} in a `Gc` pointer", prefix).as_slice()); - } mc::AliasableBorrowed => { self.tcx.sess.span_err( span, diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index cc3679ec31deb..ba721acb23198 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -100,7 +100,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr) { if v.in_const { match e.node { ExprUnary(UnDeref, _) => { } - ExprUnary(UnBox, _) | ExprUnary(UnUniq, _) => { + ExprUnary(UnUniq, _) => { span_err!(v.tcx.sess, e.span, E0010, "cannot do allocations in constant expressions"); return; } diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index bef63ec31539f..90d75b9554ba3 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -440,11 +440,6 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor, } } - ty::ty_box(_) => { - assert_eq!(pats_len, 1); - PatBox(pats.nth(0).unwrap()) - } - ty::ty_vec(_, Some(len)) => { assert_eq!(pats_len, len); PatVec(pats.collect(), None, vec![]) @@ -681,7 +676,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat, pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: ty::t) -> uint { match ty::get(ty).sty { ty::ty_tup(ref fs) => fs.len(), - ty::ty_box(_) | ty::ty_uniq(_) => 1u, + ty::ty_uniq(_) => 1u, ty::ty_rptr(_, ty::mt { ty: ty, .. }) => match ty::get(ty).sty { ty::ty_vec(_, None) => match *ctor { Slice(length) => length, diff --git a/src/librustc/middle/check_static.rs b/src/librustc/middle/check_static.rs index 7a11090a8eecb..64e4d7ff28425 100644 --- a/src/librustc/middle/check_static.rs +++ b/src/librustc/middle/check_static.rs @@ -115,10 +115,6 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckStaticVisitor<'a, 'tcx> { span_err!(self.tcx.sess, e.span, E0020, "static items are not allowed to have mutable slices"); }, - ast::ExprUnary(ast::UnBox, _) => { - span_err!(self.tcx.sess, e.span, E0021, - "static items are not allowed to have managed pointers"); - } ast::ExprBox(..) | ast::ExprUnary(ast::UnUniq, _) => { span_err!(self.tcx.sess, e.span, E0022, diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index dccb93f58cc8d..de291595cccfb 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -28,8 +28,8 @@ fn type_size_is_affected_by_type_parameters(tcx: &ty::ctxt, typ: ty::t) let mut result = false; ty::maybe_walk_ty(typ, |typ| { match ty::get(typ).sty { - ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_ptr(_) | - ty::ty_rptr(..) | ty::ty_bare_fn(..) | ty::ty_closure(..) => { + ty::ty_uniq(_) | ty::ty_ptr(_) | ty::ty_rptr(..) | + ty::ty_bare_fn(..) | ty::ty_closure(..) => { false } ty::ty_param(_) => { diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 50c92b45fdff4..3c9ebd86b941e 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -279,8 +279,6 @@ lets_do_this! { ExchangeMallocFnLangItem, "exchange_malloc", exchange_malloc_fn; ExchangeFreeFnLangItem, "exchange_free", exchange_free_fn; - MallocFnLangItem, "malloc", malloc_fn; - FreeFnLangItem, "free", free_fn; StrDupUniqFnLangItem, "strdup_uniq", strdup_uniq_fn; StartFnLangItem, "start", start_fn; @@ -293,9 +291,7 @@ lets_do_this! { EhPersonalityLangItem, "eh_personality", eh_personality; - ManagedHeapLangItem, "managed_heap", managed_heap; ExchangeHeapLangItem, "exchange_heap", exchange_heap; - GcLangItem, "gc", gc; OwnedBoxLangItem, "owned_box", owned_box; CovariantTypeItem, "covariant_type", covariant_type; diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index bb44b1f55cb45..273360c927963 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -104,7 +104,6 @@ pub struct CopiedUpvar { #[deriving(Clone, PartialEq, Eq, Hash)] pub enum PointerKind { OwnedPtr, - GcPtr, BorrowedPtr(ty::BorrowKind, ty::Region), Implicit(ty::BorrowKind, ty::Region), // Implicit deref of a borrowed ptr. UnsafePtr(ast::Mutability) @@ -191,10 +190,6 @@ pub fn opt_deref_kind(t: ty::t) -> Option { Some(deref_ptr(BorrowedPtr(ty::ImmBorrow, r))) } - ty::ty_box(..) => { - Some(deref_ptr(GcPtr)) - } - ty::ty_ptr(ref mt) => { Some(deref_ptr(UnsafePtr(mt.mutbl))) } @@ -302,9 +297,6 @@ impl MutabilityCategory { BorrowedPtr(borrow_kind, _) | Implicit(borrow_kind, _) => { MutabilityCategory::from_borrow_kind(borrow_kind) } - GcPtr => { - McImmutable - } UnsafePtr(m) => { MutabilityCategory::from_mutbl(m) } @@ -1200,7 +1192,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { Implicit(..) => { "dereference (dereference is implicit, due to indexing)".to_string() } - OwnedPtr | GcPtr => format!("dereference of `{}`", ptr_sigil(pk)), + OwnedPtr => format!("dereference of `{}`", ptr_sigil(pk)), _ => format!("dereference of `{}`-pointer", ptr_sigil(pk)) } } @@ -1237,7 +1229,6 @@ pub enum InteriorSafety { } pub enum AliasableReason { - AliasableManaged, AliasableBorrowed, AliasableOther, AliasableStatic(InteriorSafety), @@ -1256,7 +1247,6 @@ impl cmt_ { cat_copied_upvar(..) | cat_local(..) | cat_deref(_, _, UnsafePtr(..)) | - cat_deref(_, _, GcPtr(..)) | cat_deref(_, _, BorrowedPtr(..)) | cat_deref(_, _, Implicit(..)) | cat_upvar(..) => { @@ -1320,10 +1310,6 @@ impl cmt_ { } } - cat_deref(_, _, GcPtr) => { - Some(AliasableManaged) - } - cat_deref(_, _, BorrowedPtr(ty::ImmBorrow, _)) | cat_deref(_, _, Implicit(ty::ImmBorrow, _)) => { Some(AliasableBorrowed) @@ -1371,7 +1357,6 @@ impl Repr for categorization { pub fn ptr_sigil(ptr: PointerKind) -> &'static str { match ptr { OwnedPtr => "Box", - GcPtr => "Gc", BorrowedPtr(ty::ImmBorrow, _) | Implicit(ty::ImmBorrow, _) => "&", BorrowedPtr(ty::MutBorrow, _) | diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/middle/traits/coherence.rs index 9b179d3e89517..080f9ff5bc7ab 100644 --- a/src/librustc/middle/traits/coherence.rs +++ b/src/librustc/middle/traits/coherence.rs @@ -104,11 +104,6 @@ pub fn ty_is_local(tcx: &ty::ctxt, krate == Some(ast::LOCAL_CRATE) || ty_is_local(tcx, t) } - ty::ty_box(t) => { - let krate = tcx.lang_items.gc().map(|d| d.krate); - krate == Some(ast::LOCAL_CRATE) || ty_is_local(tcx, t) - } - ty::ty_vec(t, _) | ty::ty_ptr(ty::mt { ty: t, .. }) | ty::ty_rptr(_, ty::mt { ty: t, .. }) => { diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index 61477fdeed5f7..b86fabccf93de 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -713,23 +713,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ok(self, Always) } - ty::ty_box(_) => { - match bound { - ty::BoundSync | - ty::BoundSend | - ty::BoundCopy => { - // Managed data is not copyable, sendable, nor - // synchronized, regardless of referent. - ok(self, Never) - } - - ty::BoundSized => { - // But it is sized, regardless of referent. - ok(self, Always) - } - } - } - ty::ty_uniq(referent_ty) => { // Box match bound { ty::BoundCopy => { diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index 4d8e0145901dc..506b12de08467 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -321,9 +321,6 @@ impl Case { _ => return Some(ThinPointer(i)) }, - // Gc is just a pointer - ty::ty_box(..) => return Some(ThinPointer(i)), - // Functions are just pointers ty::ty_bare_fn(..) => return Some(ThinPointer(i)), diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 03045777155d4..f65827753aa20 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -397,36 +397,6 @@ pub fn malloc_raw_dyn_proc<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: ty::t) -> Resu Result::new(bcx, llbox) } - -pub fn malloc_raw_dyn_managed<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, - t: ty::t, - alloc_fn: LangItem, - size: ValueRef) - -> Result<'blk, 'tcx> { - let _icx = push_ctxt("malloc_raw_dyn_managed"); - let ccx = bcx.ccx(); - - let langcall = require_alloc_fn(bcx, t, alloc_fn); - - // Grab the TypeRef type of box_ptr_ty. - let box_ptr_ty = ty::mk_box(bcx.tcx(), t); - let llty = type_of(ccx, box_ptr_ty); - let llalign = C_uint(ccx, type_of::align_of(ccx, box_ptr_ty) as uint); - - // Allocate space: - let drop_glue = glue::get_drop_glue(ccx, t); - let r = callee::trans_lang_call( - bcx, - langcall, - [ - PointerCast(bcx, drop_glue, Type::glue_fn(ccx, Type::i8p(ccx)).ptr_to()), - size, - llalign - ], - None); - Result::new(r.bcx, PointerCast(r.bcx, r.val, llty)) -} - // Type descriptor and type glue stuff pub fn get_tydesc(ccx: &CrateContext, t: ty::t) -> Rc { diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc/middle/trans/cleanup.rs index 35464be0e4312..20fd0b0eb3d8f 100644 --- a/src/librustc/middle/trans/cleanup.rs +++ b/src/librustc/middle/trans/cleanup.rs @@ -960,7 +960,6 @@ impl Cleanup for DropValue { } pub enum Heap { - HeapManaged, HeapExchange } @@ -986,9 +985,6 @@ impl Cleanup for FreeValue { apply_debug_loc(bcx.fcx, debug_loc); match self.heap { - HeapManaged => { - glue::trans_free(bcx, self.ptr) - } HeapExchange => { glue::trans_exchange_free_ty(bcx, self.ptr, self.content_ty) } @@ -1019,9 +1015,6 @@ impl Cleanup for FreeSlice { apply_debug_loc(bcx.fcx, debug_loc); match self.heap { - HeapManaged => { - glue::trans_free(bcx, self.ptr) - } HeapExchange => { glue::trans_exchange_free_dyn(bcx, self.ptr, self.size, self.align) } diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 30f91c82930e3..7daee22e61461 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -71,7 +71,7 @@ pub fn type_is_immediate(ccx: &CrateContext, ty: ty::t) -> bool { use middle::trans::type_of::sizing_type_of; let tcx = ccx.tcx(); - let simple = ty::type_is_scalar(ty) || ty::type_is_boxed(ty) || + let simple = ty::type_is_scalar(ty) || ty::type_is_unique(ty) || ty::type_is_region_ptr(ty) || type_is_newtype_immediate(ccx, ty) || ty::type_is_bot(ty) || ty::type_is_simd(tcx, ty); diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index c499fcf4bf8df..196efd7d2cce8 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -421,7 +421,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr, let ty = ty::expr_ty(cx.tcx(), &**e); let is_float = ty::type_is_fp(ty); return (match u { - ast::UnBox | ast::UnUniq | ast::UnDeref => { + ast::UnUniq | ast::UnDeref => { let (dv, _dt) = const_deref(cx, te, ty, true); dv } diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index 84d9f2cb740a3..260bde0f07f5d 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -20,7 +20,6 @@ use middle::trans::common::*; use middle::trans::cleanup; use middle::trans::cleanup::CleanupMethods; use middle::trans::expr; -use middle::trans::glue; use middle::trans::tvec; use middle::trans::type_of; use middle::ty; @@ -240,14 +239,9 @@ impl KindOps for Lvalue { */ if ty::type_needs_drop(bcx.tcx(), ty) { - if ty::type_moves_by_default(bcx.tcx(), ty) { - // cancel cleanup of affine values by zeroing out - let () = zero_mem(bcx, val, ty); - bcx - } else { - // incr. refcount for @T or newtype'd @T - glue::take_ty(bcx, val, ty) - } + // cancel cleanup of affine values by zeroing out + let () = zero_mem(bcx, val, ty); + bcx } else { bcx } @@ -567,15 +561,15 @@ impl Datum { * is moved). */ - self.shallow_copy(bcx, dst); + self.shallow_copy_raw(bcx, dst); self.kind.post_store(bcx, self.val, self.ty) } - fn shallow_copy<'blk, 'tcx>(&self, - bcx: Block<'blk, 'tcx>, - dst: ValueRef) - -> Block<'blk, 'tcx> { + fn shallow_copy_raw<'blk, 'tcx>(&self, + bcx: Block<'blk, 'tcx>, + dst: ValueRef) + -> Block<'blk, 'tcx> { /*! * Helper function that performs a shallow copy of this value * into `dst`, which should be a pointer to a memory location @@ -584,10 +578,9 @@ impl Datum { * * This function is private to datums because it leaves memory * in an unstable state, where the source value has been - * copied but not zeroed. Public methods are `store_to` (if - * you no longer need the source value) or - * `shallow_copy_and_take` (if you wish the source value to - * remain valid). + * copied but not zeroed. Public methods are `store_to` + * (if you no longer need the source value) or `shallow_copy` + * (if you wish the source value to remain valid). */ let _icx = push_ctxt("copy_to_no_check"); @@ -605,22 +598,19 @@ impl Datum { return bcx; } - pub fn shallow_copy_and_take<'blk, 'tcx>(&self, - bcx: Block<'blk, 'tcx>, - dst: ValueRef) - -> Block<'blk, 'tcx> { + pub fn shallow_copy<'blk, 'tcx>(&self, + bcx: Block<'blk, 'tcx>, + dst: ValueRef) + -> Block<'blk, 'tcx> { /*! - * Copies the value into a new location and runs any necessary - * take glue on the new location. This function always + * Copies the value into a new location. This function always * preserves the existing datum as a valid value. Therefore, * it does not consume `self` and, also, cannot be applied to * affine values (since they must never be duplicated). */ assert!(!ty::type_moves_by_default(bcx.tcx(), self.ty)); - let mut bcx = bcx; - bcx = self.shallow_copy(bcx, dst); - glue::take_ty(bcx, dst, self.ty) + self.shallow_copy_raw(bcx, dst) } #[allow(dead_code)] // useful for debugging diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index dc328833d546b..a29fd7f6ceb7a 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -373,12 +373,6 @@ impl TypeMap { unique_type_id.push_str(component_type_id.as_slice()); } }, - ty::ty_box(inner_type) => { - unique_type_id.push_char('@'); - let inner_type_id = self.get_unique_type_id_of_type(cx, inner_type); - let inner_type_id = self.get_unique_type_id_as_string(inner_type_id); - unique_type_id.push_str(inner_type_id.as_slice()); - }, ty::ty_uniq(inner_type) => { unique_type_id.push_char('~'); let inner_type_id = self.get_unique_type_id_of_type(cx, inner_type); @@ -596,18 +590,6 @@ impl TypeMap { let interner_key = self.unique_id_interner.intern(Rc::new(enum_variant_type_id)); UniqueTypeId(interner_key) } - - fn get_unique_type_id_of_gc_box(&mut self, - cx: &CrateContext, - element_type: ty::t) - -> UniqueTypeId { - let element_type_id = self.get_unique_type_id_of_type(cx, element_type); - let gc_box_type_id = format!("{{GC_BOX<{}>}}", - self.get_unique_type_id_as_string(element_type_id) - .as_slice()); - let interner_key = self.unique_id_interner.intern(Rc::new(gc_box_type_id)); - UniqueTypeId(interner_key) - } } // Returns from the enclosing function if the type metadata with the given @@ -2646,105 +2628,6 @@ fn create_struct_stub(cx: &CrateContext, return metadata_stub; } -fn at_box_metadata(cx: &CrateContext, - at_pointer_type: ty::t, - content_type: ty::t, - unique_type_id: UniqueTypeId) - -> MetadataCreationResult { - let content_type_metadata = type_metadata(cx, content_type, codemap::DUMMY_SP); - - return_if_metadata_created_in_meantime!(cx, unique_type_id); - - let content_type_name = compute_debuginfo_type_name(cx, content_type, true); - let content_type_name = content_type_name.as_slice(); - let content_llvm_type = type_of::type_of(cx, content_type); - - let box_type_name = format!("GcBox<{}>", content_type_name); - let box_llvm_type = Type::at_box(cx, content_llvm_type); - let member_llvm_types = box_llvm_type.field_types(); - assert!(box_layout_is_correct(cx, - member_llvm_types.as_slice(), - content_llvm_type)); - - let int_type = ty::mk_int(); - let nil_pointer_type = ty::mk_nil_ptr(cx.tcx()); - let nil_pointer_type_metadata = type_metadata(cx, - nil_pointer_type, - codemap::DUMMY_SP); - let member_descriptions = [ - MemberDescription { - name: "refcnt".to_string(), - llvm_type: *member_llvm_types.get(0), - type_metadata: type_metadata(cx, int_type, codemap::DUMMY_SP), - offset: ComputedMemberOffset, - flags: FLAGS_ARTIFICAL, - }, - MemberDescription { - name: "drop_glue".to_string(), - llvm_type: *member_llvm_types.get(1), - type_metadata: nil_pointer_type_metadata, - offset: ComputedMemberOffset, - flags: FLAGS_ARTIFICAL, - }, - MemberDescription { - name: "prev".to_string(), - llvm_type: *member_llvm_types.get(2), - type_metadata: nil_pointer_type_metadata, - offset: ComputedMemberOffset, - flags: FLAGS_ARTIFICAL, - }, - MemberDescription { - name: "next".to_string(), - llvm_type: *member_llvm_types.get(3), - type_metadata: nil_pointer_type_metadata, - offset: ComputedMemberOffset, - flags: FLAGS_ARTIFICAL, - }, - MemberDescription { - name: "val".to_string(), - llvm_type: *member_llvm_types.get(4), - type_metadata: content_type_metadata, - offset: ComputedMemberOffset, - flags: FLAGS_ARTIFICAL, - } - ]; - - let gc_box_unique_id = debug_context(cx).type_map - .borrow_mut() - .get_unique_type_id_of_gc_box(cx, content_type); - - let gc_box_metadata = composite_type_metadata( - cx, - box_llvm_type, - box_type_name.as_slice(), - gc_box_unique_id, - member_descriptions, - UNKNOWN_SCOPE_METADATA, - UNKNOWN_FILE_METADATA, - codemap::DUMMY_SP); - - let gc_pointer_metadata = pointer_type_metadata(cx, - at_pointer_type, - gc_box_metadata); - - return MetadataCreationResult::new(gc_pointer_metadata, false); - - // Unfortunately, we cannot assert anything but the correct types here---and - // not whether the 'next' and 'prev' pointers are in the correct order. - fn box_layout_is_correct(cx: &CrateContext, - member_llvm_types: &[Type], - content_llvm_type: Type) - -> bool { - member_llvm_types.len() == 5 && - member_llvm_types[0] == cx.int_type() && - member_llvm_types[1] == Type::generic_glue_fn(cx).ptr_to() && - member_llvm_types[2] == Type::i8(cx).ptr_to() && - member_llvm_types[3] == Type::i8(cx).ptr_to() && - member_llvm_types[4] == content_llvm_type - } -} - - fn fixed_vec_metadata(cx: &CrateContext, unique_type_id: UniqueTypeId, element_type: ty::t, @@ -2968,9 +2851,6 @@ fn type_metadata(cx: &CrateContext, ty::ty_enum(def_id, _) => { prepare_enum_metadata(cx, t, def_id, unique_type_id, usage_site_span).finalize(cx) } - ty::ty_box(pointee_type) => { - at_box_metadata(cx, t, pointee_type, unique_type_id) - } ty::ty_vec(typ, Some(len)) => { fixed_vec_metadata(cx, unique_type_id, typ, len, usage_site_span) } @@ -3702,7 +3582,7 @@ fn populate_scope_map(cx: &CrateContext, ast::ExprInlineAsm(ast::InlineAsm { inputs: ref inputs, outputs: ref outputs, .. }) => { - // inputs, outputs: ~[(String, Gc)] + // inputs, outputs: Vec<(String, P)> for &(_, ref exp) in inputs.iter() { walk_expr(cx, &**exp, scope_stack, scope_map); } @@ -3777,10 +3657,6 @@ fn push_debuginfo_type_name(cx: &CrateContext, push_debuginfo_type_name(cx, inner_type, true, output); output.push_char('>'); }, - ty::ty_box(inner_type) => { - output.push_char('@'); - push_debuginfo_type_name(cx, inner_type, true, output); - }, ty::ty_ptr(ty::mt { ty: inner_type, mutbl } ) => { output.push_char('*'); match mutbl { diff --git a/src/librustc/middle/trans/doc.rs b/src/librustc/middle/trans/doc.rs index 56bf25613382c..d6df0d88a769f 100644 --- a/src/librustc/middle/trans/doc.rs +++ b/src/librustc/middle/trans/doc.rs @@ -65,7 +65,7 @@ Some of the datum methods, however, are designed to work only on copyable values such as ints or pointers. Those methods may borrow the datum (`&self`) rather than consume it, but they always include assertions on the type of the value represented to check that this -makes sense. An example is `shallow_copy_and_take()`, which duplicates +makes sense. An example is `shallow_copy()`, which duplicates a datum value. Translating an expression always yields a `Datum` result, but diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 37a39ef8e3bef..cd4ad85d0942c 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -38,7 +38,6 @@ use llvm; use llvm::{ValueRef}; use metadata::csearch; use middle::def; -use middle::lang_items::MallocFnLangItem; use middle::mem_categorization::Typer; use middle::subst; use middle::subst::Subst; @@ -624,18 +623,15 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, DatumBlock::new(bcx, scratch.to_expr_datum()) } ast::ExprBox(_, ref contents) => { - // Special case for `Box` and `Gc` + // Special case for `Box` let box_ty = expr_ty(bcx, expr); let contents_ty = expr_ty(bcx, &**contents); match ty::get(box_ty).sty { ty::ty_uniq(..) => { trans_uniq_expr(bcx, box_ty, &**contents, contents_ty) } - ty::ty_box(..) => { - trans_managed_expr(bcx, box_ty, &**contents, contents_ty) - } _ => bcx.sess().span_bug(expr.span, - "expected unique or managed box") + "expected unique box") } } @@ -1533,9 +1529,6 @@ fn trans_unary<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, }; immediate_rvalue_bcx(bcx, llneg, un_ty).to_expr_datumblock() } - ast::UnBox => { - trans_managed_expr(bcx, un_ty, sub_expr, expr_ty(bcx, sub_expr)) - } ast::UnUniq => { trans_uniq_expr(bcx, un_ty, sub_expr, expr_ty(bcx, sub_expr)) } @@ -1575,26 +1568,6 @@ fn trans_uniq_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, immediate_rvalue_bcx(bcx, val, box_ty).to_expr_datumblock() } -fn trans_managed_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, - box_ty: ty::t, - contents: &ast::Expr, - contents_ty: ty::t) - -> DatumBlock<'blk, 'tcx, Expr> { - let _icx = push_ctxt("trans_managed_expr"); - let fcx = bcx.fcx; - let ty = type_of::type_of(bcx.ccx(), contents_ty); - let Result {bcx, val: bx} = malloc_raw_dyn_managed(bcx, contents_ty, MallocFnLangItem, - llsize_of(bcx.ccx(), ty)); - let body = GEPi(bcx, bx, [0u, abi::box_field_body]); - - let custom_cleanup_scope = fcx.push_custom_cleanup_scope(); - fcx.schedule_free_value(cleanup::CustomScope(custom_cleanup_scope), - bx, cleanup::HeapManaged, contents_ty); - let bcx = trans_into(bcx, contents, SaveIn(body)); - fcx.pop_custom_cleanup_scope(custom_cleanup_scope); - immediate_rvalue_bcx(bcx, bx, box_ty).to_expr_datumblock() -} - fn trans_addr_of<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr, subexpr: &ast::Expr) @@ -1927,10 +1900,6 @@ pub fn cast_type_kind(tcx: &ty::ctxt, t: ty::t) -> cast_kind { } fn cast_is_noop(t_in: ty::t, t_out: ty::t) -> bool { - if ty::type_is_boxed(t_in) || ty::type_is_boxed(t_out) { - return false; - } - match (ty::deref(t_in, true), ty::deref(t_out, true)) { (Some(ty::mt{ ty: t_in, .. }), Some(ty::mt{ ty: t_out, .. })) => { t_in == t_out @@ -2163,15 +2132,6 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } } - ty::ty_box(content_ty) => { - let datum = unpack_datum!( - bcx, datum.to_lvalue_datum(bcx, "deref", expr.id)); - let llptrref = datum.to_llref(); - let llptr = Load(bcx, llptrref); - let llbody = GEPi(bcx, llptr, [0u, abi::box_field_body]); - DatumBlock::new(bcx, Datum::new(llbody, content_ty, LvalueExpr)) - } - ty::ty_ptr(ty::mt { ty: content_ty, .. }) | ty::ty_rptr(_, ty::mt { ty: content_ty, .. }) => { if ty::type_is_sized(bcx.tcx(), content_ty) { diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index c8cc89ca66a20..33a46c0ba36af 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -17,7 +17,7 @@ use back::abi; use back::link::*; use llvm::{ValueRef, True, get_param}; use llvm; -use middle::lang_items::{FreeFnLangItem, ExchangeFreeFnLangItem}; +use middle::lang_items::ExchangeFreeFnLangItem; use middle::subst; use middle::subst::Subst; use middle::trans::adt; @@ -46,15 +46,6 @@ use libc::c_uint; use syntax::ast; use syntax::parse::token; -pub fn trans_free<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef) - -> Block<'blk, 'tcx> { - let _icx = push_ctxt("trans_free"); - callee::trans_lang_call(cx, - langcall(cx, None, "", FreeFnLangItem), - [PointerCast(cx, v, Type::i8p(cx.ccx()))], - Some(expr::Ignore)).bcx -} - pub fn trans_exchange_free_dyn<'blk, 'tcx>(cx: Block<'blk, 'tcx>, v: ValueRef, size: ValueRef, align: ValueRef) -> Block<'blk, 'tcx> { @@ -87,20 +78,6 @@ pub fn trans_exchange_free_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ptr: ValueRef, } } -pub fn take_ty<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v: ValueRef, t: ty::t) - -> Block<'blk, 'tcx> { - // NB: v is an *alias* of type t here, not a direct value. - let _icx = push_ctxt("take_ty"); - match ty::get(t).sty { - ty::ty_box(_) => incr_refcnt_of_boxed(bcx, v), - _ if ty::type_is_structural(t) - && ty::type_needs_drop(bcx.tcx(), t) => { - iter_structural_ty(bcx, v, t, take_ty) - } - _ => bcx - } -} - pub fn get_drop_glue_type(ccx: &CrateContext, t: ty::t) -> ty::t { let tcx = ccx.tcx(); // Even if there is no dtor for t, there might be one deeper down and we @@ -446,9 +423,6 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: ty::t) // NB: v0 is an *alias* of type t here, not a direct value. let _icx = push_ctxt("make_drop_glue"); match ty::get(t).sty { - ty::ty_box(body_ty) => { - decr_refcnt_maybe_free(bcx, v0, body_ty) - } ty::ty_uniq(content_ty) => { match ty::get(content_ty).sty { ty::ty_vec(ty, None) => { @@ -568,48 +542,6 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: ty::t) } } -fn decr_refcnt_maybe_free<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, - box_ptr_ptr: ValueRef, - t: ty::t) -> Block<'blk, 'tcx> { - let _icx = push_ctxt("decr_refcnt_maybe_free"); - let fcx = bcx.fcx; - let ccx = bcx.ccx(); - - let decr_bcx = fcx.new_temp_block("decr"); - let free_bcx = fcx.new_temp_block("free"); - let next_bcx = fcx.new_temp_block("next"); - - let box_ptr = Load(bcx, box_ptr_ptr); - let llnotnull = IsNotNull(bcx, box_ptr); - CondBr(bcx, llnotnull, decr_bcx.llbb, next_bcx.llbb); - - let rc_ptr = GEPi(decr_bcx, box_ptr, [0u, abi::box_field_refcnt]); - let rc = Sub(decr_bcx, Load(decr_bcx, rc_ptr), C_int(ccx, 1)); - Store(decr_bcx, rc, rc_ptr); - CondBr(decr_bcx, IsNull(decr_bcx, rc), free_bcx.llbb, next_bcx.llbb); - - let v = Load(free_bcx, box_ptr_ptr); - let body = GEPi(free_bcx, v, [0u, abi::box_field_body]); - let free_bcx = drop_ty(free_bcx, body, t, None); - let free_bcx = trans_free(free_bcx, v); - Br(free_bcx, next_bcx.llbb); - - next_bcx -} - -fn incr_refcnt_of_boxed<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, - box_ptr_ptr: ValueRef) -> Block<'blk, 'tcx> { - let _icx = push_ctxt("incr_refcnt_of_boxed"); - let ccx = bcx.ccx(); - let box_ptr = Load(bcx, box_ptr_ptr); - let rc_ptr = GEPi(bcx, box_ptr, [0u, abi::box_field_refcnt]); - let rc = Load(bcx, rc_ptr); - let rc = Add(bcx, rc, C_int(ccx, 1)); - Store(bcx, rc, rc_ptr); - bcx -} - - // Generates the declaration for (but doesn't emit) a type descriptor. pub fn declare_tydesc(ccx: &CrateContext, t: ty::t) -> tydesc_info { // If emit_tydescs already ran, then we shouldn't be creating any new diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 03550299fbdf5..f004bea23c7a0 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -169,14 +169,6 @@ impl<'a, 'blk, 'tcx> Reflector<'a, 'blk, 'tcx> { extra.push(self.c_tydesc(ty)); self.visit("evec_fixed", extra.as_slice()) } - // Should remove mt from box and uniq. - ty::ty_box(typ) => { - let extra = self.c_mt(&ty::mt { - ty: typ, - mutbl: ast::MutImmutable, - }); - self.visit("box", extra.as_slice()) - } ty::ty_ptr(ref mt) => { match ty::get(mt.ty).sty { ty::ty_vec(ty, None) => { diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 848e59e2a60d8..fac0ef2014ec6 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -325,7 +325,7 @@ pub fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let bcx = iter_vec_loop(bcx, lldest, vt, C_uint(bcx.ccx(), count), |set_bcx, lleltptr, _| { - elem.shallow_copy_and_take(set_bcx, lleltptr) + elem.shallow_copy(set_bcx, lleltptr) }); elem.add_clean_if_rvalue(bcx, element.id); diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 54f24516867f0..d41cd7ed9e5d4 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -174,7 +174,6 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type { ty::ty_uint(t) => Type::uint_from_ty(cx, t), ty::ty_float(t) => Type::float_from_ty(cx, t), - ty::ty_box(..) => Type::i8p(cx), ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) | ty::ty_ptr(ty::mt{ty, ..}) => { if ty::type_is_sized(cx.tcx(), ty) { Type::i8p(cx) @@ -299,9 +298,6 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type { let name = llvm_type_name(cx, an_unboxed_closure, did, []); adt::incomplete_type_of(cx, &*repr, name.as_slice()) } - ty::ty_box(typ) => { - Type::at_box(cx, type_of(cx, typ)).ptr_to() - } ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) | ty::ty_ptr(ty::mt{ty, ..}) => { match ty::get(ty).sty { diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index b38f362dcf18d..edbdf427c0bc6 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -940,7 +940,6 @@ pub enum sty { /// the `ast_ty_to_ty_cache`. This is probably true for `ty_struct` as /// well.` ty_enum(DefId, Substs), - ty_box(t), ty_uniq(t), ty_str, ty_vec(t, Option), // Second field is length. @@ -1621,7 +1620,7 @@ pub fn mk_t(cx: &ctxt, st: sty) -> t { flags |= sflags(substs); flags |= flags_for_bounds(bounds); } - &ty_box(tt) | &ty_uniq(tt) | &ty_vec(tt, _) | &ty_open(tt) => { + &ty_uniq(tt) | &ty_vec(tt, _) | &ty_open(tt) => { flags |= get(tt).flags } &ty_ptr(ref m) => { @@ -1776,8 +1775,6 @@ pub fn mk_enum(cx: &ctxt, did: ast::DefId, substs: Substs) -> t { mk_t(cx, ty_enum(did, substs)) } -pub fn mk_box(cx: &ctxt, ty: t) -> t { mk_t(cx, ty_box(ty)) } - pub fn mk_uniq(cx: &ctxt, ty: t) -> t { mk_t(cx, ty_uniq(ty)) } pub fn mk_ptr(cx: &ctxt, tm: mt) -> t { mk_t(cx, ty_ptr(tm)) } @@ -1901,7 +1898,7 @@ pub fn maybe_walk_ty(ty: t, f: |t| -> bool) { match get(ty).sty { ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | ty_uint(_) | ty_float(_) | ty_str | ty_infer(_) | ty_param(_) | ty_unboxed_closure(_, _) | ty_err => {} - ty_box(ty) | ty_uniq(ty) | ty_vec(ty, _) | ty_open(ty) => maybe_walk_ty(ty, f), + ty_uniq(ty) | ty_vec(ty, _) | ty_open(ty) => maybe_walk_ty(ty, f), ty_ptr(ref tm) | ty_rptr(_, ref tm) => { maybe_walk_ty(tm.ty, f); } @@ -2014,7 +2011,7 @@ pub fn type_is_vec(ty: t) -> bool { match get(ty).sty { ty_vec(..) => true, ty_ptr(mt{ty: t, ..}) | ty_rptr(_, mt{ty: t, ..}) | - ty_box(t) | ty_uniq(t) => match get(t).sty { + ty_uniq(t) => match get(t).sty { ty_vec(_, None) => true, _ => false }, @@ -2067,13 +2064,6 @@ pub fn simd_size(cx: &ctxt, ty: t) -> uint { } } -pub fn type_is_boxed(ty: t) -> bool { - match get(ty).sty { - ty_box(_) => true, - _ => false - } -} - pub fn type_is_region_ptr(ty: t) -> bool { match get(ty).sty { ty_rptr(..) => true, @@ -2144,29 +2134,22 @@ pub fn type_needs_unwind_cleanup(cx: &ctxt, ty: t) -> bool { let mut tycache = HashSet::new(); let needs_unwind_cleanup = - type_needs_unwind_cleanup_(cx, ty, &mut tycache, false); + type_needs_unwind_cleanup_(cx, ty, &mut tycache); cx.needs_unwind_cleanup_cache.borrow_mut().insert(ty, needs_unwind_cleanup); - return needs_unwind_cleanup; + needs_unwind_cleanup } fn type_needs_unwind_cleanup_(cx: &ctxt, ty: t, - tycache: &mut HashSet, - encountered_box: bool) -> bool { + tycache: &mut HashSet) -> bool { // Prevent infinite recursion if !tycache.insert(ty) { return false; } - let mut encountered_box = encountered_box; let mut needs_unwind_cleanup = false; maybe_walk_ty(ty, |ty| { - let old_encountered_box = encountered_box; let result = match get(ty).sty { - ty_box(_) => { - encountered_box = true; - true - } ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_tup(_) | ty_ptr(_) => { true @@ -2176,33 +2159,21 @@ fn type_needs_unwind_cleanup_(cx: &ctxt, ty: t, for aty in v.args.iter() { let t = aty.subst(cx, substs); needs_unwind_cleanup |= - type_needs_unwind_cleanup_(cx, t, tycache, - encountered_box); + type_needs_unwind_cleanup_(cx, t, tycache); } } !needs_unwind_cleanup } - ty_uniq(_) => { - // Once we're inside a box, the annihilator will find - // it and destroy it. - if !encountered_box { - needs_unwind_cleanup = true; - false - } else { - true - } - } _ => { needs_unwind_cleanup = true; false } }; - encountered_box = old_encountered_box; result }); - return needs_unwind_cleanup; + needs_unwind_cleanup } /** @@ -2460,10 +2431,6 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents { closure_contents(cx, &**c) | TC::ReachesFfiUnsafe } - ty_box(typ) => { - tc_ty(cx, typ, cache).managed_pointer() | TC::ReachesFfiUnsafe - } - ty_uniq(typ) => { TC::ReachesFfiUnsafe | match get(typ).sty { ty_str => TC::OwnsOwned, @@ -2782,7 +2749,7 @@ pub fn is_instantiable(cx: &ctxt, r_ty: t) -> bool { ty_vec(_, None) => { false } - ty_box(typ) | ty_uniq(typ) | ty_open(typ) => { + ty_uniq(typ) | ty_open(typ) => { type_requires(cx, seen, r_ty, typ) } ty_rptr(_, ref mt) => { @@ -3092,7 +3059,7 @@ pub fn type_is_c_like_enum(cx: &ctxt, ty: t) -> bool { // Some types---notably unsafe ptrs---can only be dereferenced explicitly. pub fn deref(t: t, explicit: bool) -> Option { match get(t).sty { - ty_box(ty) | ty_uniq(ty) => { + ty_uniq(ty) => { Some(mt { ty: ty, mutbl: ast::MutImmutable, @@ -3106,9 +3073,7 @@ pub fn deref(t: t, explicit: bool) -> Option { pub fn deref_or_dont(t: t) -> t { match get(t).sty { - ty_box(ty) | ty_uniq(ty) => { - ty - }, + ty_uniq(ty) => ty, ty_rptr(_, mt) | ty_ptr(mt) => mt.ty, _ => t } @@ -3124,7 +3089,7 @@ pub fn close_type(cx: &ctxt, t: t) -> t { pub fn type_content(t: t) -> t { match get(t).sty { - ty_box(ty) | ty_uniq(ty) => ty, + ty_uniq(ty) => ty, ty_rptr(_, mt) |ty_ptr(mt) => mt.ty, _ => t } @@ -3695,14 +3660,13 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind { } ast::ExprBox(ref place, _) => { - // Special case `Box`/`Gc` for now: + // Special case `Box` for now: let definition = match tcx.def_map.borrow().find(&place.id) { Some(&def) => def, None => fail!("no def for place"), }; let def_id = definition.def_id(); - if tcx.lang_items.exchange_heap() == Some(def_id) || - tcx.lang_items.managed_heap() == Some(def_id) { + if tcx.lang_items.exchange_heap() == Some(def_id) { RvalueDatumExpr } else { RvalueDpsExpr @@ -3753,7 +3717,6 @@ pub fn ty_sort_string(cx: &ctxt, t: t) -> String { } ty_enum(id, _) => format!("enum {}", item_path_str(cx, id)), - ty_box(_) => "Gc-ptr".to_string(), ty_uniq(_) => "box".to_string(), ty_vec(_, Some(_)) => "array".to_string(), ty_vec(_, None) => "unsized array".to_string(), @@ -5223,19 +5186,15 @@ pub fn hash_crate_independent(tcx: &ctxt, t: t, svh: &Svh) -> u64 { byte!(8); did(&mut state, d); } - ty_box(_) => { - byte!(9); - } ty_uniq(_) => { - byte!(10); + byte!(9); } ty_vec(_, Some(n)) => { - byte!(11); + byte!(10); n.hash(&mut state); } ty_vec(_, None) => { byte!(11); - 0u8.hash(&mut state); } ty_ptr(m) => { byte!(12); @@ -5586,7 +5545,6 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec, ty_int(_) | ty_uint(_) | ty_float(_) | - ty_box(_) | ty_uniq(_) | ty_str | ty_vec(_, _) | diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty_fold.rs index 2e964c457bf29..44420ddd7f31f 100644 --- a/src/librustc/middle/ty_fold.rs +++ b/src/librustc/middle/ty_fold.rs @@ -458,9 +458,6 @@ pub fn super_fold_mt<'tcx, T: TypeFolder<'tcx>>(this: &mut T, pub fn super_fold_sty<'tcx, T: TypeFolder<'tcx>>(this: &mut T, sty: &ty::sty) -> ty::sty { match *sty { - ty::ty_box(typ) => { - ty::ty_box(typ.fold_with(this)) - } ty::ty_uniq(typ) => { ty::ty_uniq(typ.fold_with(this)) } diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index b73fa172d3f7b..4d21090dd2c2a 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -559,44 +559,6 @@ pub fn ast_ty_to_builtin_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( "not enough type parameters supplied to `Box`"); Some(ty::mk_err()) } - def::DefTy(did, _) | def::DefStruct(did) - if Some(did) == this.tcx().lang_items.gc() => { - if path.segments - .iter() - .flat_map(|s| s.types.iter()) - .count() > 1 { - span_err!(this.tcx().sess, path.span, E0048, - "`Gc` has only one type parameter"); - } - - for inner_ast_type in path.segments - .iter() - .flat_map(|s| s.types.iter()) { - return Some(mk_pointer(this, - rscope, - ast::MutImmutable, - &**inner_ast_type, - Box, - |typ| { - match ty::get(typ).sty { - ty::ty_str => { - span_err!(this.tcx().sess, path.span, E0114, - "`Gc` is not a type"); - ty::mk_err() - } - ty::ty_vec(_, None) => { - span_err!(this.tcx().sess, path.span, E0115, - "`Gc<[T]>` is not a type"); - ty::mk_err() - } - _ => ty::mk_box(this.tcx(), typ), - } - })) - } - this.tcx().sess.span_bug(path.span, - "not enough type parameters \ - supplied to `Gc`") - } _ => None } } @@ -606,7 +568,6 @@ pub fn ast_ty_to_builtin_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( #[deriving(Show)] enum PointerTy { - Box, RPtr(ty::Region), Uniq } @@ -614,7 +575,6 @@ enum PointerTy { impl PointerTy { fn default_region(&self) -> ty::Region { match *self { - Box => ty::ReStatic, Uniq => ty::ReStatic, RPtr(r) => r, } @@ -702,14 +662,6 @@ fn mk_pointer<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( r, ty::mt {mutbl: a_seq_mutbl, ty: tr}); } - _ => { - tcx.sess.span_err( - a_seq_ty.span, - "~trait or &trait are the only supported \ - forms of casting-to-trait"); - return ty::mk_err(); - } - } } ast::TyPath(ref path, ref opt_bounds, id) => { @@ -726,11 +678,6 @@ fn mk_pointer<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( RPtr(r) => { return ty::mk_str_slice(tcx, r, ast::MutImmutable); } - _ => { - tcx.sess - .span_err(path.span, - "managed strings are not supported") - } } } Some(&def::DefTrait(trait_def_id)) => { @@ -767,13 +714,6 @@ fn mk_pointer<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( RPtr(r) => { return ty::mk_rptr(tcx, r, ty::mt{mutbl: a_seq_mutbl, ty: tr}); } - _ => { - tcx.sess.span_err( - path.span, - "~trait or &trait are the only supported \ - forms of casting-to-trait"); - return ty::mk_err(); - } }; } _ => {} @@ -856,10 +796,6 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( match ast_ty.node { ast::TyNil => ty::mk_nil(), ast::TyBot => ty::mk_bot(), - ast::TyBox(ref ty) => { - mk_pointer(this, rscope, ast::MutImmutable, &**ty, Box, - |ty| ty::mk_box(tcx, ty)) - } ast::TyUniq(ref ty) => { mk_pointer(this, rscope, ast::MutImmutable, &**ty, Uniq, |ty| ty::mk_uniq(tcx, ty)) diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 3d522a7c54860..8711f4de512e6 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -1094,7 +1094,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { let tcx = self.tcx(); match ty::get(self_ty).sty { - ty_bare_fn(..) | ty_box(..) | ty_uniq(..) | ty_rptr(..) | + ty_bare_fn(..) | ty_uniq(..) | ty_rptr(..) | ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) | ty_param(..) | ty_nil | ty_bot | ty_bool | diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 5f7f77ea7da58..194c2c35c8897 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -3820,12 +3820,6 @@ fn check_expr_with_unifier(fcx: &FnCtxt, if tcx.lang_items.exchange_heap() == Some(def_id) { fcx.write_ty(id, ty::mk_uniq(tcx, referent_ty)); checked = true - } else if tcx.lang_items.managed_heap() == Some(def_id) { - fcx.register_region_obligation(infer::Managed(expr.span), - referent_ty, - ty::ReStatic); - fcx.write_ty(id, ty::mk_box(tcx, referent_ty)); - checked = true } } _ => {} @@ -3881,8 +3875,8 @@ fn check_expr_with_unifier(fcx: &FnCtxt, ast::ExprUnary(unop, ref oprnd) => { let expected_inner = expected.map(fcx, |sty| { match unop { - ast::UnBox | ast::UnUniq => match *sty { - ty::ty_box(ty) | ty::ty_uniq(ty) => { + ast::UnUniq => match *sty { + ty::ty_uniq(ty) => { ExpectHasType(ty) } _ => { @@ -3907,11 +3901,6 @@ fn check_expr_with_unifier(fcx: &FnCtxt, if !ty::type_is_error(oprnd_t) { match unop { - ast::UnBox => { - if !ty::type_is_bot(oprnd_t) { - oprnd_t = ty::mk_box(tcx, oprnd_t) - } - } ast::UnUniq => { if !ty::type_is_bot(oprnd_t) { oprnd_t = ty::mk_uniq(tcx, oprnd_t); diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 9e20028569bf4..4d19bc16a3e2c 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -663,14 +663,6 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) { visit::walk_expr(rcx, expr); } - ast::ExprUnary(ast::UnBox, ref base) => { - // Managed data must not have borrowed pointers within it: - let base_ty = rcx.resolve_node_type(base.id); - type_must_outlive(rcx, infer::Managed(expr.span), - base_ty, ty::ReStatic); - visit::walk_expr(rcx, expr); - } - ast::ExprUnary(ast::UnDeref, ref base) => { // For *a, the lifetime of a must enclose the deref let method_call = MethodCall::expr(expr.id); @@ -1474,7 +1466,6 @@ fn link_region(rcx: &Rcx, mc::cat_discr(cmt_base, _) | mc::cat_downcast(cmt_base) | - mc::cat_deref(cmt_base, _, mc::GcPtr(..)) | mc::cat_deref(cmt_base, _, mc::OwnedPtr) | mc::cat_interior(cmt_base, _) => { // Borrowing interior or owned data requires the base @@ -1707,7 +1698,6 @@ fn adjust_upvar_borrow_kind_for_mut(rcx: &Rcx, } mc::cat_deref(_, _, mc::UnsafePtr(..)) | - mc::cat_deref(_, _, mc::GcPtr) | mc::cat_static_item | mc::cat_rvalue(_) | mc::cat_copied_upvar(_) | @@ -1758,7 +1748,6 @@ fn adjust_upvar_borrow_kind_for_unique(rcx: &Rcx, cmt: mc::cmt) { } mc::cat_deref(_, _, mc::UnsafePtr(..)) | - mc::cat_deref(_, _, mc::GcPtr) | mc::cat_static_item | mc::cat_rvalue(_) | mc::cat_copied_upvar(_) | diff --git a/src/librustc/middle/typeck/check/regionmanip.rs b/src/librustc/middle/typeck/check/regionmanip.rs index db9877698a365..5d75d590a09f9 100644 --- a/src/librustc/middle/typeck/check/regionmanip.rs +++ b/src/librustc/middle/typeck/check/regionmanip.rs @@ -129,7 +129,6 @@ impl<'a, 'tcx> Wf<'a, 'tcx> { ty::ty_vec(t, _) | ty::ty_ptr(ty::mt { ty: t, .. }) | - ty::ty_box(t) | ty::ty_uniq(t) => { self.accumulate_from_ty(t) } diff --git a/src/librustc/middle/typeck/check/vtable2.rs b/src/librustc/middle/typeck/check/vtable2.rs index bdcf4d73c3b84..1d765c6c7c6c2 100644 --- a/src/librustc/middle/typeck/check/vtable2.rs +++ b/src/librustc/middle/typeck/check/vtable2.rs @@ -95,7 +95,7 @@ pub fn check_object_cast(fcx: &FnCtxt, } } - // Because we currently give unsound lifetimes to the "ty_box", I + // Because we currently give unsound lifetimes to the "t_box", I // could have written &'static ty::TyTrait here, but it seems // gratuitously unsafe. fn object_trait<'a>(t: &'a ty::t) -> &'a ty::TyTrait { diff --git a/src/librustc/middle/typeck/coherence/mod.rs b/src/librustc/middle/typeck/coherence/mod.rs index cef6e31b93704..f6ac0e1666ca9 100644 --- a/src/librustc/middle/typeck/coherence/mod.rs +++ b/src/librustc/middle/typeck/coherence/mod.rs @@ -23,7 +23,7 @@ use middle::subst::{Substs}; use middle::ty::get; use middle::ty::{ImplContainer, ImplOrTraitItemId, MethodTraitItemId}; use middle::ty::{TypeTraitItemId, lookup_item_type}; -use middle::ty::{t, ty_bool, ty_char, ty_bot, ty_box, ty_enum, ty_err}; +use middle::ty::{t, ty_bool, ty_char, ty_bot, ty_enum, ty_err}; use middle::ty::{ty_str, ty_vec, ty_float, ty_infer, ty_int, ty_nil, ty_open}; use middle::ty::{ty_param, Polytype, ty_ptr}; use middle::ty::{ty_rptr, ty_struct, ty_trait, ty_tup}; @@ -84,8 +84,8 @@ fn get_base_type(inference_context: &InferCtxt, ty_nil | ty_bot | ty_bool | ty_char | ty_int(..) | ty_uint(..) | ty_float(..) | ty_str(..) | ty_vec(..) | ty_bare_fn(..) | ty_closure(..) | ty_tup(..) | - ty_infer(..) | ty_param(..) | ty_err | ty_open(..) | - ty_box(_) | ty_uniq(_) | ty_ptr(_) | ty_rptr(_, _) => { + ty_infer(..) | ty_param(..) | ty_err | ty_open(..) | ty_uniq(_) | + ty_ptr(_) | ty_rptr(_, _) => { debug!("(getting base type) no base type; found {:?}", get(original_type).sty); None diff --git a/src/librustc/middle/typeck/infer/coercion.rs b/src/librustc/middle/typeck/infer/coercion.rs index 7f9f569c37ea2..a0c190c5c817b 100644 --- a/src/librustc/middle/typeck/infer/coercion.rs +++ b/src/librustc/middle/typeck/infer/coercion.rs @@ -258,7 +258,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { let r_borrow = self.get_ref().infcx.next_region_var(coercion); let inner_ty = match *sty_a { - ty::ty_box(_) | ty::ty_uniq(_) => return Err(ty::terr_mismatch), + ty::ty_uniq(_) => return Err(ty::terr_mismatch), ty::ty_rptr(_, mt_a) => mt_a.ty, _ => { return self.subtype(a, b); diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index 4412b7d94d468..a742cf45059a4 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -495,10 +495,6 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C, a: ty::t, b: ty::t) -> cres { - this.tys(a_inner, b_inner).and_then(|typ| Ok(ty::mk_box(tcx, typ))) - } - (&ty::ty_uniq(a_inner), &ty::ty_uniq(b_inner)) => { let typ = try!(this.tys(a_inner, b_inner)); check_ptr_to_unsized(this, a, b, a_inner, b_inner, ty::mk_uniq(tcx, typ)) diff --git a/src/librustc/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index 2ad6a1f72e2cc..8ff5b3c902493 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -776,11 +776,6 @@ impl<'a, 'tcx> ErrorReporting for InferCtxt<'a, 'tcx> { sup, ""); } - infer::Managed(span) => { - self.tcx.sess.span_err( - span, - format!("cannot put borrowed references into managed memory").as_slice()); - } } } @@ -1285,7 +1280,6 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { ast::TyPtr(ref mut_ty) => { ty_queue.push(&*mut_ty.ty); } - ast::TyBox(ref ty) | ast::TyVec(ref ty) | ast::TyUniq(ref ty) | ast::TyFixedLengthVec(ref ty, _) => { @@ -1323,7 +1317,6 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { ty: build_to(mut_ty.ty, to), }) } - ast::TyBox(ty) => ast::TyBox(build_to(ty, to)), ast::TyVec(ty) => ast::TyVec(build_to(ty, to)), ast::TyUniq(ty) => ast::TyUniq(build_to(ty, to)), ast::TyFixedLengthVec(ty, e) => { @@ -1614,11 +1607,6 @@ impl<'a, 'tcx> ErrorReportingHelpers for InferCtxt<'a, 'tcx> { does not outlive the data it points at", self.ty_to_string(ty)).as_slice()); } - infer::Managed(span) => { - self.tcx.sess.span_note( - span, - "...so that the value can be stored in managed memory."); - } infer::RelateParamBound(span, param_ty, t) => { self.tcx.sess.span_note( span, diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index c36192777f0a9..44bda134909bb 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -216,9 +216,6 @@ pub enum SubregionOrigin { // An auto-borrow that does not enclose the expr where it occurs AutoBorrow(Span), - - // Managed data cannot contain borrowed pointers. - Managed(Span), } /// Reasons to create a region inference variable @@ -1029,7 +1026,6 @@ impl SubregionOrigin { CallReturn(a) => a, AddrOf(a) => a, AutoBorrow(a) => a, - Managed(a) => a, } } } @@ -1102,7 +1098,6 @@ impl Repr for SubregionOrigin { CallReturn(a) => format!("CallReturn({})", a.repr(tcx)), AddrOf(a) => format!("AddrOf({})", a.repr(tcx)), AutoBorrow(a) => format!("AutoBorrow({})", a.repr(tcx)), - Managed(a) => format!("Managed({})", a.repr(tcx)), } } } diff --git a/src/librustc/middle/typeck/infer/skolemize.rs b/src/librustc/middle/typeck/infer/skolemize.rs index 4002f5984497b..54ece395be94c 100644 --- a/src/librustc/middle/typeck/infer/skolemize.rs +++ b/src/librustc/middle/typeck/infer/skolemize.rs @@ -143,7 +143,6 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeSkolemizer<'a, 'tcx> { ty::ty_uint(..) | ty::ty_float(..) | ty::ty_enum(..) | - ty::ty_box(..) | ty::ty_uniq(..) | ty::ty_str | ty::ty_err | diff --git a/src/librustc/middle/typeck/variance.rs b/src/librustc/middle/typeck/variance.rs index a6edfcf80fdac..9317ba2c7fa93 100644 --- a/src/librustc/middle/typeck/variance.rs +++ b/src/librustc/middle/typeck/variance.rs @@ -742,7 +742,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { self.add_constraints_from_mt(mt, variance); } - ty::ty_uniq(typ) | ty::ty_box(typ) | ty::ty_vec(typ, _) | ty::ty_open(typ) => { + ty::ty_uniq(typ) | ty::ty_vec(typ, _) | ty::ty_open(typ) => { self.add_constraints_from_ty(typ, variance); } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 5ca6d08720fa6..18cf805bccba0 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -17,7 +17,7 @@ use middle::ty::{ReEarlyBound, BrFresh, ctxt}; use middle::ty::{ReFree, ReScope, ReInfer, ReStatic, Region, ReEmpty}; use middle::ty::{ReSkolemized, ReVar}; use middle::ty::{mt, t, ParamTy}; -use middle::ty::{ty_bool, ty_char, ty_bot, ty_box, ty_struct, ty_enum}; +use middle::ty::{ty_bool, ty_char, ty_bot, ty_struct, ty_enum}; use middle::ty::{ty_err, ty_str, ty_vec, ty_float, ty_bare_fn, ty_closure}; use middle::ty::{ty_nil, ty_param, ty_ptr, ty_rptr, ty_tup, ty_open}; use middle::ty::{ty_unboxed_closure}; @@ -375,7 +375,6 @@ pub fn ty_to_string(cx: &ctxt, typ: t) -> String { ty_int(t) => ast_util::int_ty_to_string(t, None).to_string(), ty_uint(t) => ast_util::uint_ty_to_string(t, None).to_string(), ty_float(t) => ast_util::float_ty_to_string(t).to_string(), - ty_box(typ) => format!("Gc<{}>", ty_to_string(cx, typ)), ty_uniq(typ) => format!("Box<{}>", ty_to_string(cx, typ)), ty_ptr(ref tm) => { format!("*{} {}", match tm.mutbl { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 0b04536f05443..e251544b5bee0 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1087,7 +1087,6 @@ pub enum Type { /// aka TyBot Bottom, Unique(Box), - Managed(Box), RawPointer(Mutability, Box), BorrowedRef { pub lifetime: Option, @@ -1215,7 +1214,6 @@ impl Clean for ast::Ty { TyRptr(ref l, ref m) => BorrowedRef {lifetime: l.clean(cx), mutability: m.mutbl.clean(cx), type_: box m.ty.clean(cx)}, - TyBox(ref ty) => Managed(box ty.clean(cx)), TyUniq(ref ty) => Unique(box ty.clean(cx)), TyVec(ref ty) => Vector(box ty.clean(cx)), TyFixedLengthVec(ref ty, ref e) => FixedVector(box ty.clean(cx), @@ -1254,12 +1252,6 @@ impl Clean for ty::t { ty::ty_float(ast::TyF32) => Primitive(F32), ty::ty_float(ast::TyF64) => Primitive(F64), ty::ty_str => Primitive(Str), - ty::ty_box(t) => { - let gc_did = cx.tcx_opt().and_then(|tcx| { - tcx.lang_items.gc() - }); - lang_struct(cx, gc_did, t, "Gc", Managed) - } ty::ty_uniq(t) => { let box_did = cx.tcx_opt().and_then(|tcx| { tcx.lang_items.owned_box() diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index b52b34ff58124..6a001b324706f 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -476,7 +476,7 @@ impl fmt::Show for clean::Type { }; write!(f, "&{}{}{}", lt, MutableSpace(mutability), **ty) } - clean::Unique(..) | clean::Managed(..) => { + clean::Unique(..) => { fail!("should have been cleaned") } } diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index b46d8727b69d0..77d63224fcd6d 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -16,7 +16,7 @@ #![crate_type = "rlib"] #![allow(unknown_features)] -#![feature(globs, struct_variant, managed_boxes, macro_rules, phase, slicing_syntax)] +#![feature(globs, struct_variant, macro_rules, phase, slicing_syntax)] extern crate arena; extern crate debug; diff --git a/src/librustrt/lib.rs b/src/librustrt/lib.rs index 1183b14fb4e16..d3ea07291a423 100644 --- a/src/librustrt/lib.rs +++ b/src/librustrt/lib.rs @@ -17,7 +17,7 @@ html_root_url = "http://doc.rust-lang.org/master/")] #![allow(unknown_features)] -#![feature(macro_rules, phase, globs, thread_local, managed_boxes, asm)] +#![feature(macro_rules, phase, globs, thread_local, asm)] #![feature(linkage, lang_items, unsafe_destructor, default_type_params)] #![feature(import_shadowing, slicing_syntax)] #![no_std] @@ -58,7 +58,6 @@ pub mod c_str; pub mod exclusive; pub mod local; pub mod local_data; -pub mod local_heap; pub mod mutex; pub mod rtio; pub mod stack; @@ -105,9 +104,8 @@ pub static DEFAULT_ERROR_CODE: int = 101; /// One-time runtime initialization. /// -/// Initializes global state, including frobbing -/// the crate's logging flags, registering GC -/// metadata, and storing the process arguments. +/// Initializes global state, including frobbing the crate's logging flags, +/// and storing the process arguments. pub fn init(argc: int, argv: *const *const u8) { // FIXME: Derefing these pointers is not safe. // Need to propagate the unsafety to `start`. diff --git a/src/librustrt/local_data.rs b/src/librustrt/local_data.rs index e7ce5b7dca8cb..fcef5981f0a35 100644 --- a/src/librustrt/local_data.rs +++ b/src/librustrt/local_data.rs @@ -411,7 +411,6 @@ mod tests { extern crate test; use std::prelude::*; - use std::gc::{Gc, GC}; use super::*; use std::task; @@ -467,11 +466,11 @@ mod tests { #[test] fn test_tls_multiple_types() { static str_key: Key = &KeyValueKey; - static box_key: Key> = &KeyValueKey; + static box_key: Key> = &KeyValueKey; static int_key: Key = &KeyValueKey; task::spawn(proc() { str_key.replace(Some("string data".to_string())); - box_key.replace(Some(box(GC) ())); + box_key.replace(Some(box 0)); int_key.replace(Some(42)); }); } @@ -479,13 +478,13 @@ mod tests { #[test] fn test_tls_overwrite_multiple_types() { static str_key: Key = &KeyValueKey; - static box_key: Key> = &KeyValueKey; + static box_key: Key> = &KeyValueKey; static int_key: Key = &KeyValueKey; task::spawn(proc() { str_key.replace(Some("string data".to_string())); str_key.replace(Some("string data 2".to_string())); - box_key.replace(Some(box(GC) ())); - box_key.replace(Some(box(GC) ())); + box_key.replace(Some(box 0)); + box_key.replace(Some(box 1)); int_key.replace(Some(42)); // This could cause a segfault if overwriting-destruction is done // with the crazy polymorphic transmute rather than the provided @@ -498,13 +497,13 @@ mod tests { #[should_fail] fn test_tls_cleanup_on_failure() { static str_key: Key = &KeyValueKey; - static box_key: Key> = &KeyValueKey; + static box_key: Key> = &KeyValueKey; static int_key: Key = &KeyValueKey; str_key.replace(Some("parent data".to_string())); - box_key.replace(Some(box(GC) ())); + box_key.replace(Some(box 0)); task::spawn(proc() { str_key.replace(Some("string data".to_string())); - box_key.replace(Some(box(GC) ())); + box_key.replace(Some(box 2)); int_key.replace(Some(42)); fail!(); }); diff --git a/src/librustrt/local_heap.rs b/src/librustrt/local_heap.rs deleted file mode 100644 index 0e84e9c0097f5..0000000000000 --- a/src/librustrt/local_heap.rs +++ /dev/null @@ -1,345 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The local, garbage collected heap - -use core::prelude::*; - -use alloc::libc_heap; -use alloc::util; -use libc::{c_void, free}; - -use core::mem; -use core::ptr; -use core::raw; -use local::Local; -use task::Task; - -static RC_IMMORTAL : uint = 0x77777777; - -pub type Box = raw::GcBox<()>; - -pub struct MemoryRegion { - live_allocations: uint, -} - -pub struct LocalHeap { - memory_region: MemoryRegion, - live_allocs: *mut raw::GcBox<()>, -} - -impl LocalHeap { - pub fn new() -> LocalHeap { - LocalHeap { - memory_region: MemoryRegion { live_allocations: 0 }, - live_allocs: ptr::null_mut(), - } - } - - #[inline] - #[allow(deprecated)] - pub fn alloc(&mut self, - drop_glue: fn(*mut u8), - size: uint, - align: uint) -> *mut Box { - let total_size = util::get_box_size(size, align); - let alloc = self.memory_region.malloc(total_size); - { - // Make sure that we can't use `mybox` outside of this scope - let mybox: &mut Box = unsafe { mem::transmute(alloc) }; - // Clear out this box, and move it to the front of the live - // allocations list - mybox.drop_glue = drop_glue; - mybox.ref_count = 1; - mybox.prev = ptr::null_mut(); - mybox.next = self.live_allocs; - if !self.live_allocs.is_null() { - unsafe { (*self.live_allocs).prev = alloc; } - } - self.live_allocs = alloc; - } - return alloc; - } - - #[inline] - pub fn realloc(&mut self, ptr: *mut Box, size: uint) -> *mut Box { - // Make sure that we can't use `mybox` outside of this scope - let total_size = size + mem::size_of::(); - let new_box = self.memory_region.realloc(ptr, total_size); - { - // Fix links because we could have moved around - let mybox: &mut Box = unsafe { mem::transmute(new_box) }; - if !mybox.prev.is_null() { - unsafe { (*mybox.prev).next = new_box; } - } - if !mybox.next.is_null() { - unsafe { (*mybox.next).prev = new_box; } - } - } - if self.live_allocs == ptr { - self.live_allocs = new_box; - } - return new_box; - } - - #[inline] - pub fn free(&mut self, alloc: *mut Box) { - { - // Make sure that we can't use `mybox` outside of this scope - let mybox: &mut Box = unsafe { mem::transmute(alloc) }; - - // Unlink it from the linked list - if !mybox.prev.is_null() { - unsafe { (*mybox.prev).next = mybox.next; } - } - if !mybox.next.is_null() { - unsafe { (*mybox.next).prev = mybox.prev; } - } - if self.live_allocs == alloc { - self.live_allocs = mybox.next; - } - } - - self.memory_region.free(alloc); - } - - /// Immortalize all pending allocations, forcing them to live forever. - /// - /// This function will freeze all allocations to prevent all pending - /// allocations from being deallocated. This is used in preparation for when - /// a task is about to destroy TLD. - pub unsafe fn immortalize(&mut self) { - let mut n_total_boxes = 0u; - - // Pass 1: Make all boxes immortal. - // - // In this pass, nothing gets freed, so it does not matter whether - // we read the next field before or after the callback. - self.each_live_alloc(true, |_, alloc| { - n_total_boxes += 1; - (*alloc).ref_count = RC_IMMORTAL; - }); - - if debug_mem() { - // We do logging here w/o allocation. - rterrln!("total boxes annihilated: {}", n_total_boxes); - } - } - - /// Continues deallocation of the all pending allocations in this arena. - /// - /// This is invoked from the destructor, and requires that `immortalize` has - /// been called previously. - unsafe fn annihilate(&mut self) { - // Pass 2: Drop all boxes. - // - // In this pass, unique-managed boxes may get freed, but not - // managed boxes, so we must read the `next` field *after* the - // callback, as the original value may have been freed. - self.each_live_alloc(false, |_, alloc| { - let drop_glue = (*alloc).drop_glue; - let data = &mut (*alloc).data as *mut (); - drop_glue(data as *mut u8); - }); - - // Pass 3: Free all boxes. - // - // In this pass, managed boxes may get freed (but not - // unique-managed boxes, though I think that none of those are - // left), so we must read the `next` field before, since it will - // not be valid after. - self.each_live_alloc(true, |me, alloc| { - me.free(alloc); - }); - } - - unsafe fn each_live_alloc(&mut self, read_next_before: bool, - f: |&mut LocalHeap, alloc: *mut raw::GcBox<()>|) { - //! Walks the internal list of allocations - - let mut alloc = self.live_allocs; - while alloc != ptr::null_mut() { - let next_before = (*alloc).next; - - f(self, alloc); - - if read_next_before { - alloc = next_before; - } else { - alloc = (*alloc).next; - } - } - } -} - -impl Drop for LocalHeap { - fn drop(&mut self) { - unsafe { self.annihilate() } - assert!(self.live_allocs.is_null()); - } -} - -struct AllocHeader; - -impl AllocHeader { - fn init(&mut self, _size: u32) {} - fn assert_sane(&self) {} - fn update_size(&mut self, _size: u32) {} - - fn as_box(&mut self) -> *mut Box { - let myaddr: uint = unsafe { mem::transmute(self) }; - (myaddr + AllocHeader::size()) as *mut Box - } - - fn size() -> uint { - // For some platforms, 16 byte alignment is required. - let ptr_size = 16; - let header_size = mem::size_of::(); - return (header_size + ptr_size - 1) / ptr_size * ptr_size; - } - - fn from(a_box: *mut Box) -> *mut AllocHeader { - (a_box as uint - AllocHeader::size()) as *mut AllocHeader - } -} - -#[cfg(unix)] -fn debug_mem() -> bool { - // FIXME: Need to port the environment struct to newsched - false -} - -#[cfg(windows)] -fn debug_mem() -> bool { - false -} - -impl MemoryRegion { - #[inline] - fn malloc(&mut self, size: uint) -> *mut Box { - let total_size = size + AllocHeader::size(); - let alloc: *mut AllocHeader = unsafe { - libc_heap::malloc_raw(total_size) as *mut AllocHeader - }; - - let alloc: &mut AllocHeader = unsafe { mem::transmute(alloc) }; - alloc.init(size as u32); - self.claim(alloc); - self.live_allocations += 1; - - return alloc.as_box(); - } - - #[inline] - fn realloc(&mut self, alloc: *mut Box, size: uint) -> *mut Box { - rtassert!(!alloc.is_null()); - let orig_alloc = AllocHeader::from(alloc); - unsafe { (*orig_alloc).assert_sane(); } - - let total_size = size + AllocHeader::size(); - let alloc: *mut AllocHeader = unsafe { - libc_heap::realloc_raw(orig_alloc as *mut u8, total_size) as *mut AllocHeader - }; - - let alloc: &mut AllocHeader = unsafe { mem::transmute(alloc) }; - alloc.assert_sane(); - alloc.update_size(size as u32); - self.update(alloc, orig_alloc as *mut AllocHeader); - return alloc.as_box(); - } - - #[inline] - fn free(&mut self, alloc: *mut Box) { - rtassert!(!alloc.is_null()); - let alloc = AllocHeader::from(alloc); - unsafe { - (*alloc).assert_sane(); - self.release(mem::transmute(alloc)); - rtassert!(self.live_allocations > 0); - self.live_allocations -= 1; - free(alloc as *mut c_void) - } - } - - #[inline] - fn claim(&mut self, _alloc: &mut AllocHeader) {} - #[inline] - fn release(&mut self, _alloc: &AllocHeader) {} - #[inline] - fn update(&mut self, _alloc: &mut AllocHeader, _orig: *mut AllocHeader) {} -} - -impl Drop for MemoryRegion { - fn drop(&mut self) { - if self.live_allocations != 0 { - rtabort!("leaked managed memory ({} objects)", self.live_allocations); - } - } -} - -#[cfg(not(test))] -#[lang="malloc"] -#[inline] -pub unsafe fn local_malloc_(drop_glue: fn(*mut u8), size: uint, - align: uint) -> *mut u8 { - local_malloc(drop_glue, size, align) -} - -#[inline] -pub unsafe fn local_malloc(drop_glue: fn(*mut u8), size: uint, - align: uint) -> *mut u8 { - // FIXME: Unsafe borrow for speed. Lame. - let task: Option<*mut Task> = Local::try_unsafe_borrow(); - match task { - Some(task) => { - (*task).heap.alloc(drop_glue, size, align) as *mut u8 - } - None => rtabort!("local malloc outside of task") - } -} - -#[cfg(not(test))] -#[lang="free"] -#[inline] -pub unsafe fn local_free_(ptr: *mut u8) { - local_free(ptr) -} - -// NB: Calls to free CANNOT be allowed to fail, as throwing an exception from -// inside a landing pad may corrupt the state of the exception handler. If a -// problem occurs, call exit instead. -#[inline] -pub unsafe fn local_free(ptr: *mut u8) { - // FIXME: Unsafe borrow for speed. Lame. - let task_ptr: Option<*mut Task> = Local::try_unsafe_borrow(); - match task_ptr { - Some(task) => { - (*task).heap.free(ptr as *mut Box) - } - None => rtabort!("local free outside of task") - } -} - -#[cfg(test)] -mod bench { - extern crate test; - use self::test::Bencher; - use std::gc::GC; - - #[bench] - fn alloc_managed_small(b: &mut Bencher) { - b.iter(|| { box(GC) 10i }); - } - - #[bench] - fn alloc_managed_big(b: &mut Bencher) { - b.iter(|| { box(GC) ([10i, ..1000]) }); - } -} diff --git a/src/librustrt/task.rs b/src/librustrt/task.rs index 3d42b91fef17e..ca5f76cf0d45a 100644 --- a/src/librustrt/task.rs +++ b/src/librustrt/task.rs @@ -9,9 +9,8 @@ // except according to those terms. //! Language-level runtime services that should reasonably expected -//! to be available 'everywhere'. Local heaps, GC, unwinding, -//! local storage, and logging. Even a 'freestanding' Rust would likely want -//! to implement this. +//! to be available 'everywhere'. Unwinding, local storage, and logging. +//! Even a 'freestanding' Rust would likely want to implement this. use alloc::arc::Arc; use alloc::boxed::{BoxAny, Box}; @@ -27,7 +26,6 @@ use core::raw; use local_data; use Runtime; use local::Local; -use local_heap::LocalHeap; use rtio::LocalIo; use unwind; use unwind::Unwinder; @@ -95,8 +93,6 @@ use collections::str::SendStr; /// # } /// ``` pub struct Task { - pub heap: LocalHeap, - pub gc: GarbageCollector, pub storage: LocalStorage, pub unwinder: Unwinder, pub death: Death, @@ -132,7 +128,6 @@ pub struct TaskOpts { /// children tasks complete, recommend using a result future. pub type Result = ::core::result::Result<(), Box>; -pub struct GarbageCollector; pub struct LocalStorage(pub Option); /// A handle to a blocked task. Usually this means having the Box @@ -163,8 +158,6 @@ impl Task { /// task creation functions through libnative or libgreen. pub fn new() -> Task { Task { - heap: LocalHeap::new(), - gc: GarbageCollector, storage: LocalStorage(None), unwinder: Unwinder::new(), death: Death::new(), @@ -264,32 +257,22 @@ impl Task { /// already been destroyed and/or annihilated. fn cleanup(self: Box, result: Result) -> Box { // The first thing to do when cleaning up is to deallocate our local - // resources, such as TLD and GC data. + // resources, such as TLD. // // FIXME: there are a number of problems with this code // // 1. If any TLD object fails destruction, then all of TLD will leak. // This appears to be a consequence of #14875. // - // 2. Failing during GC annihilation aborts the runtime #14876. + // 2. Setting a TLD key while destroying TLD will abort the runtime #14807. // - // 3. Setting a TLD key while destroying TLD or while destroying GC will - // abort the runtime #14807. - // - // 4. Invoking GC in GC destructors will abort the runtime #6996. - // - // 5. The order of destruction of TLD and GC matters, but either way is - // susceptible to leaks (see 3/4) #8302. + // 3. The order of destruction of TLD matters, but either way is + // susceptible to leaks (see 2) #8302. // // That being said, there are a few upshots to this code // // 1. If TLD destruction fails, heap destruction will be attempted. - // There is a test for this at fail-during-tld-destroy.rs. Sadly the - // other way can't be tested due to point 2 above. Note that we must - // immortalize the heap first because if any deallocations are - // attempted while TLD is being dropped it will attempt to free the - // allocation from the wrong heap (because the current one has been - // replaced). + // There is a test for this at fail-during-tld-destroy.rs. // // 2. One failure in destruction is tolerable, so long as the task // didn't originally fail while it was running. @@ -301,15 +284,10 @@ impl Task { let &LocalStorage(ref mut optmap) = &mut task.storage; optmap.take() }; - let mut heap = mem::replace(&mut task.heap, LocalHeap::new()); - unsafe { heap.immortalize() } drop(task); // First, destroy task-local storage. This may run user dtors. drop(tld); - - // Destroy remaining boxes. Also may run user dtors. - drop(heap); }); // If the above `run` block failed, then it must be the case that the @@ -327,9 +305,8 @@ impl Task { Local::put(task); // FIXME: this is running in a seriously constrained context. If this - // allocates GC or allocates TLD then it will likely abort the - // runtime. Similarly, if this fails, this will also likely abort - // the runtime. + // allocates TLD then it will likely abort the runtime. Similarly, + // if this fails, this will also likely abort the runtime. // // This closure is currently limited to a channel send via the // standard library's task interface, but this needs @@ -577,23 +554,14 @@ mod test { use super::*; use std::prelude::*; use std::task; - use std::gc::{Gc, GC}; - - #[test] - fn local_heap() { - let a = box(GC) 5i; - let b = a; - assert!(*a == 5); - assert!(*b == 5); - } #[test] fn tls() { - local_data_key!(key: Gc) - key.replace(Some(box(GC) "data".to_string())); + local_data_key!(key: String) + key.replace(Some("data".to_string())); assert_eq!(key.get().unwrap().as_slice(), "data"); - local_data_key!(key2: Gc) - key2.replace(Some(box(GC) "data".to_string())); + local_data_key!(key2: String) + key2.replace(Some("data".to_string())); assert_eq!(key2.get().unwrap().as_slice(), "data"); } @@ -628,23 +596,6 @@ mod test { assert!(rx.recv() == 10); } - #[test] - fn heap_cycles() { - use std::cell::RefCell; - - struct List { - next: Option>>, - } - - let a = box(GC) RefCell::new(List { next: None }); - let b = box(GC) RefCell::new(List { next: Some(a) }); - - { - let mut a = a.borrow_mut(); - a.next = Some(b); - } - } - #[test] #[should_fail] fn test_begin_unwind() { diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index 8c2f323532235..6de8ca198448f 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -24,7 +24,7 @@ Core encoding and decoding interfaces. html_root_url = "http://doc.rust-lang.org/master/", html_playground_url = "http://play.rust-lang.org/")] #![allow(unknown_features)] -#![feature(macro_rules, managed_boxes, default_type_params, phase, slicing_syntax)] +#![feature(macro_rules, default_type_params, phase, slicing_syntax)] // test harness access #[cfg(test)] diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index d005a8ef004fd..3bed4e4040b3a 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -16,7 +16,6 @@ Core encoding and decoding interfaces. use std::path; use std::rc::Rc; -use std::gc::{Gc, GC}; use std::cell::{Cell, RefCell}; pub trait Encoder { @@ -392,12 +391,6 @@ impl,T:Decodable> Decodable for Box { } } -impl,T:'static + Encodable> Encodable for Gc { - fn encode(&self, s: &mut S) -> Result<(), E> { - (**self).encode(s) - } -} - impl,T:Encodable> Encodable for Rc { #[inline] fn encode(&self, s: &mut S) -> Result<(), E> { @@ -412,12 +405,6 @@ impl,T:Decodable> Decodable for Rc { } } -impl,T:Decodable + 'static> Decodable for Gc { - fn decode(d: &mut D) -> Result, E> { - Ok(box(GC) try!(Decodable::decode(d))) - } -} - impl<'a, E, S:Encoder,T:Encodable> Encodable for &'a [T] { fn encode(&self, s: &mut S) -> Result<(), E> { s.emit_seq(self.len(), |s| { diff --git a/src/libstd/gc.rs b/src/libstd/gc.rs deleted file mode 100644 index ecef8e9ed9022..0000000000000 --- a/src/libstd/gc.rs +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/*! Task-local garbage-collected boxes - -The `Gc` type provides shared ownership of an immutable value. Destruction is not deterministic, and -will occur some time between every `Gc` handle being gone and the end of the task. The garbage -collector is task-local so `Gc` is not sendable. - -*/ - -#![experimental] -#![allow(experimental)] - -use clone::Clone; -use cmp::{Ord, PartialOrd, Ordering, Eq, PartialEq}; -use default::Default; -use fmt; -use hash; -use kinds::marker; -use option::Option; -use ops::Deref; -use raw; - -/// Immutable garbage-collected pointer type -#[lang="gc"] -#[experimental = "Gc is currently based on reference-counting and will not collect cycles until \ - task annihilation. For now, cycles need to be broken manually by using `Rc` \ - with a non-owning `Weak` pointer. A tracing garbage collector is planned."] -pub struct Gc { - _ptr: *mut T, - marker: marker::NoSend, -} - -#[unstable] -impl Clone for Gc { - /// Clone the pointer only - #[inline] - fn clone(&self) -> Gc { *self } -} - -/// An value that represents the task-local managed heap. -/// -/// Use this like `let foo = box(GC) Bar::new(...);` -#[lang="managed_heap"] -#[cfg(not(test))] -pub static GC: () = (); - -impl PartialEq for Gc { - #[inline] - fn eq(&self, other: &Gc) -> bool { *(*self) == *(*other) } - #[inline] - fn ne(&self, other: &Gc) -> bool { *(*self) != *(*other) } -} -impl PartialOrd for Gc { - #[inline] - fn partial_cmp(&self, other: &Gc) -> Option { - (**self).partial_cmp(&**other) - } - #[inline] - fn lt(&self, other: &Gc) -> bool { *(*self) < *(*other) } - #[inline] - fn le(&self, other: &Gc) -> bool { *(*self) <= *(*other) } - #[inline] - fn ge(&self, other: &Gc) -> bool { *(*self) >= *(*other) } - #[inline] - fn gt(&self, other: &Gc) -> bool { *(*self) > *(*other) } -} -impl Ord for Gc { - #[inline] - fn cmp(&self, other: &Gc) -> Ordering { (**self).cmp(&**other) } -} -impl Eq for Gc {} - -impl Deref for Gc { - fn deref<'a>(&'a self) -> &'a T { &**self } -} - -impl Default for Gc { - fn default() -> Gc { - box(GC) Default::default() - } -} - -impl raw::Repr<*const raw::GcBox> for Gc {} - -impl + 'static> hash::Hash for Gc { - fn hash(&self, s: &mut S) { - (**self).hash(s) - } -} - -impl fmt::Show for Gc { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - (**self).fmt(f) - } -} - -#[cfg(test)] -mod tests { - use prelude::*; - use super::*; - use cell::RefCell; - - #[test] - fn test_managed_clone() { - let a = box(GC) 5i; - let b: Gc = a.clone(); - assert!(a == b); - } - - #[test] - fn test_clone() { - let x = Gc::new(RefCell::new(5)); - let y = x.clone(); - *x.borrow().borrow_mut() = 20; - assert_eq!(*y.borrow().borrow(), 20); - } - - #[test] - fn test_simple() { - let x = Gc::new(5); - assert_eq!(*x.borrow(), 5); - } - - #[test] - fn test_simple_clone() { - let x = Gc::new(5); - let y = x.clone(); - assert_eq!(*x.borrow(), 5); - assert_eq!(*y.borrow(), 5); - } - - #[test] - fn test_ptr_eq() { - let x = Gc::new(5); - let y = x.clone(); - let z = Gc::new(7); - assert!(x.ptr_eq(&x)); - assert!(x.ptr_eq(&y)); - assert!(!x.ptr_eq(&z)); - } - - #[test] - fn test_destructor() { - let x = Gc::new(box 5); - assert_eq!(**x.borrow(), 5); - } -} diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 82de55efad603..19b4d430562fd 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -106,7 +106,7 @@ html_playground_url = "http://play.rust-lang.org/")] #![allow(unknown_features)] -#![feature(macro_rules, globs, managed_boxes, linkage)] +#![feature(macro_rules, globs, linkage)] #![feature(default_type_params, phase, lang_items, unsafe_destructor)] #![feature(import_shadowing, slicing_syntax)] @@ -137,7 +137,6 @@ extern crate rustrt; #[cfg(test)] pub use realstd::cmp; #[cfg(test)] pub use realstd::ty; #[cfg(test)] pub use realstd::boxed; -#[cfg(test)] pub use realstd::gc; // NB: These reexports are in the order they should be listed in rustdoc @@ -220,9 +219,6 @@ pub mod rand; pub mod ascii; -#[cfg(not(test))] -pub mod gc; - pub mod time; /* Common traits */ diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 59c824d0eae77..0a87c0a344e52 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -416,7 +416,6 @@ pub enum BinOp { #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum UnOp { - UnBox, UnUniq, UnDeref, UnNot, @@ -953,7 +952,6 @@ pub struct UnboxedFnTy { pub enum Ty_ { TyNil, TyBot, /* bottom type */ - TyBox(P), TyUniq(P), TyVec(P), TyFixedLengthVec(P, P), diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 6d61c851476c3..3186006258041 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -90,7 +90,6 @@ pub fn is_shift_binop(b: BinOp) -> bool { pub fn unop_to_string(op: UnOp) -> &'static str { match op { - UnBox => "box(GC) ", UnUniq => "box() ", UnDeref => "*", UnNot => "!", diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index f2b806f43ccbb..1fdb6dd505f45 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -112,7 +112,6 @@ pub trait AstBuilder { fn expr_deref(&self, sp: Span, e: P) -> P; fn expr_unary(&self, sp: Span, op: ast::UnOp, e: P) -> P; - fn expr_managed(&self, sp: Span, e: P) -> P; fn expr_addr_of(&self, sp: Span, e: P) -> P; fn expr_mut_addr_of(&self, sp: Span, e: P) -> P; fn expr_field_access(&self, span: Span, expr: P, ident: ast::Ident) -> P; @@ -565,10 +564,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.expr(sp, ast::ExprUnary(op, e)) } - fn expr_managed(&self, sp: Span, e: P) -> P { - self.expr_unary(sp, ast::UnBox, e) - } - fn expr_field_access(&self, sp: Span, expr: P, ident: ast::Ident) -> P { let field_name = token::get_ident(ident); let field_span = Span { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 38de2a9c284f0..7dcc039a83f26 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -40,7 +40,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[ ("struct_variant", Active), ("once_fns", Active), ("asm", Active), - ("managed_boxes", Active), + ("managed_boxes", Removed), ("non_ascii_idents", Active), ("thread_local", Active), ("link_args", Active), @@ -136,14 +136,6 @@ impl<'a> Context<'a> { } } - fn gate_box(&self, span: Span) { - self.gate_feature("managed_boxes", span, - "The managed box syntax is being replaced by the \ - `std::gc::Gc` and `std::rc::Rc` types. Equivalent \ - functionality to managed trait objects will be \ - implemented but is currently missing."); - } - fn has_feature(&self, feature: &str) -> bool { self.features.iter().any(|n| n.as_slice() == feature) } @@ -331,7 +323,6 @@ impl<'a, 'v> Visitor<'v> for Context<'a> { experimental and likely to be removed"); }, - ast::TyBox(_) => { self.gate_box(t.span); } ast::TyUnboxedFn(..) => { self.gate_feature("unboxed_closure_sugar", t.span, @@ -345,9 +336,6 @@ impl<'a, 'v> Visitor<'v> for Context<'a> { fn visit_expr(&mut self, e: &ast::Expr) { match e.node { - ast::ExprUnary(ast::UnBox, _) => { - self.gate_box(e.span); - } ast::ExprUnboxedFn(..) => { self.gate_feature("unboxed_closures", e.span, diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 31bec58a4daa6..84de6c3b91339 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -372,7 +372,6 @@ pub fn noop_fold_ty(t: P, fld: &mut T) -> P { id: fld.new_id(id), node: match node { TyNil | TyBot | TyInfer => node, - TyBox(ty) => TyBox(fld.fold_ty(ty)), TyUniq(ty) => TyUniq(fld.fold_ty(ty)), TyVec(ty) => TyVec(fld.fold_ty(ty)), TyPtr(mt) => TyPtr(fld.fold_mt(mt)), diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index d47231bc3e2de..1a6fb9b85dd25 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -31,8 +31,6 @@ pub enum ObsoleteSyntax { ObsoleteOwnedPattern, ObsoleteOwnedVector, ObsoleteOwnedSelf, - ObsoleteManagedType, - ObsoleteManagedExpr, ObsoleteImportRenaming, ObsoleteSubsliceMatch, ObsoleteExternCrateRenaming, @@ -77,14 +75,6 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> { "`~self` is no longer supported", "write `self: Box` instead" ), - ObsoleteManagedType => ( - "`@` notation for managed pointers", - "use `Gc` in `std::gc` instead" - ), - ObsoleteManagedExpr => ( - "`@` notation for a managed pointer allocation", - "use the `box(GC)` operator instead of `@`" - ), ObsoleteImportRenaming => ( "`use foo = bar` syntax", "write `use bar as foo` instead" diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c8f1b7f9a8e6d..7cce9c2dc3a80 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -16,8 +16,7 @@ use ast::{RegionTyParamBound, TraitTyParamBound}; use ast::{ProvidedMethod, Public, FnStyle}; use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue}; use ast::{BiBitAnd, BiBitOr, BiBitXor, BiRem, Block}; -use ast::{BlockCheckMode, UnBox}; -use ast::{CaptureByRef, CaptureByValue, CaptureClause}; +use ast::{BlockCheckMode, CaptureByRef, CaptureByValue, CaptureClause}; use ast::{Crate, CrateConfig, Decl, DeclItem}; use ast::{DeclLocal, DefaultBlock, UnDeref, BiDiv, EMPTY_CTXT, EnumDef, ExplicitSelf}; use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain}; @@ -50,7 +49,7 @@ use ast::{StructVariantKind, BiSub}; use ast::StrStyle; use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue}; use ast::{TokenTree, TraitItem, TraitRef, TTDelim, TTSeq, TTTok}; -use ast::{TTNonterminal, TupleVariantKind, Ty, Ty_, TyBot, TyBox}; +use ast::{TTNonterminal, TupleVariantKind, Ty, Ty_, TyBot}; use ast::{TypeField, TyFixedLengthVec, TyClosure, TyProc, TyBareFn}; use ast::{TyTypeof, TyInfer, TypeMethod}; use ast::{TyNil, TyParam, TyParamBound, TyParen, TyPath, TyPtr, TyQPath}; @@ -1450,12 +1449,6 @@ impl<'a> Parser<'a> { t } } - } else if self.token == token::AT { - // MANAGED POINTER - self.bump(); - let span = self.last_span; - self.obsolete(span, ObsoleteManagedType); - TyBox(self.parse_ty(plus_allowed)) } else if self.token == token::TILDE { // OWNED POINTER self.bump(); @@ -2723,14 +2716,6 @@ impl<'a> Parser<'a> { hi = e.span.hi; ex = ExprAddrOf(m, e); } - token::AT => { - self.bump(); - let span = self.last_span; - self.obsolete(span, ObsoleteManagedExpr); - let e = self.parse_prefix_expr(); - hi = e.span.hi; - ex = self.mk_unary(UnBox, e); - } token::TILDE => { self.bump(); let last_span = self.last_span; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index a8e99b4e85f2b..8400d9aea3b59 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -546,10 +546,6 @@ impl<'a> State<'a> { match ty.node { ast::TyNil => try!(word(&mut self.s, "()")), ast::TyBot => try!(word(&mut self.s, "!")), - ast::TyBox(ref ty) => { - try!(word(&mut self.s, "@")); - try!(self.print_type(&**ty)); - } ast::TyUniq(ref ty) => { try!(word(&mut self.s, "~")); try!(self.print_type(&**ty)); diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 828a6124aa09f..00fdf43663673 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -13,7 +13,6 @@ #![allow(dead_code)] #![allow(unused_imports)] -use std::gc::{Gc, GC}; use std::slice; use std::mem; use std::vec; diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 6fc79e2c42ab9..249f87d3102dd 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -326,7 +326,7 @@ pub fn skip_ty<'v, V: Visitor<'v>>(_: &mut V, _: &'v Ty) { pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { match typ.node { - TyUniq(ref ty) | TyVec(ref ty) | TyBox(ref ty) | TyParen(ref ty) => { + TyUniq(ref ty) | TyVec(ref ty) | TyParen(ref ty) => { visitor.visit_ty(&**ty) } TyPtr(ref mutable_type) => { diff --git a/src/test/auxiliary/cci_nested_lib.rs b/src/test/auxiliary/cci_nested_lib.rs index b097e688b4272..bbaf7991fd3cc 100644 --- a/src/test/auxiliary/cci_nested_lib.rs +++ b/src/test/auxiliary/cci_nested_lib.rs @@ -10,7 +10,6 @@ use std::cell::RefCell; -use std::gc::{Gc, GC}; pub struct Entry { key: A, @@ -19,7 +18,7 @@ pub struct Entry { pub struct alist { eq_fn: extern "Rust" fn(A,A) -> bool, - data: Gc>>>, + data: Box>>>, } pub fn alist_add(lst: &alist, k: A, v: B) { @@ -47,7 +46,7 @@ pub fn new_int_alist() -> alist { fn eq_int(a: int, b: int) -> bool { a == b } return alist { eq_fn: eq_int, - data: box(GC) RefCell::new(Vec::new()), + data: box RefCell::new(Vec::new()), }; } @@ -57,6 +56,6 @@ pub fn new_int_alist_2() -> alist { fn eq_int(a: int, b: int) -> bool { a == b } return alist { eq_fn: eq_int, - data: box(GC) RefCell::new(Vec::new()), + data: box RefCell::new(Vec::new()), }; } diff --git a/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs index e9a249001764a..5e2a04001b5d6 100644 --- a/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs +++ b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs @@ -27,9 +27,8 @@ pub mod name_pool { pub mod rust { pub use name_pool::add; - use std::gc::Gc; - pub type rt = Gc<()>; + pub type rt = Box<()>; pub trait cx { fn cx(&self); diff --git a/src/test/auxiliary/issue-2631-a.rs b/src/test/auxiliary/issue-2631-a.rs index 61c7d3f87dfb7..3bedbd9089ce2 100644 --- a/src/test/auxiliary/issue-2631-a.rs +++ b/src/test/auxiliary/issue-2631-a.rs @@ -13,9 +13,9 @@ use std::cell::RefCell; use std::collections::HashMap; -use std::gc::Gc; +use std::rc::Rc; -pub type header_map = HashMap>>>>; +pub type header_map = HashMap>>>>; // the unused ty param is necessary so this gets monomorphized pub fn request(req: &header_map) { diff --git a/src/test/auxiliary/issue-5521.rs b/src/test/auxiliary/issue-5521.rs index 5d56db314b297..d9d393cc7492c 100644 --- a/src/test/auxiliary/issue-5521.rs +++ b/src/test/auxiliary/issue-5521.rs @@ -10,7 +10,6 @@ use std::collections::HashMap; -use std::gc::Gc; -pub type map = Gc>; +pub type map = Box>; diff --git a/src/test/auxiliary/issue13507.rs b/src/test/auxiliary/issue13507.rs index ee7787d6fccf5..961dad000914a 100644 --- a/src/test/auxiliary/issue13507.rs +++ b/src/test/auxiliary/issue13507.rs @@ -56,8 +56,6 @@ pub mod testtypes { VarB(uint, uint) } - // Skipping ty_box - // Tests ty_uniq (of u8) pub type FooUniq = Box; diff --git a/src/test/auxiliary/issue_16723_multiple_items_syntax_ext.rs b/src/test/auxiliary/issue_16723_multiple_items_syntax_ext.rs index ee5bc55b3fdd3..bb57b4a98bb70 100644 --- a/src/test/auxiliary/issue_16723_multiple_items_syntax_ext.rs +++ b/src/test/auxiliary/issue_16723_multiple_items_syntax_ext.rs @@ -11,7 +11,7 @@ // ignore-stage1 // force-host -#![feature(plugin_registrar, managed_boxes, quote)] +#![feature(plugin_registrar, quote)] #![crate_type = "dylib"] extern crate syntax; diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index 93b22edbf03e6..6729373296b76 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -10,18 +10,15 @@ #![feature(unsafe_destructor)] -extern crate collections; extern crate time; use time::precise_time_s; use std::os; use std::task; -use std::vec; -use std::gc::{Gc, GC}; #[deriving(Clone)] enum List { - Nil, Cons(T, Gc>) + Nil, Cons(T, Box>) } enum UniqueList { @@ -53,15 +50,13 @@ type nillist = List<()>; // Filled with things that have to be unwound struct State { - managed: Gc, unique: Box, - tuple: (Gc, Box), - vec: Vec>, + vec: Vec>, res: r } struct r { - _l: Gc, + _l: Box, } #[unsafe_destructor] @@ -69,7 +64,7 @@ impl Drop for r { fn drop(&mut self) {} } -fn r(l: Gc) -> r { +fn r(l: Box) -> r { r { _l: l } @@ -85,22 +80,17 @@ fn recurse_or_fail(depth: int, st: Option) { let st = match st { None => { State { - managed: box(GC) Nil, unique: box Nil, - tuple: (box(GC) Nil, box Nil), - vec: vec!(box(GC) Nil), - res: r(box(GC) Nil) + vec: vec!(box Nil), + res: r(box Nil) } } Some(st) => { State { - managed: box(GC) Cons((), st.managed), - unique: box Cons((), box(GC) *st.unique), - tuple: (box(GC) Cons((), st.tuple.ref0().clone()), - box Cons((), box(GC) *st.tuple.ref1().clone())), + unique: box Cons((), box *st.unique), vec: st.vec.clone().append( - &[box(GC) Cons((), *st.vec.last().unwrap())]), - res: r(box(GC) Cons((), st.res._l)) + &[box Cons((), *st.vec.last().unwrap())]), + res: r(box Cons((), st.res._l)) } } }; diff --git a/src/test/compile-fail/autoderef-full-lval.rs b/src/test/compile-fail/autoderef-full-lval.rs index 276c830cf5d48..7aa3b30ce4919 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, - y: Gc, + x: Box, + y: Box, } struct fish { - a: Gc, + a: Box, } 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` - 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` + 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` - println!("{:?}", answer); + //~^ ERROR binary operation `+` cannot be applied to type `Box` + println!("{}", answer); assert_eq!(answer, 42); } diff --git a/src/test/compile-fail/borrowck-borrow-immut-deref-of-gc-as-mut.rs b/src/test/compile-fail/borrowck-borrow-immut-deref-of-gc-as-mut.rs deleted file mode 100644 index 91eb20d19ed93..0000000000000 --- a/src/test/compile-fail/borrowck-borrow-immut-deref-of-gc-as-mut.rs +++ /dev/null @@ -1,25 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// 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) { - } -} - -pub fn main() { - let a = box(GC) A; - a.foo(); - //~^ ERROR cannot borrow immutable dereference of `Gc` `*a` as mutable -} diff --git a/src/test/compile-fail/borrowck-managed-pointer-deref-scope.rs b/src/test/compile-fail/borrowck-managed-pointer-deref-scope.rs deleted file mode 100644 index a8a79056fb13c..0000000000000 --- a/src/test/compile-fail/borrowck-managed-pointer-deref-scope.rs +++ /dev/null @@ -1,34 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// 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 { - match x { - &ref y => { - &**y // Do not expect an error here - } - } -} - -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/borrowck-preserve-box-in-field.rs b/src/test/compile-fail/borrowck-preserve-box-in-field.rs deleted file mode 100644 index ad1ac3cc15ee3..0000000000000 --- 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 or the MIT license -// , 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 } - -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 ec52f0588363c..0000000000000 --- 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 or the MIT license -// , 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 } - -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 5aff482a32320..0000000000000 --- 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 or the MIT license -// , 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 6c3c340b97a0a..0000000000000 --- 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 or the MIT license -// , 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 2ad042c69c3bb..0000000000000 --- 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 or the MIT license -// , 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 } - -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/box-static-bound.rs b/src/test/compile-fail/box-static-bound.rs deleted file mode 100644 index 29ee79b0079c3..0000000000000 --- a/src/test/compile-fail/box-static-bound.rs +++ /dev/null @@ -1,22 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -fn f(x: T) -> Gc { - box(GC) x //~ ERROR the parameter type `T` may not live long enough -} - -fn g(x: T) -> Gc { - box(GC) x // ok -} - -fn main() {} diff --git a/src/test/compile-fail/check-static-values-constraints.rs b/src/test/compile-fail/check-static-values-constraints.rs index 3e67419843cba..e29be22ca9acc 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, &'static Box) = static mut STATIC17: SafeEnum = Variant1; //~^ ERROR mutable static items are not allowed to have destructors -static STATIC18: Gc = box(GC) SafeStruct{field1: Variant1, field2: Variant2(0)}; -//~^ ERROR static items are not allowed to have custom pointers - static STATIC19: Box = 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 06079a5487ff4..d77c552be034c 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/issue-14915.rs b/src/test/compile-fail/issue-14915.rs index 4512eb3f70ace..8cbbfb7b83a55 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 = box 0; - let y: Gc = box (GC) 0; println!("{}", x + 1); //~ ERROR binary operation `+` cannot be applied to type `Box` - println!("{}", y + 1); //~ ERROR binary operation `+` cannot be applied to type `Gc` } diff --git a/src/test/compile-fail/issue-2063-resource.rs b/src/test/compile-fail/issue-2063-resource.rs index 577ac480f60dc..30cf7ee7d8888 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); //~ ERROR this type cannot be instantiated +struct X(Box); //~ 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 d3bd17a77420f..cccf730095bdf 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> } +struct P { child: Option> } trait PTrait { - fn getChildOption(&self) -> Option>; + fn getChildOption(&self) -> Option>; } impl PTrait for P { - fn getChildOption(&self) -> Option> { - static childVal: Gc

= self.child.get(); + fn getChildOption(&self) -> Option> { + static childVal: Box

= 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 9003578a0bb3e..73d42aa0de1ad 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 a9e9416beb390..c6869c44057f9 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 { self } - //~^ ERROR: error: mismatched types: expected `Gc`, found `&'a mut BarStruct + fn foo(&'a mut self) -> Box { self } + //~^ ERROR: error: mismatched types: expected `Box`, 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 1c0295974c923..e29b8bc04d80e 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> = box(GC) RefCell::new(0); +static boxed: Box> = 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 3524d11d1842a..499144698fb81 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() { } trait Dummy { } @@ -76,8 +75,7 @@ fn test<'a,T,U:Copy>(_: &'a int) { // structs containing non-POD are not ok assert_copy::(); //~ ERROR `core::kinds::Copy` is not implemented - // managed or ref counted types are not ok - assert_copy::>(); //~ ERROR `core::kinds::Copy` is not implemented + // ref counted types are not ok assert_copy::>(); //~ 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 e50bb8fbede65..26b0c5503e32f 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, + f: Rc, } 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 f292d1599823f..6ca3f0174bb74 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) {} +fn foo(_x: Rc) {} 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 375969ffb5267..0000000000000 --- 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 or the MIT license -// , 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, //~ ERROR type uses managed -} - -struct Bar { x: Box } //~ 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) {} //~ ERROR type uses owned - proc() {}; //~ ERROR type uses owned -} diff --git a/src/test/compile-fail/lint-managed-heap-memory.rs b/src/test/compile-fail/lint-managed-heap-memory.rs deleted file mode 100644 index 0a28242fb1b3a..0000000000000 --- a/src/test/compile-fail/lint-managed-heap-memory.rs +++ /dev/null @@ -1,23 +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 or the MIT license -// , at your -// 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 //~ ERROR type uses managed -} - -fn main() { - let _x : Foo = Foo {x : box(GC) 10}; - //~^ ERROR type uses managed -} diff --git a/src/test/compile-fail/new-box-syntax-bad.rs b/src/test/compile-fail/new-box-syntax-bad.rs deleted file mode 100644 index 602ffe2680b04..0000000000000 --- a/src/test/compile-fail/new-box-syntax-bad.rs +++ /dev/null @@ -1,24 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// 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/ */ - -// Tests that the new `box` syntax works with unique pointers and GC pointers. - -use std::gc::{Gc, GC}; -use std::boxed::{Box, HEAP}; - -pub fn main() { - let x: Gc = box(HEAP) 2; //~ ERROR mismatched types - let y: Gc = box(HEAP)(1 + 2); //~ ERROR mismatched types - let z: Box = box(GC)(4 + 5); //~ ERROR mismatched types -} - diff --git a/src/test/compile-fail/no-send-res-ports.rs b/src/test/compile-fail/no-send-res-ports.rs index ddbfbc41ecaf3..83dbd9ac1bf72 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(Gc); +#[deriving(Show)] +struct Port(Rc); 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 69c012e0d8e0e..2765182225f96 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 a00528616c3e5..44318b36f4b8a 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/pinned-deep-copy.rs b/src/test/compile-fail/pinned-deep-copy.rs deleted file mode 100644 index 0e8bb40e0ffee..0000000000000 --- 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 or the MIT license -// , 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>, -} - -#[unsafe_destructor] -impl Drop for r { - fn drop(&mut self) { - unsafe { - self.i.set(self.i.get() + 1); - } - } -} - -fn r(i: Gc>) -> 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 2c068052c541c..0000000000000 --- 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 or the MIT license -// , 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 fc513b91f899a..b710578969b0d 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) -> &'a int { +fn foo<'a>(p: Box) -> &'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 623b8e6319f88..cf1fa2cfc4c2c 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(x: &T) -> &T {x} -fn foo(cond: || -> bool, make_box: || -> Gc) { +fn foo(cond: || -> bool, make_box: || -> Box) { 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 e862b36dcd168..f93907f5e5cb0 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>; +type b<'a> = Box>; struct c<'a> { - f: Gc> + f: Box> } trait set_f<'a> { - fn set_f_ok(&mut self, b: Gc>); - fn set_f_bad(&mut self, b: Gc); + fn set_f_ok(&mut self, b: Box>); + fn set_f_bad(&mut self, b: Box); } impl<'a> set_f<'a> for c<'a> { - fn set_f_ok(&mut self, b: Gc>) { + fn set_f_ok(&mut self, b: Box>) { self.f = b; } - fn set_f_bad(&mut self, b: Gc) { - self.f = b; //~ ERROR mismatched types: expected `Gc>`, found `Gc>` + fn set_f_bad(&mut self, b: Box) { + self.f = b; //~ ERROR mismatched types: expected `Box>`, found `Box>` } } diff --git a/src/test/compile-fail/static-region-bound.rs b/src/test/compile-fail/static-region-bound.rs index 2cb1f462e1dae..1e5a5ecc08e08 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) {} 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 557341fd4f09e..2c3d48e9bf735 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 0817d7c610ad1..53ebe1f9b5b64 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; +type bar = Box; 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 bd844cc58603e..73224c7b45cec 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; + fn jumbo(&self, x: &uint) -> uint; } impl Mumbo for uint { // Cannot have a larger effect than the trait: - unsafe fn jumbo(&self, x: Gc) { *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 7d6cdaef85b2f..4c2805bf4bd0c 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(_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 54b1fdea7190d..79f29c6b359d6 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>, +#[deriving(Show)] +struct r<'a> { + i: &'a Cell, } #[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(_i: Vec , _j: Vec ) { } 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 c3fea8e86d4f4..102cb636550db 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, + j: Rc, } -fn foo(i:int, j: Gc) -> foo { +fn foo(i:int, j: Rc) -> foo { foo { i: i, j: j @@ -29,5 +29,5 @@ fn foo(i:int, j: Gc) -> 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 } diff --git a/src/test/debuginfo/borrowed-managed-basic.rs b/src/test/debuginfo/borrowed-managed-basic.rs deleted file mode 100644 index a2b8c54c3801d..0000000000000 --- a/src/test/debuginfo/borrowed-managed-basic.rs +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-android: FIXME(#10381) - - -// Gdb doesn't know about UTF-32 character encoding and will print a rust char as only -// its numerical value. - -// compile-flags:-g - -// === GDB TESTS =================================================================================== - -// gdb-command:rbreak zzz -// gdb-command:run -// gdb-command:finish -// gdb-command:print *bool_ref -// gdb-check:$1 = true - -// gdb-command:print *int_ref -// gdb-check:$2 = -1 - -// gdb-command:print *char_ref -// gdb-check:$3 = 97 - -// gdb-command:print/d *i8_ref -// gdb-check:$4 = 68 - -// gdb-command:print *i16_ref -// gdb-check:$5 = -16 - -// gdb-command:print *i32_ref -// gdb-check:$6 = -32 - -// gdb-command:print *i64_ref -// gdb-check:$7 = -64 - -// gdb-command:print *uint_ref -// gdb-check:$8 = 1 - -// gdb-command:print/d *u8_ref -// gdb-check:$9 = 100 - -// gdb-command:print *u16_ref -// gdb-check:$10 = 16 - -// gdb-command:print *u32_ref -// gdb-check:$11 = 32 - -// gdb-command:print *u64_ref -// gdb-check:$12 = 64 - -// gdb-command:print *f32_ref -// gdb-check:$13 = 2.5 - -// gdb-command:print *f64_ref -// gdb-check:$14 = 3.5 - - -// === LLDB TESTS ================================================================================== - -// lldb-command:type format add -f decimal char -// lldb-command:type format add -f decimal 'unsigned char' -// lldb-command:run - -// lldb-command:print *bool_ref -// lldb-check:[...]$0 = true - -// lldb-command:print *int_ref -// lldb-check:[...]$1 = -1 - -// LLDB can't handle 32bit chars yet -// d ebugger:print *char_ref -// c heck:[...]$x = 97 - -// lldb-command:print *i8_ref -// lldb-check:[...]$2 = 68 - -// lldb-command:print *i16_ref -// lldb-check:[...]$3 = -16 - -// lldb-command:print *i32_ref -// lldb-check:[...]$4 = -32 - -// lldb-command:print *i64_ref -// lldb-check:[...]$5 = -64 - -// lldb-command:print *uint_ref -// lldb-check:[...]$6 = 1 - -// lldb-command:print *u8_ref -// lldb-check:[...]$7 = 100 - -// lldb-command:print *u16_ref -// lldb-check:[...]$8 = 16 - -// lldb-command:print *u32_ref -// lldb-check:[...]$9 = 32 - -// lldb-command:print *u64_ref -// lldb-check:[...]$10 = 64 - -// lldb-command:print *f32_ref -// lldb-check:[...]$11 = 2.5 - -// lldb-command:print *f64_ref -// lldb-check:[...]$12 = 3.5 - -#![allow(unused_variable)] - -use std::gc::{Gc, GC}; - -fn main() { - let bool_box: Gc = box(GC) true; - let bool_ref: &bool = &*bool_box; - - let int_box: Gc = box(GC) -1; - let int_ref: &int = &*int_box; - - let char_box: Gc = box(GC) 'a'; - let char_ref: &char = &*char_box; - - let i8_box: Gc = box(GC) 68; - let i8_ref: &i8 = &*i8_box; - - let i16_box: Gc = box(GC) -16; - let i16_ref: &i16 = &*i16_box; - - let i32_box: Gc = box(GC) -32; - let i32_ref: &i32 = &*i32_box; - - let i64_box: Gc = box(GC) -64; - let i64_ref: &i64 = &*i64_box; - - let uint_box: Gc = box(GC) 1; - let uint_ref: &uint = &*uint_box; - - let u8_box: Gc = box(GC) 100; - let u8_ref: &u8 = &*u8_box; - - let u16_box: Gc = box(GC) 16; - let u16_ref: &u16 = &*u16_box; - - let u32_box: Gc = box(GC) 32; - let u32_ref: &u32 = &*u32_box; - - let u64_box: Gc = box(GC) 64; - let u64_ref: &u64 = &*u64_box; - - let f32_box: Gc = box(GC) 2.5; - let f32_ref: &f32 = &*f32_box; - - let f64_box: Gc = box(GC) 3.5; - let f64_ref: &f64 = &*f64_box; - - zzz(); // #break -} - -fn zzz() {()} diff --git a/src/test/debuginfo/borrowed-struct.rs b/src/test/debuginfo/borrowed-struct.rs index 02131734fb1af..8b9c790bbbf58 100644 --- a/src/test/debuginfo/borrowed-struct.rs +++ b/src/test/debuginfo/borrowed-struct.rs @@ -29,15 +29,6 @@ // gdb-command:print *ref_to_unnamed // gdb-check:$4 = {x = 11, y = 24.5} -// gdb-command:print *managed_val_ref -// gdb-check:$5 = {x = 12, y = 25.5} - -// gdb-command:print *managed_val_interior_ref_1 -// gdb-check:$6 = 12 - -// gdb-command:print *managed_val_interior_ref_2 -// gdb-check:$7 = 25.5 - // gdb-command:print *unique_val_ref // gdb-check:$8 = {x = 13, y = 26.5} @@ -64,15 +55,6 @@ // lldb-command:print *ref_to_unnamed // lldb-check:[...]$3 = SomeStruct { x: 11, y: 24.5 } -// lldb-command:print *managed_val_ref -// lldb-check:[...]$4 = SomeStruct { x: 12, y: 25.5 } - -// lldb-command:print *managed_val_interior_ref_1 -// lldb-check:[...]$5 = 12 - -// lldb-command:print *managed_val_interior_ref_2 -// lldb-check:[...]$6 = 25.5 - // lldb-command:print *unique_val_ref // lldb-check:[...]$7 = SomeStruct { x: 13, y: 26.5 } @@ -84,8 +66,6 @@ #![allow(unused_variable)] -use std::gc::GC; - struct SomeStruct { x: int, y: f64 @@ -98,11 +78,6 @@ 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 = 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; - let unique_val = box SomeStruct { x: 13, y: 26.5 }; let unique_val_ref: &SomeStruct = &*unique_val; let unique_val_interior_ref_1: &int = &unique_val.x; diff --git a/src/test/debuginfo/borrowed-tuple.rs b/src/test/debuginfo/borrowed-tuple.rs index 5553063657138..2c78d14a86c75 100644 --- a/src/test/debuginfo/borrowed-tuple.rs +++ b/src/test/debuginfo/borrowed-tuple.rs @@ -25,9 +25,6 @@ // gdb-command:print *ref_to_unnamed // gdb-check:$2 = {-15, -20} -// gdb-command:print *managed_val_ref -// gdb-check:$3 = {-16, -21} - // gdb-command:print *unique_val_ref // gdb-check:$4 = {-17, -22} @@ -42,25 +39,17 @@ // lldb-command:print *ref_to_unnamed // lldb-check:[...]$1 = (-15, -20) -// lldb-command:print *managed_val_ref -// lldb-check:[...]$2 = (-16, -21) - // lldb-command:print *unique_val_ref // lldb-check:[...]$3 = (-17, -22) #![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: Gc<(i16, f32)> = box(GC) (-16, -21f32); - let managed_val_ref: &(i16, f32) = &*managed_val; - let unique_val: Box<(i16, f32)> = box() (-17, -22f32); let unique_val_ref: &(i16, f32) = &*unique_val; diff --git a/src/test/debuginfo/box.rs b/src/test/debuginfo/box.rs index 1a07f614c14c7..c459b9be3d09c 100644 --- a/src/test/debuginfo/box.rs +++ b/src/test/debuginfo/box.rs @@ -22,10 +22,6 @@ // gdb-check:$1 = 1 // gdb-command:print *b // gdb-check:$2 = {2, 3.5} -// gdb-command:print c->val -// gdb-check:$3 = 4 -// gdb-command:print d->val -// gdb-check:$4 = false // === LLDB TESTS ================================================================================== @@ -35,20 +31,12 @@ // lldb-check:[...]$0 = 1 // lldb-command:print *b // lldb-check:[...]$1 = (2, 3.5) -// lldb-command:print c->val -// lldb-check:[...]$2 = 4 -// lldb-command:print d->val -// lldb-check:[...]$3 = false #![allow(unused_variable)] -use std::gc::GC; - fn main() { let a = box 1i; let b = box() (2i, 3.5f64); - let c = box(GC) 4i; - let d = box(GC) false; zzz(); // #break } diff --git a/src/test/debuginfo/boxed-struct.rs b/src/test/debuginfo/boxed-struct.rs index d3a556e40099a..a22b9fdea5c8f 100644 --- a/src/test/debuginfo/boxed-struct.rs +++ b/src/test/debuginfo/boxed-struct.rs @@ -21,15 +21,9 @@ // gdb-command:print *unique // gdb-check:$1 = {x = 99, y = 999, z = 9999, w = 99999} -// gdb-command:print managed->val -// gdb-check:$2 = {x = 88, y = 888, z = 8888, w = 88888} - // gdb-command:print *unique_dtor // gdb-check:$3 = {x = 77, y = 777, z = 7777, w = 77777} -// gdb-command:print managed_dtor->val -// gdb-check:$4 = {x = 33, y = 333, z = 3333, w = 33333} - // === LLDB TESTS ================================================================================== @@ -38,19 +32,11 @@ // lldb-command:print *unique // lldb-check:[...]$0 = StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 } -// lldb-command:print managed->val -// lldb-check:[...]$1 = StructWithSomePadding { x: 88, y: 888, z: 8888, w: 88888 } - // lldb-command:print *unique_dtor // lldb-check:[...]$2 = StructWithDestructor { x: 77, y: 777, z: 7777, w: 77777 } -// lldb-command:print managed_dtor->val -// lldb-check:[...]$3 = StructWithDestructor { x: 33, y: 333, z: 3333, w: 33333 } - #![allow(unused_variable)] -use std::gc::GC; - struct StructWithSomePadding { x: i16, y: i32, @@ -72,11 +58,8 @@ impl Drop for StructWithDestructor { fn main() { let unique = box StructWithSomePadding { x: 99, y: 999, z: 9999, w: 99999 }; - 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 = box(GC) StructWithDestructor { x: 33, y: 333, z: 3333, w: 33333 }; - zzz(); // #break } diff --git a/src/test/debuginfo/by-value-self-argument-in-trait-impl.rs b/src/test/debuginfo/by-value-self-argument-in-trait-impl.rs index af1b38adf80d2..11df00ee4fe26 100644 --- a/src/test/debuginfo/by-value-self-argument-in-trait-impl.rs +++ b/src/test/debuginfo/by-value-self-argument-in-trait-impl.rs @@ -33,11 +33,6 @@ // gdb-check:$3 = {4444.5, 5555, 6666, 7777.5} // gdb-command:continue -// gdb-command:finish -// gdb-command:print self->val -// gdb-check:$4 = 8888 -// gdb-command:continue - // === LLDB TESTS ================================================================================== @@ -55,12 +50,6 @@ // lldb-check:[...]$2 = (4444.5, 5555, 6666, 7777.5) // lldb-command:continue -// lldb-command:print self->val -// lldb-check:[...]$3 = 8888 -// lldb-command:continue - -use std::gc::{Gc, GC}; - trait Trait { fn method(self) -> Self; } @@ -91,18 +80,10 @@ impl Trait for (f64, int, int, f64) { } } -impl Trait for Gc { - fn method(self) -> Gc { - zzz(); // #break - self - } -} - fn main() { let _ = (1111 as int).method(); let _ = Struct { x: 2222, y: 3333 }.method(); let _ = (4444.5, 5555, 6666, 7777.5).method(); - let _ = (box(GC) 8888).method(); } fn zzz() { () } diff --git a/src/test/debuginfo/managed-enum.rs b/src/test/debuginfo/managed-enum.rs deleted file mode 100644 index e5da4d2cdb16f..0000000000000 --- a/src/test/debuginfo/managed-enum.rs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-android: FIXME(#10381) - -// compile-flags:-g - -// === GDB TESTS =================================================================================== - -// gdb-command:rbreak zzz -// gdb-command:run -// gdb-command:finish - -// gdb-command:print the_a->val -// gdb-check:$1 = {{TheA, x = 0, y = 8970181431921507452}, {TheA, 0, 2088533116, 2088533116}} - -// gdb-command:print the_b->val -// gdb-check:$2 = {{TheB, x = 0, y = 1229782938247303441}, {TheB, 0, 286331153, 286331153}} - -// gdb-command:print univariant->val -// gdb-check:$3 = {{-9747455}} - - -// === LLDB TESTS ================================================================================== - -// lldb-command:run - -// lldb-command:print the_a->val -// lldb-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 } - -// lldb-command:print the_b->val -// lldb-check:[...]$1 = TheB(0, 286331153, 286331153) - -// lldb-command:print univariant->val -// lldb-check:[...]$2 = TheOnlyCase(-9747455) - -#![allow(unused_variable)] -#![feature(struct_variant)] - -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. -enum ABC { - TheA { x: i64, y: i64 }, - TheB (i64, i32, i32), -} - -// This is a special case since it does not have the implicit discriminant field. -enum Univariant { - TheOnlyCase(i64) -} - -fn main() { - - // In order to avoid endianess trouble all of the following test values consist of a single - // repeated byte. This way each interpretation of the union should look the same, no matter if - // this is a big or little endian machine. - - // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452 - // 0b01111100011111000111110001111100 = 2088533116 - // 0b0111110001111100 = 31868 - // 0b01111100 = 124 - let the_a = box(GC) TheA { x: 0, y: 8970181431921507452 }; - - // 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441 - // 0b00010001000100010001000100010001 = 286331153 - // 0b0001000100010001 = 4369 - // 0b00010001 = 17 - let the_b = box(GC) TheB (0, 286331153, 286331153); - - let univariant = box(GC) TheOnlyCase(-9747455); - - zzz(); // #break -} - -fn zzz() {()} diff --git a/src/test/debuginfo/managed-pointer-within-unique-vec.rs b/src/test/debuginfo/managed-pointer-within-unique-vec.rs deleted file mode 100644 index 69f3938ecee3c..0000000000000 --- a/src/test/debuginfo/managed-pointer-within-unique-vec.rs +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-android: FIXME(#10381) - - -// compile-flags:-g - -// === GDB TESTS =================================================================================== - -// gdb-command:rbreak zzz -// gdb-command:run -// gdb-command:finish - -// gdb-command:print unique.ptr[0]->val -// gdb-check:$1 = 10 - -// gdb-command:print unique.ptr[1]->val -// gdb-check:$2 = 11 - -// gdb-command:print unique.ptr[2]->val -// gdb-check:$3 = 12 - -// gdb-command:print unique.ptr[3]->val -// gdb-check:$4 = 13 - - -// === LLDB TESTS ================================================================================== - -// lldb-command:run - -// lldb-command:print unique.ptr[0]->val -// lldb-check:[...]$0 = 10 - -// lldb-command:print unique.ptr[1]->val -// lldb-check:[...]$1 = 11 - -// lldb-command:print unique.ptr[2]->val -// lldb-check:[...]$2 = 12 - -// lldb-command:print unique.ptr[3]->val -// lldb-check:[...]$3 = 13 - - -#![allow(unused_variable)] - -use std::gc::{Gc, GC}; - -fn main() { - - let unique: Vec> = vec!(box(GC) 10, box(GC) 11, box(GC) 12, box(GC) 13); - - zzz(); // #break -} - -fn zzz() {()} diff --git a/src/test/debuginfo/managed-pointer-within-unique.rs b/src/test/debuginfo/managed-pointer-within-unique.rs deleted file mode 100644 index 2690efb8f8588..0000000000000 --- a/src/test/debuginfo/managed-pointer-within-unique.rs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-android: FIXME(#10381) - - -// compile-flags:-g - -// === GDB TESTS =================================================================================== - -// gdb-command:set print pretty off -// gdb-command:rbreak zzz -// gdb-command:run -// gdb-command:finish - -// gdb-command:print *ordinary_unique -// gdb-check:$1 = {-1, -2} - -// gdb-command:print managed_within_unique->x -// gdb-check:$2 = -3 - -// gdb-command:print managed_within_unique->y->val -// gdb-check:$3 = -4 - -// === LLDB TESTS ================================================================================== - -// lldb-command:run - -// lldb-command:print *ordinary_unique -// lldb-check:[...]$0 = (-1, -2) - -// lldb-command:print managed_within_unique->x -// lldb-check:[...]$1 = -3 - -// lldb-command:print managed_within_unique->y->val -// lldb-check:[...]$2 = -4 - -#![allow(unused_variable)] - -use std::gc::{GC, Gc}; - -struct ContainsManaged { - x: int, - y: Gc, -} - -fn main() { - let ordinary_unique = box() (-1i, -2i); - - let managed_within_unique = box ContainsManaged { x: -3, y: box(GC) -4i }; - - zzz(); // #break -} - -fn zzz() {()} diff --git a/src/test/debuginfo/recursive-struct.rs b/src/test/debuginfo/recursive-struct.rs index 76722b743d731..412bdfaaf15ac 100644 --- a/src/test/debuginfo/recursive-struct.rs +++ b/src/test/debuginfo/recursive-struct.rs @@ -29,11 +29,6 @@ // gdb-command:print unique_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value // gdb-check:$4 = 3 -// gdb-command:print box_unique->val.value -// gdb-check:$5 = 4 -// gdb-command:print box_unique->val.next.RUST$ENCODED$ENUM$0$Empty.val->value -// gdb-check:$6 = 5 - // gdb-command:print vec_unique[0].value // gdb-check:$7 = 6.5 // gdb-command:print vec_unique[0].next.RUST$ENCODED$ENUM$0$Empty.val->value @@ -44,32 +39,6 @@ // gdb-command:print borrowed_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value // gdb-check:$10 = 9.5 -// MANAGED -// gdb-command:print stack_managed.value -// gdb-check:$11 = 10 -// gdb-command:print stack_managed.next.RUST$ENCODED$ENUM$0$Empty.val->val.value -// gdb-check:$12 = 11 - -// gdb-command:print unique_managed->value -// gdb-check:$13 = 12 -// gdb-command:print unique_managed->next.RUST$ENCODED$ENUM$0$Empty.val->val.value -// gdb-check:$14 = 13 - -// gdb-command:print box_managed.val->value -// gdb-check:$15 = 14 -// gdb-command:print box_managed->val->next.RUST$ENCODED$ENUM$0$Empty.val->val.value -// gdb-check:$16 = 15 - -// gdb-command:print vec_managed[0].value -// gdb-check:$17 = 16.5 -// gdb-command:print vec_managed[0].next.RUST$ENCODED$ENUM$0$Empty.val->val.value -// gdb-check:$18 = 17.5 - -// gdb-command:print borrowed_managed->value -// gdb-check:$19 = 18.5 -// gdb-command:print borrowed_managed->next.RUST$ENCODED$ENUM$0$Empty.val->val.value -// gdb-check:$20 = 19.5 - // LONG CYCLE // gdb-command:print long_cycle1.value // gdb-check:$21 = 20 @@ -106,8 +75,6 @@ #![allow(unused_variable)] #![feature(struct_variant)] -use std::gc::{Gc, GC}; - enum Opt { Empty, Val { val: T } @@ -118,11 +85,6 @@ struct UniqueNode { value: T } -struct ManagedNode { - next: Opt>>, - value: T -} - struct LongCycle1 { next: Box>, value: T, @@ -184,16 +146,6 @@ fn main() { value: 2, }; - let box_unique: Gc> = box(GC) UniqueNode { - next: Val { - val: box UniqueNode { - next: Empty, - value: 5, - } - }, - value: 4, - }; - let vec_unique: [UniqueNode, ..1] = [UniqueNode { next: Val { val: box UniqueNode { @@ -214,56 +166,6 @@ fn main() { value: 8.5, }; - let stack_managed: ManagedNode = ManagedNode { - next: Val { - val: box(GC) ManagedNode { - next: Empty, - value: 11, - } - }, - value: 10, - }; - - let unique_managed: Box> = box ManagedNode { - next: Val { - val: box(GC) ManagedNode { - next: Empty, - value: 13, - } - }, - value: 12, - }; - - let box_managed: Gc> = box(GC) ManagedNode { - next: Val { - val: box(GC) ManagedNode { - next: Empty, - value: 15, - } - }, - value: 14, - }; - - let vec_managed: [ManagedNode, ..1] = [ManagedNode { - next: Val { - val: box(GC) ManagedNode { - next: Empty, - value: 17.5, - } - }, - value: 16.5, - }]; - - let borrowed_managed: &ManagedNode = &ManagedNode { - next: Val { - val: box(GC) ManagedNode { - next: Empty, - value: 19.5, - } - }, - value: 18.5, - }; - // LONG CYCLE let long_cycle1: LongCycle1 = LongCycle1 { next: box LongCycle2 { diff --git a/src/test/debuginfo/var-captured-in-nested-closure.rs b/src/test/debuginfo/var-captured-in-nested-closure.rs index a08cc6bdb6e2c..89415df3588fa 100644 --- a/src/test/debuginfo/var-captured-in-nested-closure.rs +++ b/src/test/debuginfo/var-captured-in-nested-closure.rs @@ -28,8 +28,6 @@ // gdb-check:$4 = {a = -3, b = 4.5, c = 5} // gdb-command:print *owned // gdb-check:$5 = 6 -// gdb-command:print managed->val -// gdb-check:$6 = 7 // gdb-command:print closure_local // gdb-check:$7 = 8 // gdb-command:continue @@ -45,8 +43,6 @@ // gdb-check:$11 = {a = -3, b = 4.5, c = 5} // gdb-command:print *owned // gdb-check:$12 = 6 -// gdb-command:print managed->val -// gdb-check:$13 = 7 // gdb-command:print closure_local // gdb-check:$14 = 8 // gdb-command:continue @@ -66,8 +62,6 @@ // lldb-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 } // lldb-command:print *owned // lldb-check:[...]$4 = 6 -// lldb-command:print managed->val -// lldb-check:[...]$5 = 7 // lldb-command:print closure_local // lldb-check:[...]$6 = 8 // lldb-command:continue @@ -82,16 +76,12 @@ // lldb-check:[...]$10 = Struct { a: -3, b: 4.5, c: 5 } // lldb-command:print *owned // lldb-check:[...]$11 = 6 -// lldb-command:print managed->val -// lldb-check:[...]$12 = 7 // lldb-command:print closure_local // lldb-check:[...]$13 = 8 // lldb-command:continue #![allow(unused_variable)] -use std::gc::GC; - struct Struct { a: int, b: f64, @@ -110,14 +100,13 @@ fn main() { let struct_ref = &a_struct; let owned = box 6; - let managed = box(GC) 7; let closure = || { let closure_local = 8; let nested_closure = || { zzz(); // #break - variable = constant + a_struct.a + struct_ref.a + *owned + *managed + closure_local; + variable = constant + a_struct.a + struct_ref.a + *owned + closure_local; }; zzz(); // #break diff --git a/src/test/debuginfo/var-captured-in-stack-closure.rs b/src/test/debuginfo/var-captured-in-stack-closure.rs index c37f0ddbe99c2..8ea407fc54470 100644 --- a/src/test/debuginfo/var-captured-in-stack-closure.rs +++ b/src/test/debuginfo/var-captured-in-stack-closure.rs @@ -28,8 +28,6 @@ // gdb-check:$4 = {a = -3, b = 4.5, c = 5} // gdb-command:print *owned // gdb-check:$5 = 6 -// gdb-command:print managed->val -// gdb-check:$6 = 7 // === LLDB TESTS ================================================================================== @@ -46,13 +44,9 @@ // lldb-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 } // lldb-command:print *owned // lldb-check:[...]$4 = 6 -// lldb-command:print managed->val -// lldb-check:[...]$5 = 7 #![allow(unused_variable)] -use std::gc::GC; - struct Struct { a: int, b: f64, @@ -71,11 +65,10 @@ fn main() { let struct_ref = &a_struct; let owned = box 6; - let managed = box(GC) 7; let closure = || { zzz(); // #break - variable = constant + a_struct.a + struct_ref.a + *owned + *managed; + variable = constant + a_struct.a + struct_ref.a + *owned; }; closure(); diff --git a/src/test/pretty/block-disambig.rs b/src/test/pretty/block-disambig.rs index 3f6d5b8c18abe..01fc70c1d2cc1 100644 --- a/src/test/pretty/block-disambig.rs +++ b/src/test/pretty/block-disambig.rs @@ -14,34 +14,33 @@ use std::cell::Cell; -use std::gc::GC; -fn test1() { let val = box(GC) 0i; { } *val; } +fn test1() { let val = &0i; { } *val; } -fn test2() -> int { let val = box(GC) 0i; { } *val } +fn test2() -> int { let val = &0i; { } *val } struct S { eax: int } fn test3() { - let regs = box(GC) Cell::new(S {eax: 0}); + let regs = &Cell::new(S {eax: 0}); match true { true => { } _ => { } } regs.set(S {eax: 1}); } -fn test4() -> bool { let regs = box(GC) true; if true { } *regs || false } +fn test4() -> bool { let regs = &true; if true { } *regs || false } fn test5() -> (int, int) { { } (0, 1) } fn test6() -> bool { { } (true || false) && true } fn test7() -> uint { - let regs = box(GC) 0i; + let regs = &0i; match true { true => { } _ => { } } (*regs < 2) as uint } fn test8() -> int { - let val = box(GC) 0i; + let val = &0i; match true { true => { } _ => { } @@ -54,12 +53,12 @@ fn test8() -> int { } fn test9() { - let regs = box(GC) Cell::new(0i); + let regs = &Cell::new(0i); match true { true => { } _ => { } } regs.set(regs.get() + 1); } fn test10() -> int { - let regs = box(GC) vec!(0i); + let regs = vec!(0i); match true { true => { } _ => { } } *(*regs).get(0) } diff --git a/src/test/run-fail/args-fail.rs b/src/test/run-fail/args-fail.rs index d8ba7e1b78868..5e1b7bb69bb2b 100644 --- a/src/test/run-fail/args-fail.rs +++ b/src/test/run-fail/args-fail.rs @@ -11,8 +11,6 @@ // error-pattern:meep -use std::gc::{Gc, GC}; +fn f(_a: int, _b: int, _c: Box) { fail!("moop"); } -fn f(_a: int, _b: int, _c: Gc) { fail!("moop"); } - -fn main() { f(1, fail!("meep"), box(GC) 42); } +fn main() { f(1, fail!("meep"), box 42); } diff --git a/src/test/run-fail/issue-2272.rs b/src/test/run-fail/issue-2272.rs deleted file mode 100644 index 87de4d3d3f296..0000000000000 --- a/src/test/run-fail/issue-2272.rs +++ /dev/null @@ -1,29 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// error-pattern:explicit failure -// Issue #2272 - unwind this without leaking the unique pointer - -use std::gc::{Gc, GC}; - -struct X { y: Y, a: Box } - -struct Y { z: Gc } - -fn main() { - let _x = X { - y: Y { - z: box(GC) 0 - }, - a: box 0 - }; - fail!(); -} diff --git a/src/test/run-fail/unwind-assert.rs b/src/test/run-fail/unwind-assert.rs deleted file mode 100644 index 4947093d10cb8..0000000000000 --- a/src/test/run-fail/unwind-assert.rs +++ /dev/null @@ -1,19 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn main() { - let _a = box(GC) 0i; - assert!(false); -} diff --git a/src/test/run-fail/unwind-box-fn-unique.rs b/src/test/run-fail/unwind-box-fn-unique.rs deleted file mode 100644 index 7ed58be607204..0000000000000 --- a/src/test/run-fail/unwind-box-fn-unique.rs +++ /dev/null @@ -1,29 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// error-pattern:fail - -extern crate debug; - -use std::gc::{GC, Gc}; - -fn failfn() { - fail!(); -} - -fn main() { - let y = box 0i; - let x: Gc = box(GC) (proc() { - println!("{:?}", y.clone()); - }); - failfn(); - println!("{:?}", x); -} diff --git a/src/test/run-fail/unwind-box-res.rs b/src/test/run-fail/unwind-box-res.rs deleted file mode 100644 index ede8331173237..0000000000000 --- a/src/test/run-fail/unwind-box-res.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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -extern crate debug; - -use std::mem; -use std::gc::GC; - -fn failfn() { - fail!(); -} - -struct r { - v: *const int, -} - -impl Drop for r { - fn drop(&mut self) { - unsafe { - let _v2: Box = mem::transmute(self.v); - } - } -} - -fn r(v: *const int) -> r { - r { - v: v - } -} - -fn main() { - unsafe { - let i1 = box 0i; - let i1p = mem::transmute_copy(&i1); - mem::forget(i1); - let x = box(GC) r(i1p); - failfn(); - println!("{:?}", x); - } -} diff --git a/src/test/run-fail/unwind-box-str.rs b/src/test/run-fail/unwind-box-str.rs deleted file mode 100644 index 07a8f5d4cfad6..0000000000000 --- a/src/test/run-fail/unwind-box-str.rs +++ /dev/null @@ -1,26 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -extern crate debug; - -use std::gc::GC; - -fn failfn() { - fail!(); -} - -fn main() { - let x = box(GC) "hi".to_string(); - failfn(); - println!("{:?}", x); -} diff --git a/src/test/run-fail/unwind-box-unique-unique.rs b/src/test/run-fail/unwind-box-unique-unique.rs deleted file mode 100644 index 9aa916a062e77..0000000000000 --- a/src/test/run-fail/unwind-box-unique-unique.rs +++ /dev/null @@ -1,26 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -extern crate debug; - -use std::gc::GC; - -fn failfn() { - fail!(); -} - -fn main() { - let x = box(GC) box box 0i; - failfn(); - println!("{:?}", x); -} diff --git a/src/test/run-fail/unwind-box-unique.rs b/src/test/run-fail/unwind-box-unique.rs deleted file mode 100644 index 7135742db34b8..0000000000000 --- a/src/test/run-fail/unwind-box-unique.rs +++ /dev/null @@ -1,26 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -extern crate debug; - -use std::gc::GC; - -fn failfn() { - fail!(); -} - -fn main() { - let x = box(GC) box 0i; - failfn(); - println!("{:?}", x); -} diff --git a/src/test/run-fail/unwind-box-vec.rs b/src/test/run-fail/unwind-box-vec.rs deleted file mode 100644 index e7d1476c2b6d8..0000000000000 --- a/src/test/run-fail/unwind-box-vec.rs +++ /dev/null @@ -1,26 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -extern crate debug; - -use std::gc::GC; - -fn failfn() { - fail!(); -} - -fn main() { - let x = box(GC) vec!(0i, 1, 2, 3, 4, 5); - failfn(); - println!("{:?}", x); -} diff --git a/src/test/run-fail/unwind-box.rs b/src/test/run-fail/unwind-box.rs deleted file mode 100644 index 7d93ae5615688..0000000000000 --- a/src/test/run-fail/unwind-box.rs +++ /dev/null @@ -1,23 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn failfn() { - fail!(); -} - -fn main() { - box(GC) 0i; - failfn(); -} diff --git a/src/test/run-fail/unwind-fail.rs b/src/test/run-fail/unwind-fail.rs deleted file mode 100644 index 1e19522871af8..0000000000000 --- a/src/test/run-fail/unwind-fail.rs +++ /dev/null @@ -1,19 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn main() { - box(GC) 0i; - fail!(); -} diff --git a/src/test/run-fail/unwind-initializer-indirect.rs b/src/test/run-fail/unwind-initializer-indirect.rs deleted file mode 100644 index 13ad5d2fae3dc..0000000000000 --- a/src/test/run-fail/unwind-initializer-indirect.rs +++ /dev/null @@ -1,20 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::Gc; - -fn f() -> Gc { fail!(); } - -fn main() { - let _a: Gc = f(); -} diff --git a/src/test/run-fail/unwind-initializer.rs b/src/test/run-fail/unwind-initializer.rs deleted file mode 100644 index 7294b19ac9acc..0000000000000 --- a/src/test/run-fail/unwind-initializer.rs +++ /dev/null @@ -1,20 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::Gc; - -fn main() { - let _a: Gc = { - fail!(); - }; -} diff --git a/src/test/run-fail/unwind-iter.rs b/src/test/run-fail/unwind-iter.rs deleted file mode 100644 index 411b9a56a2f27..0000000000000 --- a/src/test/run-fail/unwind-iter.rs +++ /dev/null @@ -1,26 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - -#![allow(unreachable_code)] -#![allow(unused_variable)] - -use std::gc::GC; - -fn x(it: |int|) { - fail!(); - it(0); -} - -fn main() { - let a = box(GC) 0i; - x(|_i| { } ); -} diff --git a/src/test/run-fail/unwind-iter2.rs b/src/test/run-fail/unwind-iter2.rs deleted file mode 100644 index 1a2492e0ac897..0000000000000 --- a/src/test/run-fail/unwind-iter2.rs +++ /dev/null @@ -1,23 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::{GC}; - -fn x(it: |int|) { - let _a = box(GC) 0i; - it(1); -} - -fn main() { - x(|_x| fail!() ); -} diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs deleted file mode 100644 index e96bc14905e9d..0000000000000 --- a/src/test/run-fail/unwind-lambda.rs +++ /dev/null @@ -1,32 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::{Gc, GC}; - -fn main() { - let cheese = "roquefort".to_string(); - let carrots = box(GC) "crunchy".to_string(); - - let result: |Gc, |String||: 'static = (|tasties, macerate| { - macerate((*tasties).clone()); - }); - result(carrots, |food| { - let mush = format!("{}{}", food, cheese); - let cheese = cheese.clone(); - let f: || = || { - let _chew = format!("{}{}", mush, cheese); - fail!("so yummy") - }; - f(); - }); -} diff --git a/src/test/run-fail/unwind-match.rs b/src/test/run-fail/unwind-match.rs deleted file mode 100644 index a6564a68e19a5..0000000000000 --- a/src/test/run-fail/unwind-match.rs +++ /dev/null @@ -1,28 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue #945 -// error-pattern:non-exhaustive match failure - - -use std::gc::GC; - -fn test_box() { - box(GC) 0i; -} -fn test_str() { - let res = match false { true => { "happy".to_string() }, - _ => fail!("non-exhaustive match failure") }; - assert_eq!(res, "happy".to_string()); -} -fn main() { - test_box(); - test_str(); -} diff --git a/src/test/run-fail/unwind-misc-1.rs b/src/test/run-fail/unwind-misc-1.rs deleted file mode 100644 index 23ec6cd0300a6..0000000000000 --- a/src/test/run-fail/unwind-misc-1.rs +++ /dev/null @@ -1,31 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// exec-env:RUST_NEWRT=1 -// error-pattern:fail - - -use std::vec; -use std::collections; -use std::gc::GC; - -fn main() { - let _count = box(GC) 0u; - let mut map = collections::HashMap::new(); - let mut arr = Vec::new(); - for _i in range(0u, 10u) { - arr.push(box(GC) "key stuff".to_string()); - map.insert(arr.clone(), - arr.clone().append([box(GC) "value stuff".to_string()])); - if arr.len() == 5 { - fail!(); - } - } -} diff --git a/src/test/run-fail/unwind-move.rs b/src/test/run-fail/unwind-move.rs deleted file mode 100644 index 692bf713b405e..0000000000000 --- a/src/test/run-fail/unwind-move.rs +++ /dev/null @@ -1,23 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::{Gc, GC}; - -fn f(_a: Gc) { - fail!(); -} - -fn main() { - let a = box(GC) 0; - f(a); -} diff --git a/src/test/run-fail/unwind-nested.rs b/src/test/run-fail/unwind-nested.rs deleted file mode 100644 index 84b727ea20f9f..0000000000000 --- a/src/test/run-fail/unwind-nested.rs +++ /dev/null @@ -1,24 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn main() { - let _a = box(GC) 0i; - { - let _b = box(GC) 0i; - { - fail!(); - } - } -} diff --git a/src/test/run-fail/unwind-partial-box.rs b/src/test/run-fail/unwind-partial-box.rs deleted file mode 100644 index 366531b9127bc..0000000000000 --- a/src/test/run-fail/unwind-partial-box.rs +++ /dev/null @@ -1,31 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn f() -> Vec { 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() { - box(GC) 0i; -} - -fn partial() { - let _x = box(GC) f(); -} - -fn main() { - prime(); - partial(); -} diff --git a/src/test/run-fail/unwind-partial-unique.rs b/src/test/run-fail/unwind-partial-unique.rs deleted file mode 100644 index 725b57af7df5f..0000000000000 --- a/src/test/run-fail/unwind-partial-unique.rs +++ /dev/null @@ -1,31 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn f() -> Vec { 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() { - box(GC) 0i; -} - -fn partial() { - let _x = box f(); -} - -fn main() { - prime(); - partial(); -} diff --git a/src/test/run-fail/unwind-partial-vec.rs b/src/test/run-fail/unwind-partial-vec.rs deleted file mode 100644 index 627fb3d028ed9..0000000000000 --- a/src/test/run-fail/unwind-partial-vec.rs +++ /dev/null @@ -1,31 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn f() -> Vec { 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() { - box(GC) 0i; -} - -fn partial() { - let _x = vec!(vec!(0i), f(), vec!(0i)); -} - -fn main() { - prime(); - partial(); -} diff --git a/src/test/run-fail/unwind-resource-fail.rs b/src/test/run-fail/unwind-resource-fail.rs deleted file mode 100644 index 66fd044d64e7e..0000000000000 --- a/src/test/run-fail/unwind-resource-fail.rs +++ /dev/null @@ -1,29 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// error-pattern:squirrel - -use std::gc::GC; - -struct r { - i: int, -} - -impl Drop for r { - fn drop(&mut self) { fail!("squirrel") } -} - -fn r(i: int) -> r { r { i: i } } - -fn main() { - box(GC) 0i; - let _r = r(0); -} diff --git a/src/test/run-fail/unwind-resource-fail2.rs b/src/test/run-fail/unwind-resource-fail2.rs deleted file mode 100644 index add7fe3f0f359..0000000000000 --- a/src/test/run-fail/unwind-resource-fail2.rs +++ /dev/null @@ -1,30 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test leaks -// error-pattern:wombat - -use std::gc::GC; - -struct r { - i: int, -} - -impl Drop for r { - fn drop(&mut self) { fail!("wombat") } -} - -fn r(i: int) -> r { r { i: i } } - -fn main() { - box(GC) 0; - let r = r(0); - fail!(); -} diff --git a/src/test/run-fail/unwind-resource-fail3.rs b/src/test/run-fail/unwind-resource-fail3.rs deleted file mode 100644 index 9ec7c4a1eb326..0000000000000 --- a/src/test/run-fail/unwind-resource-fail3.rs +++ /dev/null @@ -1,33 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unsafe_destructor)] - -// error-pattern:quux - -use std::gc::{Gc, GC}; - -struct faily_box { - i: Gc -} -// What happens to the box pointer owned by this class? - -fn faily_box(i: Gc) -> faily_box { faily_box { i: i } } - -#[unsafe_destructor] -impl Drop for faily_box { - fn drop(&mut self) { - fail!("quux"); - } -} - -fn main() { - faily_box(box(GC) 10); -} diff --git a/src/test/run-fail/unwind-stacked.rs b/src/test/run-fail/unwind-stacked.rs deleted file mode 100644 index 1e1caac0004e2..0000000000000 --- a/src/test/run-fail/unwind-stacked.rs +++ /dev/null @@ -1,29 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn f() { - let _a = box(GC) 0i; - fail!(); -} - -fn g() { - let _b = box(GC) 0i; - f(); -} - -fn main() { - let _a = box(GC) 0i; - g(); -} diff --git a/src/test/run-fail/unwind-tup.rs b/src/test/run-fail/unwind-tup.rs deleted file mode 100644 index 877e2beb70379..0000000000000 --- a/src/test/run-fail/unwind-tup.rs +++ /dev/null @@ -1,22 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::Gc; - -// error-pattern:fail - -fn fold_local() -> Gc> { - fail!(); -} - -fn main() { - let _lss = (fold_local(), 0i); -} diff --git a/src/test/run-fail/unwind-tup2.rs b/src/test/run-fail/unwind-tup2.rs deleted file mode 100644 index 01536233ffe5f..0000000000000 --- a/src/test/run-fail/unwind-tup2.rs +++ /dev/null @@ -1,26 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -// error-pattern:fail - -fn fold_local() -> Gc> { - box(GC) vec!(0,0,0,0,0,0) -} - -fn fold_remote() -> Gc> { - fail!(); -} - -fn main() { - let _lss = (fold_local(), fold_remote()); -} diff --git a/src/test/run-fail/unwind-uninitialized.rs b/src/test/run-fail/unwind-uninitialized.rs deleted file mode 100644 index 54321e98e7343..0000000000000 --- a/src/test/run-fail/unwind-uninitialized.rs +++ /dev/null @@ -1,23 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:fail - - -use std::gc::GC; - -fn f() { - fail!(); -} - -fn main() { - f(); - let _a = box(GC) 0i; -} diff --git a/src/test/run-pass/assert-eq-macro-success.rs b/src/test/run-pass/assert-eq-macro-success.rs index 7cc4fab999c2d..49a374f343c6f 100644 --- a/src/test/run-pass/assert-eq-macro-success.rs +++ b/src/test/run-pass/assert-eq-macro-success.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - #[deriving(PartialEq, Show)] struct Point { x : int } @@ -19,5 +17,4 @@ 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!(box(GC) Point{x:34},box(GC) Point{x:34}); } diff --git a/src/test/run-pass/autoderef-method-priority.rs b/src/test/run-pass/autoderef-method-priority.rs index 2bad924192f78..cc4dd13cf61c9 100644 --- a/src/test/run-pass/autoderef-method-priority.rs +++ b/src/test/run-pass/autoderef-method-priority.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::{GC, Gc}; - trait double { fn double(self) -> uint; } @@ -19,11 +17,11 @@ impl double for uint { fn double(self) -> uint { self } } -impl double for Gc { +impl double for Box { fn double(self) -> uint { *self * 2u } } pub fn main() { - let x = box(GC) 3u; + let x = box 3u; assert_eq!(x.double(), 6u); } diff --git a/src/test/run-pass/autoref-intermediate-types-issue-3585.rs b/src/test/run-pass/autoref-intermediate-types-issue-3585.rs index ac19c373bb201..7f44bcdb50c1a 100644 --- a/src/test/run-pass/autoref-intermediate-types-issue-3585.rs +++ b/src/test/run-pass/autoref-intermediate-types-issue-3585.rs @@ -9,15 +9,13 @@ // except according to those terms. -use std::gc::{Gc, GC}; - trait Foo { fn foo(&self) -> String; } -impl Foo for Gc { +impl Foo for Box { fn foo(&self) -> String { - format!("box(GC) {}", (**self).foo()) + format!("box {}", (**self).foo()) } } @@ -28,6 +26,6 @@ impl Foo for uint { } pub fn main() { - let x = box(GC) 3u; - assert_eq!(x.foo(), "box(GC) 3".to_string()); + let x = box 3u; + assert_eq!(x.foo(), "box 3".to_string()); } diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs index 2551dafe345ce..3997c5d3d29b8 100644 --- a/src/test/run-pass/binops.rs +++ b/src/test/run-pass/binops.rs @@ -10,9 +10,6 @@ // Binop corner cases - -use std::gc::GC; - fn test_nil() { assert_eq!((), ()); assert!((!(() != ()))); @@ -45,10 +42,6 @@ fn test_bool() { assert_eq!(true ^ true, false); } -fn test_box() { - assert_eq!(box(GC) 10i, box(GC) 10i); -} - fn test_ptr() { unsafe { let p1: *const u8 = ::std::mem::transmute(0u); @@ -98,7 +91,6 @@ fn test_class() { pub fn main() { test_nil(); test_bool(); - test_box(); test_ptr(); test_class(); } diff --git a/src/test/run-pass/borrowck-borrow-from-expr-block.rs b/src/test/run-pass/borrowck-borrow-from-expr-block.rs index 7222d655a408f..8c4995e710097 100644 --- a/src/test/run-pass/borrowck-borrow-from-expr-block.rs +++ b/src/test/run-pass/borrowck-borrow-from-expr-block.rs @@ -9,13 +9,11 @@ // except according to those terms. -use std::gc::{Gc, GC}; - fn borrow(x: &int, f: |x: &int|) { f(x) } -fn test1(x: Gc>) { +fn test1(x: &Box) { borrow(&*(*x).clone(), |p| { let x_a = &**x as *const int; assert!((x_a as uint) != (p as *const int as uint)); @@ -24,5 +22,5 @@ fn test1(x: Gc>) { } pub fn main() { - test1(box(GC) box 22); + test1(&box 22); } diff --git a/src/test/run-pass/borrowck-preserve-box-in-moved-value.rs b/src/test/run-pass/borrowck-preserve-box-in-moved-value.rs deleted file mode 100644 index 525a93a4c83de..0000000000000 --- a/src/test/run-pass/borrowck-preserve-box-in-moved-value.rs +++ /dev/null @@ -1,37 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// exec-env:RUST_POISON_ON_FREE=1 - -// Test that we root `x` even though it is found in immutable memory, -// because it is moved. - - -use std::gc::{Gc, GC}; - -fn free(x: Gc) {} - -struct Foo { - f: Gc -} - -struct Bar { - g: int -} - -fn lend(x: Gc) -> 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(box(GC) Foo {f: box(GC) Bar {g: 22}}), 22); -} diff --git a/src/test/run-pass/borrowck-root-while-cond-2.rs b/src/test/run-pass/borrowck-root-while-cond-2.rs deleted file mode 100644 index 344867568bb7a..0000000000000 --- a/src/test/run-pass/borrowck-root-while-cond-2.rs +++ /dev/null @@ -1,20 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{GC, Gc}; - -struct F { f: Gc } -struct G { g: Vec } - -pub fn main() { - let rec = box(GC) F {f: box(GC) G {g: vec!(1, 2, 3)}}; - while rec.f.g.len() == 23 {} -} diff --git a/src/test/run-pass/borrowck-root-while-cond.rs b/src/test/run-pass/borrowck-root-while-cond.rs deleted file mode 100644 index 163ccf5c02959..0000000000000 --- a/src/test/run-pass/borrowck-root-while-cond.rs +++ /dev/null @@ -1,21 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -fn borrow<'r,T>(x: &'r T) -> &'r T {x} - -struct Rec { f: Gc } - -pub fn main() { - let rec = box(GC) Rec {f: box(GC) 22}; - while *borrow(&*rec.f) == 23 {} -} diff --git a/src/test/run-pass/borrowck-univariant-enum.rs b/src/test/run-pass/borrowck-univariant-enum.rs index 8192566da1965..129fa8bf7d926 100644 --- a/src/test/run-pass/borrowck-univariant-enum.rs +++ b/src/test/run-pass/borrowck-univariant-enum.rs @@ -10,7 +10,6 @@ use std::cell::Cell; -use std::gc::GC; enum newtype { newvar(int) @@ -21,8 +20,8 @@ pub fn main() { // Test that borrowck treats enums with a single variant // specially. - let x = box(GC) Cell::new(5); - let y = box(GC) Cell::new(newvar(3)); + let x = &Cell::new(5); + let y = &Cell::new(newvar(3)); let z = match y.get() { newvar(b) => { x.set(x.get() + 1); diff --git a/src/test/run-pass/box-compare.rs b/src/test/run-pass/box-compare.rs deleted file mode 100644 index 9e8e416d7b07d..0000000000000 --- a/src/test/run-pass/box-compare.rs +++ /dev/null @@ -1,20 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::GC; - -pub fn main() { - assert!((box(GC) 1i < box(GC) 3i)); - 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())); -} diff --git a/src/test/run-pass/box-in-tup.rs b/src/test/run-pass/box-in-tup.rs deleted file mode 100644 index 8d7bb55028f68..0000000000000 --- a/src/test/run-pass/box-in-tup.rs +++ /dev/null @@ -1,17 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -pub fn main() { - let i: (Gc, int) = (box(GC) 10, 10); - let (_a, _) = i; -} diff --git a/src/test/run-pass/box-inside-if.rs b/src/test/run-pass/box-inside-if.rs deleted file mode 100644 index 47c7e7f16f488..0000000000000 --- a/src/test/run-pass/box-inside-if.rs +++ /dev/null @@ -1,24 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{GC, Gc}; - -fn some_box(x: int) -> Gc { return box(GC) x; } - -fn is_odd(_n: int) -> bool { return true; } - -fn length_is_even(_vs: Gc) -> bool { return true; } - -fn foo(_acc: int, n: int) { - if is_odd(n) && length_is_even(some_box(1)) { println!("bloop"); } -} - -pub fn main() { foo(67, 5); } diff --git a/src/test/run-pass/box-inside-if2.rs b/src/test/run-pass/box-inside-if2.rs deleted file mode 100644 index e62050c8ea962..0000000000000 --- a/src/test/run-pass/box-inside-if2.rs +++ /dev/null @@ -1,24 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -fn some_box(x: int) -> Gc { return box(GC) x; } - -fn is_odd(_n: int) -> bool { return true; } - -fn length_is_even(_vs: Gc) -> bool { return true; } - -fn foo(_acc: int, n: int) { - if is_odd(n) || length_is_even(some_box(1)) { println!("bloop"); } -} - -pub fn main() { foo(67, 5); } diff --git a/src/test/run-pass/box-pattern.rs b/src/test/run-pass/box-pattern.rs deleted file mode 100644 index 21d1d2359019a..0000000000000 --- a/src/test/run-pass/box-pattern.rs +++ /dev/null @@ -1,20 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let box x = box 3i; - match box 3i { - box y => { - assert!(x == y); - println!("{} {}", x, y); - } - } -} - diff --git a/src/test/run-pass/box-unbox.rs b/src/test/run-pass/box-unbox.rs deleted file mode 100644 index bc8afff0cd626..0000000000000 --- a/src/test/run-pass/box-unbox.rs +++ /dev/null @@ -1,23 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -struct Box {c: Gc} - -fn unbox(b: Box) -> T { return (*b.c).clone(); } - -pub fn main() { - let foo: int = 17; - let bfoo: Box = Box {c: box(GC) foo}; - println!("see what's in our box"); - assert_eq!(unbox::(bfoo), foo); -} diff --git a/src/test/run-pass/box.rs b/src/test/run-pass/box.rs deleted file mode 100644 index 844b9392ec864..0000000000000 --- a/src/test/run-pass/box.rs +++ /dev/null @@ -1,14 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -pub fn main() { let x: Gc = box(GC) 10; assert!((*x == 10)); } diff --git a/src/test/run-pass/boxed-class-type-substitution.rs b/src/test/run-pass/boxed-class-type-substitution.rs deleted file mode 100644 index 41ffdd7b4b9ad..0000000000000 --- a/src/test/run-pass/boxed-class-type-substitution.rs +++ /dev/null @@ -1,37 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test that rustc doesn't recurse infinitely substituting -// the boxed type parameter - - -use std::gc::Gc; - -struct Tree { - parent: Option -} - -fn empty() -> Tree { fail!() } - -struct Box { - tree: Tree> -} - -fn Box() -> Box { - Box { - tree: empty() - } -} - -struct LayoutData { - a_box: Option> -} - -pub fn main() { } diff --git a/src/test/run-pass/cci_borrow.rs b/src/test/run-pass/cci_borrow.rs index e319866d5ce73..262c19174b18b 100644 --- a/src/test/run-pass/cci_borrow.rs +++ b/src/test/run-pass/cci_borrow.rs @@ -13,10 +13,9 @@ extern crate cci_borrow_lib; use cci_borrow_lib::foo; -use std::gc::GC; pub fn main() { - let p = box(GC) 22u; + let p = box 22u; let r = foo(&*p); println!("r={}", r); assert_eq!(r, 22u); diff --git a/src/test/run-pass/classes-self-referential.rs b/src/test/run-pass/classes-self-referential.rs index 099431acd246c..a54a821a7b9b4 100644 --- a/src/test/run-pass/classes-self-referential.rs +++ b/src/test/run-pass/classes-self-referential.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::Gc; - struct kitten { cat: Option, } @@ -21,6 +19,6 @@ fn kitten(cat: Option) -> kitten { } } -type cat = Gc; +type cat = Box; pub fn main() {} diff --git a/src/test/run-pass/cleanup-copy-mode.rs b/src/test/run-pass/cleanup-copy-mode.rs deleted file mode 100644 index 3eec506c9e319..0000000000000 --- a/src/test/run-pass/cleanup-copy-mode.rs +++ /dev/null @@ -1,21 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::task; -use std::gc::{GC, Gc}; - -fn adder(x: Gc, y: Gc) -> int { return *x + *y; } -fn failer() -> Gc { fail!(); } -pub fn main() { - assert!(task::try(proc() { - adder(box(GC) 2, failer()); () - }).is_err()); -} diff --git a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs index 481a922a463f0..0088a36eda9a3 100644 --- a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs +++ b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs @@ -17,12 +17,10 @@ extern crate crate_method_reexport_grrrrrrr2; -use std::gc::GC; - pub fn main() { use crate_method_reexport_grrrrrrr2::rust::add; use crate_method_reexport_grrrrrrr2::rust::cx; - let x = box(GC) (); + let x = box() (); x.cx(); let y = (); y.add("hi".to_string()); diff --git a/src/test/run-pass/cycle-collection.rs b/src/test/run-pass/cycle-collection.rs deleted file mode 100644 index edcbd21476b42..0000000000000 --- a/src/test/run-pass/cycle-collection.rs +++ /dev/null @@ -1,27 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::cell::RefCell; -use std::gc::{Gc, GC}; - -enum taggy { - cons(Gc>), - nil, -} - -fn f() { - let a_box = box(GC) RefCell::new(nil); - *a_box.borrow_mut() = cons(a_box); -} - -pub fn main() { - f(); -} diff --git a/src/test/run-pass/deref-lval.rs b/src/test/run-pass/deref-lval.rs index 4ccf6744d5c00..d9b0940f80b3f 100644 --- a/src/test/run-pass/deref-lval.rs +++ b/src/test/run-pass/deref-lval.rs @@ -9,13 +9,10 @@ // except according to those terms. -extern crate debug; - use std::cell::Cell; -use std::gc::GC; pub fn main() { - let x = box(GC) Cell::new(5i); + let x = box Cell::new(5i); x.set(1000i); - println!("{:?}", x.get()); + println!("{}", x.get()); } diff --git a/src/test/run-pass/deref.rs b/src/test/run-pass/deref.rs index 12fc65cecb943..117b133a11319 100644 --- a/src/test/run-pass/deref.rs +++ b/src/test/run-pass/deref.rs @@ -9,9 +9,7 @@ // except according to those terms. -use std::gc::{Gc, GC}; - pub fn main() { - let x: Gc = box(GC) 10; + let x: Box = box 10; let _y: int = *x; } diff --git a/src/test/run-pass/double-unbox.rs b/src/test/run-pass/double-unbox.rs deleted file mode 100644 index 0d5556a867b6d..0000000000000 --- a/src/test/run-pass/double-unbox.rs +++ /dev/null @@ -1,21 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::Gc; - -struct Quux { - bar: int -} - -fn g(_i: int) { } -fn f(foo: Gc>) { g(foo.bar); } - -pub fn main() { } diff --git a/src/test/run-pass/drop-on-empty-block-exit.rs b/src/test/run-pass/drop-on-empty-block-exit.rs index 8add96d8ed7bc..c52549d286fd5 100644 --- a/src/test/run-pass/drop-on-empty-block-exit.rs +++ b/src/test/run-pass/drop-on-empty-block-exit.rs @@ -9,11 +9,9 @@ // except according to those terms. -use std::gc::{Gc, GC}; - -enum t { foo(Gc), } +enum t { foo(Box), } pub fn main() { - let tt = foo(box(GC) 10); + let tt = foo(box 10); match tt { foo(_z) => { } } } diff --git a/src/test/run-pass/enum-null-pointer-opt.rs b/src/test/run-pass/enum-null-pointer-opt.rs index 433c3b5422473..3e22c83318393 100644 --- a/src/test/run-pass/enum-null-pointer-opt.rs +++ b/src/test/run-pass/enum-null-pointer-opt.rs @@ -9,7 +9,6 @@ // except according to those terms. -use std::gc::Gc; use std::mem::size_of; trait Trait {} @@ -33,9 +32,8 @@ fn main() { assert_eq!(size_of::<&Trait>(), size_of::>()); assert_eq!(size_of::<&mut Trait>(), size_of::>()); - // Pointers - Box / Gc + // Pointers - Box assert_eq!(size_of::>(), size_of::>>()); - assert_eq!(size_of::>(), size_of::>>()); // The optimization can't apply to raw pointers diff --git a/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs b/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs index 7d8a3d3fb7965..24fb503aea3a9 100644 --- a/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs +++ b/src/test/run-pass/enum-nullable-simplifycfg-misopt.rs @@ -15,11 +15,9 @@ * represented with nullable pointers could be misoptimized in some cases. */ -use std::gc::{Gc, GC}; - -enum List { Nil, Cons(X, Gc>) } +enum List { Nil, Cons(X, Box>) } pub fn main() { - match Cons(10i, box(GC) Nil) { + match Cons(10i, box Nil) { Cons(10i, _) => {} Nil => {} _ => fail!() diff --git a/src/test/run-pass/evec-internal-boxes.rs b/src/test/run-pass/evec-internal-boxes.rs deleted file mode 100644 index 63e034c0eaa30..0000000000000 --- a/src/test/run-pass/evec-internal-boxes.rs +++ /dev/null @@ -1,22 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_assignment)] - -use std::gc::{Gc, GC}; - -pub fn main() { - let x : [Gc, ..5] = [box(GC) 1,box(GC) 2,box(GC) 3,box(GC) 4,box(GC) 5]; - let _y : [Gc, ..5] = [box(GC) 1,box(GC) 2,box(GC) 3,box(GC) 4,box(GC) 5]; - let mut z = [box(GC) 1,box(GC) 2,box(GC) 3,box(GC) 4,box(GC) 5]; - z = x; - assert_eq!(*z[0], 1); - assert_eq!(*z[4], 5); -} diff --git a/src/test/run-pass/export-non-interference.rs b/src/test/run-pass/export-non-interference.rs index 424a09227ec0e..94652e30fe64f 100644 --- a/src/test/run-pass/export-non-interference.rs +++ b/src/test/run-pass/export-non-interference.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::Gc; - -enum list_cell { cons(Gc>), nil } +enum list_cell { cons(Box>), nil } pub fn main() { } diff --git a/src/test/run-pass/expr-block-box.rs b/src/test/run-pass/expr-block-box.rs deleted file mode 100644 index 9b3d2028edffb..0000000000000 --- a/src/test/run-pass/expr-block-box.rs +++ /dev/null @@ -1,14 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::GC; - -pub fn main() { let x = { box(GC) 100i }; assert!((*x == 100)); } diff --git a/src/test/run-pass/expr-block-generic-box1.rs b/src/test/run-pass/expr-block-generic-box1.rs deleted file mode 100644 index dfcef1712526a..0000000000000 --- a/src/test/run-pass/expr-block-generic-box1.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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -type compare = |Gc, Gc|: 'static -> bool; - -fn test_generic(expected: Gc, eq: compare) { - let actual: Gc = { expected }; - assert!((eq(expected, actual))); -} - -fn test_box() { - fn compare_box(b1: Gc, b2: Gc) -> bool { - println!("{}", *b1); - println!("{}", *b2); - return *b1 == *b2; - } - test_generic::(box(GC) true, compare_box); -} - -pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-block-generic-box2.rs b/src/test/run-pass/expr-block-generic-box2.rs deleted file mode 100644 index 547e7dfa9110e..0000000000000 --- a/src/test/run-pass/expr-block-generic-box2.rs +++ /dev/null @@ -1,26 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{GC, Gc}; - -type compare<'a, T> = |T, T|: 'a -> bool; - -fn test_generic(expected: T, eq: compare) { - let actual: T = { expected.clone() }; - assert!((eq(expected, actual))); -} - -fn test_vec() { - fn compare_vec(v1: Gc, v2: Gc) -> bool { return v1 == v2; } - test_generic::>(box(GC) 1, compare_vec); -} - -pub fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-block-ref.rs b/src/test/run-pass/expr-block-ref.rs deleted file mode 100644 index 3d649b17b7937..0000000000000 --- a/src/test/run-pass/expr-block-ref.rs +++ /dev/null @@ -1,15 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::GC; - -// Regression test for issue #388 -pub fn main() { let _x = { { box(GC) 10i } }; } diff --git a/src/test/run-pass/expr-elseif-ref.rs b/src/test/run-pass/expr-elseif-ref.rs deleted file mode 100644 index f0b9c85a53d33..0000000000000 --- a/src/test/run-pass/expr-elseif-ref.rs +++ /dev/null @@ -1,20 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -// Make sure we drop the refs of the temporaries needed to return the -// values from the else if branch -pub fn main() { - let y: Gc = box(GC) 10u; - let _x = if false { y } else if true { y } else { y }; - assert_eq!(*y, 10u); -} diff --git a/src/test/run-pass/expr-elseif-ref2.rs b/src/test/run-pass/expr-elseif-ref2.rs deleted file mode 100644 index 9d4efea7e3d10..0000000000000 --- a/src/test/run-pass/expr-elseif-ref2.rs +++ /dev/null @@ -1,23 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{GC}; - -// Regression test for issue #388 -pub fn main() { - let _x = if false { - box(GC) 0u - } else if true { - box(GC) 10u - } else { - box(GC) 0u - }; -} diff --git a/src/test/run-pass/expr-if-box.rs b/src/test/run-pass/expr-if-box.rs deleted file mode 100644 index 3def4571e134b..0000000000000 --- a/src/test/run-pass/expr-if-box.rs +++ /dev/null @@ -1,25 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -// Tests for if as expressions returning boxed types -fn test_box() { - let rs = if true { box(GC) 100i } else { box(GC) 101i }; - assert_eq!(*rs, 100); -} - -fn test_str() { - let rs = if true { "happy".to_string() } else { "sad".to_string() }; - assert_eq!(rs, "happy".to_string()); -} - -pub fn main() { test_box(); test_str(); } diff --git a/src/test/run-pass/expr-if-generic-box1.rs b/src/test/run-pass/expr-if-generic-box1.rs deleted file mode 100644 index 931f500a30935..0000000000000 --- a/src/test/run-pass/expr-if-generic-box1.rs +++ /dev/null @@ -1,26 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{GC, Gc}; - -type compare = |Gc, Gc|: 'static -> bool; - -fn test_generic(expected: Gc, not_expected: Gc, eq: compare) { - let actual: Gc = if true { expected } else { not_expected }; - assert!((eq(expected, actual))); -} - -fn test_box() { - fn compare_box(b1: Gc, b2: Gc) -> bool { return *b1 == *b2; } - test_generic::(box(GC) true, box(GC) false, compare_box); -} - -pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-if-generic-box2.rs b/src/test/run-pass/expr-if-generic-box2.rs deleted file mode 100644 index b8b8c9b89a8ad..0000000000000 --- a/src/test/run-pass/expr-if-generic-box2.rs +++ /dev/null @@ -1,26 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -type compare = |T, T|: 'static -> bool; - -fn test_generic(expected: T, not_expected: T, eq: compare) { - let actual: T = if true { expected.clone() } else { not_expected }; - assert!((eq(expected, actual))); -} - -fn test_vec() { - fn compare_box(v1: Gc, v2: Gc) -> bool { return v1 == v2; } - test_generic::>(box(GC) 1, box(GC) 2, compare_box); -} - -pub fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-match-box.rs b/src/test/run-pass/expr-match-box.rs deleted file mode 100644 index c2ba36006bd03..0000000000000 --- a/src/test/run-pass/expr-match-box.rs +++ /dev/null @@ -1,26 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::GC; - -// Tests for match as expressions resulting in boxed types -fn test_box() { - let res = match true { true => { box(GC) 100i } _ => fail!("wat") }; - assert_eq!(*res, 100i); -} - -fn test_str() { - let res = match true { true => { "happy".to_string() }, - _ => fail!("not happy at all") }; - assert_eq!(res, "happy".to_string()); -} - -pub fn main() { test_box(); test_str(); } diff --git a/src/test/run-pass/expr-match-generic-box1.rs b/src/test/run-pass/expr-match-generic-box1.rs deleted file mode 100644 index 97fa53b5e2439..0000000000000 --- a/src/test/run-pass/expr-match-generic-box1.rs +++ /dev/null @@ -1,26 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -type compare = |Gc, Gc|: 'static -> bool; - -fn test_generic(expected: Gc, eq: compare) { - let actual: Gc = match true { true => { expected }, _ => fail!() }; - assert!((eq(expected, actual))); -} - -fn test_box() { - fn compare_box(b1: Gc, b2: Gc) -> bool { return *b1 == *b2; } - test_generic::(box(GC) true, compare_box); -} - -pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-match-generic-box2.rs b/src/test/run-pass/expr-match-generic-box2.rs deleted file mode 100644 index fd8179c59a593..0000000000000 --- a/src/test/run-pass/expr-match-generic-box2.rs +++ /dev/null @@ -1,26 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -type compare = |T, T|: 'static -> bool; - -fn test_generic(expected: T, eq: compare) { - let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") }; - assert!((eq(expected, actual))); -} - -fn test_vec() { - fn compare_box(v1: Gc, v2: Gc) -> bool { return v1 == v2; } - test_generic::>(box(GC) 1, compare_box); -} - -pub fn main() { test_vec(); } diff --git a/src/test/run-pass/exterior.rs b/src/test/run-pass/exterior.rs index cd0f3d6101a9c..e95c203413155 100644 --- a/src/test/run-pass/exterior.rs +++ b/src/test/run-pass/exterior.rs @@ -10,11 +10,10 @@ use std::cell::Cell; -use std::gc::{Gc, GC}; struct Point {x: int, y: int, z: int} -fn f(p: Gc>) { +fn f(p: &Cell) { assert!((p.get().z == 12)); p.set(Point {x: 10, y: 11, z: 13}); assert!((p.get().z == 13)); @@ -22,7 +21,7 @@ fn f(p: Gc>) { pub fn main() { let a: Point = Point {x: 10, y: 11, z: 12}; - let b: Gc> = box(GC) Cell::new(a); + let b: &Cell = &Cell::new(a); assert_eq!(b.get().z, 12); f(b); assert_eq!(a.z, 12); diff --git a/src/test/run-pass/fail-during-tld-destroy.rs b/src/test/run-pass/fail-during-tld-destroy.rs index 835f1fe4d4a80..3faa30c4c8a20 100644 --- a/src/test/run-pass/fail-during-tld-destroy.rs +++ b/src/test/run-pass/fail-during-tld-destroy.rs @@ -9,45 +9,25 @@ // except according to those terms. use std::task; -use std::gc::{GC, Gc}; -use std::cell::RefCell; static mut DROPS: uint = 0; -struct Foo(bool); +struct Foo; impl Drop for Foo { fn drop(&mut self) { - let Foo(fail) = *self; unsafe { DROPS += 1; } - if fail { fail!() } + fail!() } } -fn tld_fail(fail: bool) { - local_data_key!(foo: Foo); - foo.replace(Some(Foo(fail))); -} - -fn gc_fail(fail: bool) { - struct A { - inner: RefCell>>, - other: Foo, - } - let a = box(GC) A { - inner: RefCell::new(None), - other: Foo(fail), - }; - *a.inner.borrow_mut() = Some(a.clone()); -} - fn main() { let _ = task::try(proc() { - tld_fail(true); - gc_fail(false); + local_data_key!(foo: Foo); + foo.replace(Some(Foo)); }); unsafe { - assert_eq!(DROPS, 2); + assert_eq!(DROPS, 1); } } diff --git a/src/test/run-pass/gc-vec.rs b/src/test/run-pass/gc-vec.rs deleted file mode 100644 index 430ee16bc8a26..0000000000000 --- a/src/test/run-pass/gc-vec.rs +++ /dev/null @@ -1,22 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::gc::{GC}; - -fn main() { - // A fixed-size array allocated in a garbage-collected box - let x = box(GC) [1i, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - assert_eq!(x[0], 1); - assert_eq!(x[6], 7); - assert_eq!(x[9], 10); - - let y = x; - assert!(*y == [1i, 2, 3, 4, 5, 6, 7, 8, 9, 10]); -} diff --git a/src/test/run-pass/generic-alias-box.rs b/src/test/run-pass/generic-alias-box.rs deleted file mode 100644 index 325f6a2c85473..0000000000000 --- a/src/test/run-pass/generic-alias-box.rs +++ /dev/null @@ -1,23 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -extern crate debug; - -use std::gc::{Gc, GC}; - -fn id(t: T) -> T { return t; } - -pub fn main() { - let expected = box(GC) 100; - let actual = id::>(expected); - println!("{:?}", *actual); - assert_eq!(*expected, *actual); -} diff --git a/src/test/run-pass/generic-box.rs b/src/test/run-pass/generic-box.rs deleted file mode 100644 index d5047eb8f863b..0000000000000 --- a/src/test/run-pass/generic-box.rs +++ /dev/null @@ -1,21 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -fn box_it(x: Box) -> Gc> { return box(GC) x; } - -struct Box {x: T, y: T, z: T} - -pub fn main() { - let x: Gc> = box_it::(Box{x: 1, y: 2, z: 3}); - assert_eq!(x.y, 2); -} diff --git a/src/test/run-pass/generic-drop-glue.rs b/src/test/run-pass/generic-drop-glue.rs deleted file mode 100644 index 2cc3a89459eba..0000000000000 --- a/src/test/run-pass/generic-drop-glue.rs +++ /dev/null @@ -1,18 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -struct Pair { x: Gc, y: Gc } - -fn f(t: T) { let _t1: T = t; } - -pub fn main() { let x = Pair {x: box(GC) 10, y: box(GC) 12}; f(x); } diff --git a/src/test/run-pass/generic-exterior-box.rs b/src/test/run-pass/generic-exterior-box.rs deleted file mode 100644 index 2c1ae5d985489..0000000000000 --- a/src/test/run-pass/generic-exterior-box.rs +++ /dev/null @@ -1,22 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -struct Recbox {x: Gc} - -fn reclift(t: T) -> Recbox { return Recbox {x: box(GC) t}; } - -pub fn main() { - let foo: int = 17; - let rbfoo: Recbox = reclift::(foo); - assert_eq!(*rbfoo.x, foo); -} diff --git a/src/test/run-pass/generic-fn-box.rs b/src/test/run-pass/generic-fn-box.rs deleted file mode 100644 index 2164b00e06691..0000000000000 --- a/src/test/run-pass/generic-fn-box.rs +++ /dev/null @@ -1,18 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -extern crate debug; - -use std::gc::{Gc, GC}; - -fn f(x: Gc) -> Gc { return x; } - -pub fn main() { let x = f(box(GC) 3i); println!("{:?}", *x); } diff --git a/src/test/run-pass/generic-ivec.rs b/src/test/run-pass/generic-ivec.rs deleted file mode 100644 index 68e7b98183b3c..0000000000000 --- a/src/test/run-pass/generic-ivec.rs +++ /dev/null @@ -1,15 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -fn f(_v: Gc) { } -pub fn main() { f(box(GC) vec!(1i, 2, 3, 4, 5)); } diff --git a/src/test/run-pass/generic-recursive-tag.rs b/src/test/run-pass/generic-recursive-tag.rs index 6d81cea8b2fcf..d8777515cecf0 100644 --- a/src/test/run-pass/generic-recursive-tag.rs +++ b/src/test/run-pass/generic-recursive-tag.rs @@ -11,14 +11,12 @@ // ignore-pretty FIXME(#14193) -use std::gc::{Gc, GC}; - -enum list { cons(Gc, Gc>), nil, } +enum list { cons(Box, Box>), nil, } pub fn main() { let _a: list = - cons::(box(GC) 10, - box(GC) cons::(box(GC) 12, - box(GC) cons::(box(GC) 13, - box(GC) nil::))); + cons::(box 10, + box cons::(box 12, + box cons::(box 13, + box nil::))); } diff --git a/src/test/run-pass/generic-tag.rs b/src/test/run-pass/generic-tag.rs index 43cdf43ceb354..52e512e515c58 100644 --- a/src/test/run-pass/generic-tag.rs +++ b/src/test/run-pass/generic-tag.rs @@ -11,11 +11,9 @@ #![allow(dead_assignment)] #![allow(unused_variable)] -use std::gc::{Gc, GC}; - -enum option { some(Gc), none, } +enum option { some(Box), none, } pub fn main() { - let mut a: option = some::(box(GC) 10); + let mut a: option = some::(box 10); a = none::; } diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 78e17bb22bd03..365070f704f85 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -18,7 +18,6 @@ extern crate debug; use std::fmt; -use std::gc::GC; use std::io::MemWriter; use std::io; use std::str; @@ -50,7 +49,6 @@ pub fn main() { t!(format!("{:?}", 1i), "1"); t!(format!("{:?}", A), "A"); t!(format!("{:?}", ()), "()"); - t!(format!("{:?}", box(GC) (box 1i, "foo")), "box(GC) (box 1, \"foo\")"); // Various edge cases without formats t!(format!(""), ""); diff --git a/src/test/run-pass/init-res-into-things.rs b/src/test/run-pass/init-res-into-things.rs index d6920b2e2fe80..752e95f25dc53 100644 --- a/src/test/run-pass/init-res-into-things.rs +++ b/src/test/run-pass/init-res-into-things.rs @@ -11,52 +11,43 @@ #![feature(unsafe_destructor)] use std::cell::Cell; -use std::gc::{Gc, GC}; // Resources can't be copied, but storing into data structures counts // as a move unless the stored thing is used afterwards. -struct r { - i: Gc>, +struct r<'a> { + i: &'a Cell, } -struct Box { x: r } +struct BoxR<'a> { x: r<'a> } #[unsafe_destructor] -impl Drop for r { +impl<'a> Drop for r<'a> { fn drop(&mut self) { self.i.set(self.i.get() + 1) } } -fn r(i: Gc>) -> r { +fn r(i: &Cell) -> r { r { i: i } } -fn test_box() { - let i = box(GC) Cell::new(0i); - { - let _a = box(GC) r(i); - } - assert_eq!(i.get(), 1); -} - fn test_rec() { - let i = box(GC) Cell::new(0i); + let i = &Cell::new(0i); { - let _a = Box {x: r(i)}; + let _a = BoxR {x: r(i)}; } assert_eq!(i.get(), 1); } fn test_tag() { - enum t { - t0(r), + enum t<'a> { + t0(r<'a>), } - let i = box(GC) Cell::new(0i); + let i = &Cell::new(0i); { let _a = t0(r(i)); } @@ -64,7 +55,7 @@ fn test_tag() { } fn test_tup() { - let i = box(GC) Cell::new(0i); + let i = &Cell::new(0i); { let _a = (r(i), 0i); } @@ -72,17 +63,17 @@ fn test_tup() { } fn test_unique() { - let i = box(GC) Cell::new(0i); + let i = &Cell::new(0i); { let _a = box r(i); } assert_eq!(i.get(), 1); } -fn test_box_rec() { - let i = box(GC) Cell::new(0i); +fn test_unique_rec() { + let i = &Cell::new(0i); { - let _a = box(GC) Box { + let _a = box BoxR { x: r(i) }; } @@ -90,10 +81,9 @@ fn test_box_rec() { } pub fn main() { - test_box(); test_rec(); test_tag(); test_tup(); test_unique(); - test_box_rec(); + test_unique_rec(); } diff --git a/src/test/run-pass/issue-14082.rs b/src/test/run-pass/issue-14082.rs index 9aff6b917484e..dd9a7c97c9ab5 100644 --- a/src/test/run-pass/issue-14082.rs +++ b/src/test/run-pass/issue-14082.rs @@ -8,21 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(globs)] #![allow(unused_imports, dead_code)] -use foo::GC; +use foo::Foo; mod foo { - pub use m::GC; // this should shadow d::GC + pub use m::Foo; // this should shadow d::Foo } mod m { - pub struct GC; + pub struct Foo; } mod d { - pub struct GC; + pub struct Foo; } fn main() {} diff --git a/src/test/run-pass/issue-2631-b.rs b/src/test/run-pass/issue-2631-b.rs index 777210d2b0452..84f046499e439 100644 --- a/src/test/run-pass/issue-2631-b.rs +++ b/src/test/run-pass/issue-2631-b.rs @@ -11,17 +11,16 @@ // aux-build:issue-2631-a.rs -extern crate collections; extern crate req; use req::request; use std::cell::RefCell; use std::collections::HashMap; -use std::gc::GC; +use std::rc::Rc; pub fn main() { - let v = vec!(box(GC) "hi".to_string()); + let v = vec!(Rc::new("hi".to_string())); let mut m: req::header_map = HashMap::new(); - m.insert("METHOD".to_string(), box(GC) RefCell::new(v)); + m.insert("METHOD".to_string(), Rc::new(RefCell::new(v))); request::(&m); } diff --git a/src/test/run-pass/issue-2708.rs b/src/test/run-pass/issue-2708.rs index e11cb28c65db8..3ac4b874f3ad8 100644 --- a/src/test/run-pass/issue-2708.rs +++ b/src/test/run-pass/issue-2708.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - struct Font { fontbuf: uint, cairo_font: uint, @@ -31,5 +29,5 @@ fn Font() -> Font { } pub fn main() { - let _f = box(GC) Font(); + let _f = box Font(); } diff --git a/src/test/run-pass/issue-2735-2.rs b/src/test/run-pass/issue-2735-2.rs index f7a91d11748b3..0d1cf1c339227 100644 --- a/src/test/run-pass/issue-2735-2.rs +++ b/src/test/run-pass/issue-2735-2.rs @@ -11,28 +11,27 @@ #![feature(unsafe_destructor)] use std::cell::Cell; -use std::gc::{Gc, GC}; // This test should behave exactly like issue-2735-3 -struct defer { - b: Gc>, +struct defer<'a> { + b: &'a Cell, } #[unsafe_destructor] -impl Drop for defer { +impl<'a> Drop for defer<'a> { fn drop(&mut self) { self.b.set(true); } } -fn defer(b: Gc>) -> defer { +fn defer(b: &Cell) -> defer { defer { b: b } } pub fn main() { - let dtor_ran = box(GC) Cell::new(false); + let dtor_ran = &Cell::new(false); let _ = defer(dtor_ran); assert!(dtor_ran.get()); } diff --git a/src/test/run-pass/issue-2735-3.rs b/src/test/run-pass/issue-2735-3.rs index 3650c3f924643..658183cf6ff54 100644 --- a/src/test/run-pass/issue-2735-3.rs +++ b/src/test/run-pass/issue-2735-3.rs @@ -11,28 +11,27 @@ #![feature(unsafe_destructor)] use std::cell::Cell; -use std::gc::{Gc, GC}; // This test should behave exactly like issue-2735-2 -struct defer { - b: Gc>, +struct defer<'a> { + b: &'a Cell, } #[unsafe_destructor] -impl Drop for defer { +impl<'a> Drop for defer<'a> { fn drop(&mut self) { self.b.set(true); } } -fn defer(b: Gc>) -> defer { +fn defer(b: &Cell) -> defer { defer { b: b } } pub fn main() { - let dtor_ran = box(GC) Cell::new(false); + let dtor_ran = &Cell::new(false); defer(dtor_ran); assert!(dtor_ran.get()); } diff --git a/src/test/run-pass/issue-3012-2.rs b/src/test/run-pass/issue-3012-2.rs index 96e60dab3c9c6..aa2ce824822b1 100644 --- a/src/test/run-pass/issue-3012-2.rs +++ b/src/test/run-pass/issue-3012-2.rs @@ -14,10 +14,9 @@ extern crate socketlib; extern crate libc; -use std::gc::GC; use socketlib::socket; pub fn main() { let fd: libc::c_int = 1 as libc::c_int; - let _sock = box(GC) socket::socket_handle(fd); + let _sock = box socket::socket_handle(fd); } diff --git a/src/test/run-pass/issue-3121.rs b/src/test/run-pass/issue-3121.rs index 24ffd41649920..6b320e1474624 100644 --- a/src/test/run-pass/issue-3121.rs +++ b/src/test/run-pass/issue-3121.rs @@ -9,13 +9,11 @@ // except according to those terms. -use std::gc::{Gc, GC}; - enum side { mayo, catsup, vinegar } enum order { hamburger, fries(side), shake } enum meal { to_go(order), for_here(order) } -fn foo(m: Gc, cond: bool) { +fn foo(m: Box, cond: bool) { match *m { to_go(_) => { } for_here(_) if cond => {} @@ -26,5 +24,5 @@ fn foo(m: Gc, cond: bool) { } pub fn main() { - foo(box(GC) for_here(hamburger), true) + foo(box for_here(hamburger), true) } diff --git a/src/test/run-pass/issue-3447.rs b/src/test/run-pass/issue-3447.rs index 612e0a07dac12..4ebf981e4ee55 100644 --- a/src/test/run-pass/issue-3447.rs +++ b/src/test/run-pass/issue-3447.rs @@ -10,13 +10,12 @@ use std::cell::RefCell; -use std::gc::{Gc, GC}; static S: &'static str = "str"; struct list { element: T, - next: Option>>> + next: Option>>> } impl list { @@ -26,7 +25,7 @@ impl list { next: None }; - self.next = Some(box(GC) RefCell::new(newList)); + self.next = Some(box RefCell::new(newList)); } } diff --git a/src/test/run-pass/issue-3556.rs b/src/test/run-pass/issue-3556.rs index b8a34b751814b..e59cf9f77fa6e 100644 --- a/src/test/run-pass/issue-3556.rs +++ b/src/test/run-pass/issue-3556.rs @@ -9,18 +9,15 @@ // except according to those terms. -extern crate debug; - -use std::gc::{Gc, GC}; - +#[deriving(Show)] enum Token { - Text(Gc), - ETag(Gc> , Gc), - UTag(Gc> , Gc), - Section(Gc> , bool, Gc>, Gc, - Gc, Gc, Gc, Gc), - IncompleteSection(Gc> , bool, Gc, bool), - Partial(Gc, Gc, Gc), + Text(String), + ETag(Vec, String), + UTag(Vec, String), + Section(Vec, bool, Vec, String, + String, String, String, String), + IncompleteSection(Vec, bool, String, bool), + Partial(String, String, String), } fn check_strs(actual: &str, expected: &str) -> bool @@ -39,13 +36,13 @@ pub fn main() // assert!(check_strs(fmt!("%?", ETag(@~["foo".to_string()], @"bar".to_string())), // "ETag(@~[ ~\"foo\" ], @~\"bar\")")); - let t = Text(box(GC) "foo".to_string()); - let u = Section(box(GC) vec!("alpha".to_string()), - true, - box(GC) vec!(t), - box(GC) "foo".to_string(), - box(GC) "foo".to_string(), box(GC) "foo".to_string(), box(GC) "foo".to_string(), - box(GC) "foo".to_string()); - let v = format!("{:?}", u); // this is the line that causes the seg fault + let t = Text("foo".to_string()); + let u = Section(vec!["alpha".to_string()], + true, + vec![t], + "foo".to_string(), + "foo".to_string(), "foo".to_string(), "foo".to_string(), + "foo".to_string()); + let v = format!("{}", u); // this is the line that causes the seg fault assert!(v.len() > 0); } diff --git a/src/test/run-pass/issue-5884.rs b/src/test/run-pass/issue-5884.rs index 93f8ebf02acdb..4010c31eed50a 100644 --- a/src/test/run-pass/issue-5884.rs +++ b/src/test/run-pass/issue-5884.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::Gc; - pub struct Foo { a: int, } @@ -20,7 +18,7 @@ struct Bar<'a> { b: &'a Foo, } -fn check(a: Gc) { +fn check(a: Box) { let _ic = Bar{ b: &*a, a: box None }; } diff --git a/src/test/run-pass/issue-6117.rs b/src/test/run-pass/issue-6117.rs index e124b2efe29f8..7eaaa5ea74eda 100644 --- a/src/test/run-pass/issue-6117.rs +++ b/src/test/run-pass/issue-6117.rs @@ -9,12 +9,10 @@ // except according to those terms. -use std::gc::GC; - enum Either { Left(T), Right(U) } pub fn main() { - match Left(box(GC) 17i) { + match Left(box 17i) { Right(()) => {} _ => {} } diff --git a/src/test/run-pass/issue-8898.rs b/src/test/run-pass/issue-8898.rs index f2dcaa4a31eaa..3fff58410a41a 100644 --- a/src/test/run-pass/issue-8898.rs +++ b/src/test/run-pass/issue-8898.rs @@ -12,8 +12,6 @@ extern crate debug; -use std::gc::GC; - fn assert_repr_eq(obj : T, expected : String) { assert_eq!(expected, format!("{:?}", obj)); } @@ -23,12 +21,10 @@ pub fn main() { let tf = [true, false]; let x = [(), ()]; let slice = x[0..1]; - let z = box(GC) x; assert_repr_eq(abc, "[1, 2, 3]".to_string()); assert_repr_eq(tf, "[true, false]".to_string()); assert_repr_eq(x, "[(), ()]".to_string()); assert_repr_eq(slice, "&[()]".to_string()); assert_repr_eq(&x, "&[(), ()]".to_string()); - assert_repr_eq(z, "box(GC) [(), ()]".to_string()); } diff --git a/src/test/run-pass/issue-8983.rs b/src/test/run-pass/issue-8983.rs deleted file mode 100644 index 1291f0b6cd1c7..0000000000000 --- a/src/test/run-pass/issue-8983.rs +++ /dev/null @@ -1,20 +0,0 @@ -// 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. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::GC; - -fn main() { - fn f(_: proc()) {} - fn eat(_: T) {} - - let x = box(GC) 1i; - f(proc() { eat(x) }); -} diff --git a/src/test/run-pass/issue-979.rs b/src/test/run-pass/issue-979.rs index abe6a2d9ee63f..919f0aae38e0a 100644 --- a/src/test/run-pass/issue-979.rs +++ b/src/test/run-pass/issue-979.rs @@ -11,27 +11,26 @@ #![feature(unsafe_destructor)] use std::cell::Cell; -use std::gc::{GC, Gc}; -struct r { - b: Gc>, +struct r<'a> { + b: &'a Cell, } #[unsafe_destructor] -impl Drop for r { +impl<'a> Drop for r<'a> { fn drop(&mut self) { self.b.set(self.b.get() + 1); } } -fn r(b: Gc>) -> r { +fn r(b: &Cell) -> r { r { b: b } } pub fn main() { - let b = box(GC) Cell::new(0); + let b = &Cell::new(0); { let _p = Some(r(b)); } diff --git a/src/test/run-pass/issue-980.rs b/src/test/run-pass/issue-980.rs deleted file mode 100644 index 1083f1b3c71cb..0000000000000 --- a/src/test/run-pass/issue-980.rs +++ /dev/null @@ -1,29 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::cell::RefCell; -use std::gc::{Gc, GC}; - -enum maybe_pointy { - no_pointy, - yes_pointy(Gc>), -} - -struct Pointy { - x: maybe_pointy -} - -pub fn main() { - let m = box(GC) RefCell::new(Pointy { x : no_pointy }); - *m.borrow_mut() = Pointy { - x: yes_pointy(m) - }; -} diff --git a/src/test/run-pass/leak-box-as-tydesc.rs b/src/test/run-pass/leak-box-as-tydesc.rs deleted file mode 100644 index 57b9b2494f5ff..0000000000000 --- a/src/test/run-pass/leak-box-as-tydesc.rs +++ /dev/null @@ -1,16 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -fn leaky(_t: T) { } - -pub fn main() { let x = box(GC) 10; leaky::>(x); } diff --git a/src/test/run-pass/leak-tag-copy.rs b/src/test/run-pass/leak-tag-copy.rs deleted file mode 100644 index 3be122b38fa1e..0000000000000 --- a/src/test/run-pass/leak-tag-copy.rs +++ /dev/null @@ -1,18 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_assignment)] -#![allow(unused_variable)] - -use std::gc::{Gc, GC}; - -enum t { a, b(Gc), } - -pub fn main() { let mut x = b(box(GC) 10); x = a; } diff --git a/src/test/run-pass/list.rs b/src/test/run-pass/list.rs index bbb3ce2f2e1a1..7d0778b685937 100644 --- a/src/test/run-pass/list.rs +++ b/src/test/run-pass/list.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::{Gc, GC}; +enum list { cons(int, Box), nil, } -enum list { cons(int, Gc), nil, } - -pub fn main() { cons(10, box(GC) cons(11, box(GC) cons(12, box(GC) nil))); } +pub fn main() { cons(10, box cons(11, box cons(12, box nil))); } diff --git a/src/test/run-pass/mlist.rs b/src/test/run-pass/mlist.rs deleted file mode 100644 index ee91ae124b876..0000000000000 --- a/src/test/run-pass/mlist.rs +++ /dev/null @@ -1,16 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -enum mlist { cons(int, Gc), nil, } - -pub fn main() { cons(10, box(GC) cons(11, box(GC) cons(12, box(GC) nil))); } diff --git a/src/test/run-pass/move-1.rs b/src/test/run-pass/move-1.rs deleted file mode 100644 index 6f4ffa51a4677..0000000000000 --- a/src/test/run-pass/move-1.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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -struct Triple { x: int, y: int, z: int } - -fn test(x: bool, foo: Gc) -> int { - let bar = foo; - let mut y: Gc; - y = bar; - if x { y = bar; } else { y = box(GC) Triple{x: 4, y: 5, z: 6}; } - return y.y; -} - -pub fn main() { - let x = box(GC) Triple {x: 1, y: 2, z: 3}; - assert_eq!(test(true, x), 2); - assert_eq!(test(true, x), 2); - assert_eq!(test(true, x), 2); - assert_eq!(test(false, x), 5); -} diff --git a/src/test/run-pass/move-2.rs b/src/test/run-pass/move-2.rs index bcc67738dd4e2..04540c2f35b29 100644 --- a/src/test/run-pass/move-2.rs +++ b/src/test/run-pass/move-2.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - struct X { x: int, y: int, z: int } -pub fn main() { let x = box(GC) X {x: 1, y: 2, z: 3}; let y = x; assert!((y.y == 2)); } +pub fn main() { let x = box X {x: 1, y: 2, z: 3}; let y = x; assert!((y.y == 2)); } diff --git a/src/test/run-pass/move-3.rs b/src/test/run-pass/move-3.rs deleted file mode 100644 index 21a7d57b5631e..0000000000000 --- a/src/test/run-pass/move-3.rs +++ /dev/null @@ -1,29 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -struct Triple { x: int, y: int, z: int } - -fn test(x: bool, foo: Gc) -> int { - let bar = foo; - let mut y: Gc; - if x { y = bar; } else { y = box(GC) Triple{x: 4, y: 5, z: 6}; } - return y.y; -} - -pub fn main() { - let x = box(GC) Triple{x: 1, y: 2, z: 3}; - for _i in range(0u, 10000u) { - assert_eq!(test(true, x), 2); - } - assert_eq!(test(false, x), 5); -} diff --git a/src/test/run-pass/move-4.rs b/src/test/run-pass/move-4.rs index 984cef559983d..5e5d01ae6ee45 100644 --- a/src/test/run-pass/move-4.rs +++ b/src/test/run-pass/move-4.rs @@ -9,11 +9,9 @@ // except according to those terms. -use std::gc::{GC, Gc}; - struct Triple { a: int, b: int, c: int } -fn test(foo: Gc) -> Gc { +fn test(foo: Box) -> Box { let foo = foo; let bar = foo; let baz = bar; @@ -22,7 +20,7 @@ fn test(foo: Gc) -> Gc { } pub fn main() { - let x = box(GC) Triple{a: 1, b: 2, c: 3}; + let x = box Triple{a: 1, b: 2, c: 3}; let y = test(x); assert_eq!(y.c, 3); } diff --git a/src/test/run-pass/move-arg-2.rs b/src/test/run-pass/move-arg-2.rs index d00cdcca3e362..840a3c2a6ee86 100644 --- a/src/test/run-pass/move-arg-2.rs +++ b/src/test/run-pass/move-arg-2.rs @@ -9,15 +9,13 @@ // except according to those terms. -use std::gc::{Gc, GC}; - -fn test(foo: Gc>) { assert!((*foo.get(0) == 10)); } +fn test(foo: Box>) { assert!((*foo.get(0) == 10)); } pub fn main() { - let x = box(GC) vec!(10); + let x = box vec!(10); // Test forgetting a local by move-in test(x); // Test forgetting a temporary by move-in. - test(box(GC) vec!(10)); + test(box vec!(10)); } diff --git a/src/test/run-pass/mutable-vec-drop.rs b/src/test/run-pass/mutable-vec-drop.rs deleted file mode 100644 index 665303ac48765..0000000000000 --- a/src/test/run-pass/mutable-vec-drop.rs +++ /dev/null @@ -1,23 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_mut)] - -use std::gc::{Gc, GC}; - -struct Pair { a: int, b: int} - -pub fn main() { - // This just tests whether the vec leaks its members. - let mut _pvec: Vec> = - vec!(box(GC) Pair{a: 1, b: 2}, - box(GC) Pair{a: 3, b: 4}, - box(GC) Pair{a: 5, b: 6}); -} diff --git a/src/test/run-pass/mutual-recursion-group.rs b/src/test/run-pass/mutual-recursion-group.rs index 18f332dbb9772..8444a632fe889 100644 --- a/src/test/run-pass/mutual-recursion-group.rs +++ b/src/test/run-pass/mutual-recursion-group.rs @@ -9,14 +9,12 @@ // except according to those terms. -use std::gc::Gc; - enum colour { red, green, blue, } -enum tree { children(Gc), leaf(colour), } +enum tree { children(Box), leaf(colour), } -enum list { cons(Gc, Gc), nil, } +enum list { cons(Box, Box), nil, } -enum small_list { kons(int, Gc), neel, } +enum small_list { kons(int, Box), neel, } pub fn main() { } diff --git a/src/test/run-pass/new-box-syntax.rs b/src/test/run-pass/new-box-syntax.rs index f61a8837e2c7c..991d0ecdc87a6 100644 --- a/src/test/run-pass/new-box-syntax.rs +++ b/src/test/run-pass/new-box-syntax.rs @@ -11,9 +11,8 @@ /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ -// Tests that the new `box` syntax works with unique pointers and GC pointers. +// Tests that the new `box` syntax works with unique pointers. -use std::gc::{Gc, GC}; use std::boxed::{Box, HEAP}; struct Structure { @@ -24,12 +23,6 @@ struct Structure { pub fn main() { let x: Box = box(HEAP) 2i; let y: Box = box 2i; - let z: Gc = box(GC) 2i; - let a: Gc = box(GC) Structure { - x: 10, - y: 20, - }; let b: Box = box()(1i + 2); let c = box()(3i + 4); - let d = box(GC)(5i + 6); } diff --git a/src/test/run-pass/newtype-struct-drop-run.rs b/src/test/run-pass/newtype-struct-drop-run.rs index 50971806a8746..8c35abad7f1e6 100644 --- a/src/test/run-pass/newtype-struct-drop-run.rs +++ b/src/test/run-pass/newtype-struct-drop-run.rs @@ -13,12 +13,11 @@ // Make sure the destructor is run for newtype structs. use std::cell::Cell; -use std::gc::{Gc, GC}; -struct Foo(Gc>); +struct Foo<'a>(&'a Cell); #[unsafe_destructor] -impl Drop for Foo { +impl<'a> Drop for Foo<'a> { fn drop(&mut self) { let Foo(i) = *self; i.set(23); @@ -26,7 +25,7 @@ impl Drop for Foo { } pub fn main() { - let y = box(GC) Cell::new(32); + let y = &Cell::new(32); { let _x = Foo(y); } diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs index a7d52b87e551a..0c66b139e7c2e 100644 --- a/src/test/run-pass/nullable-pointer-iotareduction.rs +++ b/src/test/run-pass/nullable-pointer-iotareduction.rs @@ -11,7 +11,6 @@ #![feature(macro_rules)] use std::{option, mem}; -use std::gc::{Gc, GC}; // Iota-reduction is a rule in the Calculus of (Co-)Inductive Constructions, // which "says that a destructor applied to an object built from a constructor @@ -76,7 +75,6 @@ macro_rules! check_type { pub fn main() { check_type!(&17: &int); check_type!(box 18: Box); - check_type!(box(GC) 19: Gc); check_type!("foo".to_string(): String); check_type!(vec!(20, 22): Vec ); let mint: uint = unsafe { mem::transmute(main) }; diff --git a/src/test/run-pass/nullable-pointer-size.rs b/src/test/run-pass/nullable-pointer-size.rs index 9dd65bdcb263e..5708310abadbf 100644 --- a/src/test/run-pass/nullable-pointer-size.rs +++ b/src/test/run-pass/nullable-pointer-size.rs @@ -11,7 +11,6 @@ #![feature(macro_rules)] use std::mem; -use std::gc::Gc; enum E { Thing(int, T), Nothing((), ((), ()), [i8, ..0]) } struct S(int, T); @@ -40,6 +39,5 @@ macro_rules! check_type { pub fn main() { check_type!(&'static int); check_type!(Box); - check_type!(Gc); check_type!(extern fn()); } diff --git a/src/test/run-pass/objects-owned-object-borrowed-method-header.rs b/src/test/run-pass/objects-owned-object-borrowed-method-header.rs deleted file mode 100644 index 60c46d17b0699..0000000000000 --- a/src/test/run-pass/objects-owned-object-borrowed-method-header.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{Gc, GC}; - -// Test invoked `&self` methods on owned objects where the values -// closed over contain managed values. This implies that the boxes -// will have headers that must be skipped over. - -trait FooTrait { - fn foo(&self) -> uint; -} - -struct BarStruct { - x: Gc -} - -impl FooTrait for BarStruct { - fn foo(&self) -> uint { - *self.x - } -} - -pub fn main() { - let foos: Vec> = vec!( - box BarStruct{ x: box(GC) 0 } as Box, - box BarStruct{ x: box(GC) 1 } as Box, - box BarStruct{ x: box(GC) 2 } as Box - ); - - for i in range(0u, foos.len()) { - assert_eq!(i, foos.get(i).foo()); - } -} diff --git a/src/test/run-pass/option-unwrap.rs b/src/test/run-pass/option-unwrap.rs index a6730d67ce0a4..8bdae89e523fd 100644 --- a/src/test/run-pass/option-unwrap.rs +++ b/src/test/run-pass/option-unwrap.rs @@ -11,16 +11,14 @@ #![feature(unsafe_destructor)] use std::cell::Cell; -use std::gc::{GC, Gc}; -struct dtor { - x: Gc>, +struct dtor<'a> { + x: &'a Cell, } #[unsafe_destructor] -impl Drop for dtor { +impl<'a> Drop for dtor<'a> { fn drop(&mut self) { - // abuse access to shared mutable state to write this code self.x.set(self.x.get() - 1); } } @@ -33,7 +31,7 @@ fn unwrap(o: Option) -> T { } pub fn main() { - let x = box(GC) Cell::new(1); + let x = &Cell::new(1); { let b = Some(dtor { x:x }); diff --git a/src/test/run-pass/output-slot-variants.rs b/src/test/run-pass/output-slot-variants.rs index 34dccb8186586..8a10cc8c1ef4b 100644 --- a/src/test/run-pass/output-slot-variants.rs +++ b/src/test/run-pass/output-slot-variants.rs @@ -11,30 +11,28 @@ #![allow(dead_assignment)] #![allow(unused_variable)] -use std::gc::{Gc, GC}; - struct A { a: int, b: int } -struct Abox { a: Gc, b: Gc } +struct Abox { a: Box, b: Box } -fn ret_int_i() -> int { return 10; } +fn ret_int_i() -> int { 10 } -fn ret_ext_i() -> Gc { return box(GC) 10; } +fn ret_ext_i() -> Box { box 10 } -fn ret_int_rec() -> A { return A {a: 10, b: 10}; } +fn ret_int_rec() -> A { A {a: 10, b: 10} } -fn ret_ext_rec() -> Gc { return box(GC) A {a: 10, b: 10}; } +fn ret_ext_rec() -> Box { box A {a: 10, b: 10} } -fn ret_ext_mem() -> Abox { return Abox {a: box(GC) 10, b: box(GC) 10}; } +fn ret_ext_mem() -> Abox { Abox {a: box 10, b: box 10} } -fn ret_ext_ext_mem() -> Gc { box(GC) Abox{a: box(GC) 10, b: box(GC) 10} } +fn ret_ext_ext_mem() -> Box { box Abox{a: box 10, b: box 10} } pub fn main() { let mut int_i: int; - let mut ext_i: Gc; + let mut ext_i: Box; let mut int_rec: A; - let mut ext_rec: Gc; + let mut ext_rec: Box; let mut ext_mem: Abox; - let mut ext_ext_mem: Gc; + let mut ext_ext_mem: Box; int_i = ret_int_i(); // initializing int_i = ret_int_i(); // non-initializing diff --git a/src/test/run-pass/packed-struct-size.rs b/src/test/run-pass/packed-struct-size.rs index cfea444d7ffc7..e6bfc8ec1a53d 100644 --- a/src/test/run-pass/packed-struct-size.rs +++ b/src/test/run-pass/packed-struct-size.rs @@ -10,7 +10,6 @@ use std::mem; -use std::gc::Gc; #[repr(packed)] struct S4 { @@ -48,7 +47,7 @@ struct S7_Option { a: f32, b: u8, c: u16, - d: Option> + d: Option> } // Placing packed structs in statics should work @@ -62,5 +61,5 @@ pub fn main() { assert_eq!(mem::size_of::(), 5); assert_eq!(mem::size_of::(), 13); assert_eq!(mem::size_of::(), 3 + mem::size_of::()); - assert_eq!(mem::size_of::(), 7 + mem::size_of::>>()); + assert_eq!(mem::size_of::(), 7 + mem::size_of::>>()); } diff --git a/src/test/run-pass/packed-tuple-struct-size.rs b/src/test/run-pass/packed-tuple-struct-size.rs index f23166288fb55..8967b07ca8823 100644 --- a/src/test/run-pass/packed-tuple-struct-size.rs +++ b/src/test/run-pass/packed-tuple-struct-size.rs @@ -9,7 +9,6 @@ // except according to those terms. -use std::gc::Gc; use std::mem; #[repr(packed)] @@ -30,7 +29,7 @@ enum Foo { struct S3_Foo(u8, u16, Foo); #[repr(packed)] -struct S7_Option(f32, u8, u16, Option>); +struct S7_Option(f32, u8, u16, Option>); pub fn main() { assert_eq!(mem::size_of::(), 4); @@ -43,5 +42,5 @@ pub fn main() { 3 + mem::size_of::()); assert_eq!(mem::size_of::(), - 7 + mem::size_of::>>()); + 7 + mem::size_of::>>()); } diff --git a/src/test/run-pass/pass-by-copy.rs b/src/test/run-pass/pass-by-copy.rs deleted file mode 100644 index 8820919242250..0000000000000 --- a/src/test/run-pass/pass-by-copy.rs +++ /dev/null @@ -1,26 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -extern crate debug; - -use std::gc::{GC, Gc}; - -fn magic(x: A) { println!("{:?}", x); } -fn magic2(x: Gc) { println!("{:?}", x); } - -struct A { a: Gc } - -pub fn main() { - let a = A {a: box(GC) 10}; - let b = box(GC) 10; - magic(a); magic(A {a: box(GC) 20}); - magic2(b); magic2(box(GC) 20); -} diff --git a/src/test/run-pass/rcvr-borrowed-to-region.rs b/src/test/run-pass/rcvr-borrowed-to-region.rs index b856386e1d353..8ad2dbc1acb75 100644 --- a/src/test/run-pass/rcvr-borrowed-to-region.rs +++ b/src/test/run-pass/rcvr-borrowed-to-region.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - trait get { fn get(self) -> int; } @@ -25,15 +23,6 @@ impl<'a> get for &'a int { } pub fn main() { - let x = box(GC) 6; - let y = x.get(); - assert_eq!(y, 6); - - let x = box(GC) 6; - let y = x.get(); - println!("y={}", y); - assert_eq!(y, 6); - let x = box 6; let y = x.get(); println!("y={}", y); diff --git a/src/test/run-pass/regions-borrow-at.rs b/src/test/run-pass/regions-borrow-at.rs index 15206f1c386d3..9a758c5d8ada4 100644 --- a/src/test/run-pass/regions-borrow-at.rs +++ b/src/test/run-pass/regions-borrow-at.rs @@ -9,14 +9,12 @@ // except according to those terms. -use std::gc::GC; - fn foo(x: &uint) -> uint { *x } pub fn main() { - let p = box(GC) 22u; + let p = box 22u; let r = foo(&*p); println!("r={}", r); assert_eq!(r, 22u); diff --git a/src/test/run-pass/regions-escape-into-other-fn.rs b/src/test/run-pass/regions-escape-into-other-fn.rs index 09d9008c0b64a..5b0b7cc5b4ef1 100644 --- a/src/test/run-pass/regions-escape-into-other-fn.rs +++ b/src/test/run-pass/regions-escape-into-other-fn.rs @@ -9,12 +9,10 @@ // except according to those terms. -use std::gc::GC; - fn foo(x: &uint) -> &uint { x } fn bar(x: &uint) -> uint { *x } pub fn main() { - let p = box(GC) 3u; + let p = box 3u; assert_eq!(bar(foo(&*p)), 3); } diff --git a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs index 4d4417189c908..1ecaf41702e06 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs @@ -8,12 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::gc::GC; - fn borrow(x: &T) -> &T {x} pub fn main() { - let x = box(GC) 3i; + let x = box 3i; loop { let y = borrow(&*x); assert_eq!(*x, *y); diff --git a/src/test/run-pass/regions-infer-borrow-scope.rs b/src/test/run-pass/regions-infer-borrow-scope.rs index 4c021b18ad858..d3dbca53f605f 100644 --- a/src/test/run-pass/regions-infer-borrow-scope.rs +++ b/src/test/run-pass/regions-infer-borrow-scope.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - struct Point {x: int, y: int} fn x_coord(p: &Point) -> &int { @@ -18,7 +16,7 @@ fn x_coord(p: &Point) -> &int { } pub fn main() { - let p = box(GC) Point {x: 3, y: 4}; + let p = box Point {x: 3, y: 4}; let xc = x_coord(&*p); assert_eq!(*xc, 3); } diff --git a/src/test/run-pass/resource-assign-is-not-copy.rs b/src/test/run-pass/resource-assign-is-not-copy.rs index 48022fefbbdba..5ea22ae76c2c0 100644 --- a/src/test/run-pass/resource-assign-is-not-copy.rs +++ b/src/test/run-pass/resource-assign-is-not-copy.rs @@ -10,36 +10,34 @@ #![feature(unsafe_destructor)] -extern crate debug; - use std::cell::Cell; -use std::gc::{Gc, GC}; -struct r { - i: Gc>, +#[deriving(Show)] +struct r<'a> { + i: &'a Cell, } #[unsafe_destructor] -impl Drop for r { +impl<'a> Drop for r<'a> { fn drop(&mut self) { self.i.set(self.i.get() + 1); } } -fn r(i: Gc>) -> r { +fn r(i: &Cell) -> r { r { i: i } } pub fn main() { - let i = box(GC) Cell::new(0i); + let i = &Cell::new(0i); // Even though these look like copies, they are guaranteed not to be { let a = r(i); let b = (a, 10i); let (c, _d) = b; - println!("{:?}", c); + println!("{}", c); } assert_eq!(i.get(), 1); } diff --git a/src/test/run-pass/resource-destruct.rs b/src/test/run-pass/resource-destruct.rs index ba6a285d652f9..71bf6cc626153 100644 --- a/src/test/run-pass/resource-destruct.rs +++ b/src/test/run-pass/resource-destruct.rs @@ -11,31 +11,30 @@ #![feature(unsafe_destructor)] use std::cell::Cell; -use std::gc::{GC, Gc}; -struct shrinky_pointer { - i: Gc>>, +struct shrinky_pointer<'a> { + i: &'a Cell, } #[unsafe_destructor] -impl Drop for shrinky_pointer { +impl<'a> Drop for shrinky_pointer<'a> { fn drop(&mut self) { println!("Hello!"); self.i.set(self.i.get() - 1); } } -impl shrinky_pointer { +impl<'a> shrinky_pointer<'a> { pub fn look_at(&self) -> int { return self.i.get(); } } -fn shrinky_pointer(i: Gc>>) -> shrinky_pointer { +fn shrinky_pointer(i: &Cell) -> shrinky_pointer { shrinky_pointer { i: i } } pub fn main() { - let my_total = box(GC) box(GC) Cell::new(10); + let my_total = &Cell::new(10); { let pt = shrinky_pointer(my_total); assert!((pt.look_at() == 10)); } println!("my_total = {}", my_total.get()); assert_eq!(my_total.get(), 9); diff --git a/src/test/run-pass/resource-in-struct.rs b/src/test/run-pass/resource-in-struct.rs index fd1efe1a20eee..8e798fc6a0d28 100644 --- a/src/test/run-pass/resource-in-struct.rs +++ b/src/test/run-pass/resource-in-struct.rs @@ -14,17 +14,16 @@ // variant use std::cell::Cell; -use std::gc::{Gc, GC}; -type closable = Gc>; +type closable<'a> = &'a Cell; -struct close_res { - i: closable, +struct close_res<'a> { + i: closable<'a>, } #[unsafe_destructor] -impl Drop for close_res { +impl<'a> Drop for close_res<'a> { fn drop(&mut self) { self.i.set(false); } @@ -41,7 +40,7 @@ enum option { none, some(T), } fn sink(_res: option) { } pub fn main() { - let c = box(GC) Cell::new(true); + let c = &Cell::new(true); sink(none); sink(some(close_res(c))); assert!(!c.get()); diff --git a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs index b58db67c0acf1..2d6da26df52a3 100644 --- a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs +++ b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs @@ -9,30 +9,26 @@ // except according to those terms. -extern crate debug; - // Exercises a bug in the shape code that was exposed // on x86_64: when there is an enum embedded in an // interior record which is then itself interior to // something else, shape calculations were off. -use std::gc::{Gc, GC}; - -#[deriving(Clone)] +#[deriving(Clone, Show)] enum opt_span { //hack (as opposed to option), to make `span` compile os_none, - os_some(Gc), + os_some(Box), } -#[deriving(Clone)] +#[deriving(Clone, Show)] struct Span { lo: uint, hi: uint, expanded_from: opt_span, } -#[deriving(Clone)] +#[deriving(Clone, Show)] struct Spanned { data: T, span: Span, @@ -40,17 +36,17 @@ struct Spanned { type ty_ = uint; -#[deriving(Clone)] +#[deriving(Clone, Show)] struct Path_ { global: bool, idents: Vec , - types: Vec>, + types: Vec>, } type path = Spanned; type ty = Spanned; -#[deriving(Clone)] +#[deriving(Clone, Show)] struct X { sp: Span, path: path, @@ -58,14 +54,14 @@ struct X { pub fn main() { let sp: Span = Span {lo: 57451u, hi: 57542u, expanded_from: os_none}; - let t: Gc = box(GC) Spanned { data: 3u, span: sp }; + let t: Box = box Spanned { data: 3u, span: sp.clone() }; let p_: Path_ = Path_ { global: true, idents: vec!("hi".to_string()), types: vec!(t), }; - let p: path = Spanned { data: p_, span: sp }; + let p: path = Spanned { data: p_, span: sp.clone() }; let x = X { sp: sp, path: p }; - println!("{:?}", x.path.clone()); - println!("{:?}", x.clone()); + println!("{}", x.path.clone()); + println!("{}", x.clone()); } diff --git a/src/test/run-pass/terminate-in-initializer.rs b/src/test/run-pass/terminate-in-initializer.rs index fcce05a7b09cb..41a9e6e53f251 100644 --- a/src/test/run-pass/terminate-in-initializer.rs +++ b/src/test/run-pass/terminate-in-initializer.rs @@ -13,22 +13,21 @@ // Don't try to clean up uninitialized locals use std::task; -use std::gc::{Gc}; -fn test_break() { loop { let _x: Gc = break; } } +fn test_break() { loop { let _x: Box = break; } } -fn test_cont() { let mut i = 0i; while i < 1 { i += 1; let _x: Gc = continue; } } +fn test_cont() { let mut i = 0i; while i < 1 { i += 1; let _x: Box = continue; } } -fn test_ret() { let _x: Gc = return; } +fn test_ret() { let _x: Box = return; } fn test_fail() { - fn f() { let _x: Gc = fail!(); } + fn f() { let _x: Box = fail!(); } task::try(proc() f() ); } fn test_fail_indirect() { fn f() -> ! { fail!(); } - fn g() { let _x: Gc = f(); } + fn g() { let _x: Box = f(); } task::try(proc() g() ); } diff --git a/src/test/run-pass/trait-cast.rs b/src/test/run-pass/trait-cast.rs deleted file mode 100644 index 30acf07ae60c7..0000000000000 --- a/src/test/run-pass/trait-cast.rs +++ /dev/null @@ -1,74 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-pretty FIXME(#14193) - - -// Test cyclic detector when using trait instances. - -use std::cell::RefCell; -use std::gc::{GC, Gc}; - -struct Tree(Gc>); -struct TreeR { - left: Option, - right: Option, - val: Box -} - -trait to_str { - fn to_str_(&self) -> String; -} - -impl to_str for Option { - fn to_str_(&self) -> String { - match *self { - None => { "none".to_string() } - Some(ref t) => format!("some({})", t.to_str_()), - } - } -} - -impl to_str for int { - fn to_str_(&self) -> String { - self.to_string() - } -} - -impl to_str for Tree { - fn to_str_(&self) -> String { - let Tree(t) = *self; - let this = t.borrow(); - let (l, r) = (this.left, this.right); - let val = &this.val; - format!("[{}, {}, {}]", val.to_str_(), l.to_str_(), r.to_str_()) - } -} - -fn foo(x: T) -> String { x.to_str_() } - -pub fn main() { - let t1 = Tree(box(GC) RefCell::new(TreeR{left: None, - right: None, - val: box 1i as Box})); - let t2 = Tree(box(GC) RefCell::new(TreeR{left: Some(t1), - right: Some(t1), - val: box 2i as Box})); - let expected = - "[2, some([1, none, none]), some([1, none, none])]".to_string(); - assert!(t2.to_str_() == expected); - assert!(foo(t2) == expected); - - { - let Tree(t1_) = t1; - let mut t1 = t1_.borrow_mut(); - t1.left = Some(t2); // create cycle - } -} diff --git a/src/test/run-pass/type-param-constraints.rs b/src/test/run-pass/type-param-constraints.rs index 41a8ca33a2ab9..7265ddf661501 100644 --- a/src/test/run-pass/type-param-constraints.rs +++ b/src/test/run-pass/type-param-constraints.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - fn p_foo(_pinned: T) { } fn s_foo(_shared: T) { } fn u_foo(_unique: T) { } @@ -31,15 +29,11 @@ fn r(i:int) -> r { pub fn main() { p_foo(r(10)); - p_foo(box(GC) r(10)); p_foo(box r(10)); - p_foo(box(GC) 10i); p_foo(box 10i); p_foo(10i); - s_foo(box(GC) r(10)); - s_foo(box(GC) 10i); s_foo(box 10i); s_foo(10i); diff --git a/src/test/run-pass/typeclasses-eq-example-static.rs b/src/test/run-pass/typeclasses-eq-example-static.rs index 0cd6210e13c79..6d8e7d1aaf3fd 100644 --- a/src/test/run-pass/typeclasses-eq-example-static.rs +++ b/src/test/run-pass/typeclasses-eq-example-static.rs @@ -12,17 +12,15 @@ // Example from lkuper's intern talk, August 2012 -- now with static // methods! -use std::gc::{GC, Gc}; - trait Equal { - fn isEq(a: Self, b: Self) -> bool; + fn isEq(a: &Self, b: &Self) -> bool; } enum Color { cyan, magenta, yellow, black } impl Equal for Color { - fn isEq(a: Color, b: Color) -> bool { - match (a, b) { + fn isEq(a: &Color, b: &Color) -> bool { + match (*a, *b) { (cyan, cyan) => { true } (magenta, magenta) => { true } (yellow, yellow) => { true } @@ -34,15 +32,15 @@ impl Equal for Color { enum ColorTree { leaf(Color), - branch(Gc, Gc) + branch(Box, Box) } impl Equal for ColorTree { - fn isEq(a: ColorTree, b: ColorTree) -> bool { + fn isEq(a: &ColorTree, b: &ColorTree) -> bool { match (a, b) { - (leaf(x), leaf(y)) => { Equal::isEq(x, y) } - (branch(l1, r1), branch(l2, r2)) => { - Equal::isEq(*l1, *l2) && Equal::isEq(*r1, *r2) + (&leaf(x), &leaf(y)) => { Equal::isEq(&x, &y) } + (&branch(ref l1, ref r1), &branch(ref l2, ref r2)) => { + Equal::isEq(&**l1, &**l2) && Equal::isEq(&**r1, &**r2) } _ => { false } } @@ -50,19 +48,19 @@ impl Equal for ColorTree { } pub fn main() { - assert!(Equal::isEq(cyan, cyan)); - assert!(Equal::isEq(magenta, magenta)); - assert!(!Equal::isEq(cyan, yellow)); - assert!(!Equal::isEq(magenta, cyan)); + assert!(Equal::isEq(&cyan, &cyan)); + assert!(Equal::isEq(&magenta, &magenta)); + assert!(!Equal::isEq(&cyan, &yellow)); + assert!(!Equal::isEq(&magenta, &cyan)); - assert!(Equal::isEq(leaf(cyan), leaf(cyan))); - assert!(!Equal::isEq(leaf(cyan), leaf(yellow))); + assert!(Equal::isEq(&leaf(cyan), &leaf(cyan))); + assert!(!Equal::isEq(&leaf(cyan), &leaf(yellow))); - assert!(Equal::isEq(branch(box(GC) leaf(magenta), box(GC) leaf(cyan)), - branch(box(GC) leaf(magenta), box(GC) leaf(cyan)))); + assert!(Equal::isEq(&branch(box leaf(magenta), box leaf(cyan)), + &branch(box leaf(magenta), box leaf(cyan)))); - assert!(!Equal::isEq(branch(box(GC) leaf(magenta), box(GC) leaf(cyan)), - branch(box(GC) leaf(magenta), box(GC) leaf(magenta)))); + assert!(!Equal::isEq(&branch(box leaf(magenta), box leaf(cyan)), + &branch(box leaf(magenta), box leaf(magenta)))); println!("Assertions all succeeded!"); } diff --git a/src/test/run-pass/typeclasses-eq-example.rs b/src/test/run-pass/typeclasses-eq-example.rs index 0a77824cf47f7..cbb85b2b7b814 100644 --- a/src/test/run-pass/typeclasses-eq-example.rs +++ b/src/test/run-pass/typeclasses-eq-example.rs @@ -11,17 +11,15 @@ // Example from lkuper's intern talk, August 2012. -use std::gc::{GC, Gc}; - trait Equal { - fn isEq(&self, a: Self) -> bool; + fn isEq(&self, a: &Self) -> bool; } enum Color { cyan, magenta, yellow, black } impl Equal for Color { - fn isEq(&self, a: Color) -> bool { - match (*self, a) { + fn isEq(&self, a: &Color) -> bool { + match (*self, *a) { (cyan, cyan) => { true } (magenta, magenta) => { true } (yellow, yellow) => { true } @@ -33,15 +31,15 @@ impl Equal for Color { enum ColorTree { leaf(Color), - branch(Gc, Gc) + branch(Box, Box) } impl Equal for ColorTree { - fn isEq(&self, a: ColorTree) -> bool { - match (*self, a) { - (leaf(x), leaf(y)) => { x.isEq(y) } - (branch(l1, r1), branch(l2, r2)) => { - (*l1).isEq(*l2) && (*r1).isEq(*r2) + fn isEq(&self, a: &ColorTree) -> bool { + match (self, a) { + (&leaf(x), &leaf(y)) => { x.isEq(&y) } + (&branch(ref l1, ref r1), &branch(ref l2, ref r2)) => { + (&**l1).isEq(&**l2) && (&**r1).isEq(&**r2) } _ => { false } } @@ -49,19 +47,19 @@ impl Equal for ColorTree { } pub fn main() { - assert!(cyan.isEq(cyan)); - assert!(magenta.isEq(magenta)); - assert!(!cyan.isEq(yellow)); - assert!(!magenta.isEq(cyan)); + assert!(cyan.isEq(&cyan)); + assert!(magenta.isEq(&magenta)); + assert!(!cyan.isEq(&yellow)); + assert!(!magenta.isEq(&cyan)); - assert!(leaf(cyan).isEq(leaf(cyan))); - assert!(!leaf(cyan).isEq(leaf(yellow))); + assert!(leaf(cyan).isEq(&leaf(cyan))); + assert!(!leaf(cyan).isEq(&leaf(yellow))); - assert!(branch(box(GC) leaf(magenta), box(GC) leaf(cyan)) - .isEq(branch(box(GC) leaf(magenta), box(GC) leaf(cyan)))); + assert!(branch(box leaf(magenta), box leaf(cyan)) + .isEq(&branch(box leaf(magenta), box leaf(cyan)))); - assert!(!branch(box(GC) leaf(magenta), box(GC) leaf(cyan)) - .isEq(branch(box(GC) leaf(magenta), box(GC) leaf(magenta)))); + assert!(!branch(box leaf(magenta), box leaf(cyan)) + .isEq(&branch(box leaf(magenta), box leaf(magenta)))); println!("Assertions all succeeded!"); } diff --git a/src/test/run-pass/uniq-cc-generic.rs b/src/test/run-pass/uniq-cc-generic.rs deleted file mode 100644 index e342dcb365dfa..0000000000000 --- a/src/test/run-pass/uniq-cc-generic.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-pretty FIXME(#14193) - - -use std::cell::RefCell; -use std::gc::{Gc, GC}; - -enum maybe_pointy { - none, - p(Gc>), -} - -struct Pointy { - a : maybe_pointy, - d : proc():Send -> uint, -} - -fn make_uniq_closure(a: A) -> proc():Send -> uint { - proc() { &a as *const A as uint } -} - -fn empty_pointy() -> Gc> { - return box(GC) RefCell::new(Pointy { - a : none, - d : make_uniq_closure("hi".to_string()) - }) -} - -pub fn main() { - let v = empty_pointy(); - { - let mut vb = v.borrow_mut(); - vb.a = p(v); - } -} diff --git a/src/test/run-pass/uniq-cc.rs b/src/test/run-pass/uniq-cc.rs deleted file mode 100644 index c7aca64c7cb95..0000000000000 --- a/src/test/run-pass/uniq-cc.rs +++ /dev/null @@ -1,40 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::cell::RefCell; -use std::gc::{Gc, GC}; - -enum maybe_pointy { - none, - p(Gc>), -} - -struct Pointy { - a : maybe_pointy, - c : Box, - d : proc():Send->(), -} - -fn empty_pointy() -> Gc> { - return box(GC) RefCell::new(Pointy { - a : none, - c : box 22, - d : proc() {}, - }) -} - -pub fn main() { - let v = empty_pointy(); - { - let mut vb = v.borrow_mut(); - vb.a = p(v); - } -} diff --git a/src/test/run-pass/unique-assign-generic.rs b/src/test/run-pass/unique-assign-generic.rs index 478565c86fd48..493ec8ddc207d 100644 --- a/src/test/run-pass/unique-assign-generic.rs +++ b/src/test/run-pass/unique-assign-generic.rs @@ -9,8 +9,6 @@ // except according to those terms. -use std::gc::GC; - fn f(t: T) -> T { let t1 = t; t1 @@ -19,6 +17,4 @@ fn f(t: T) -> T { pub fn main() { let t = f(box 100i); assert_eq!(t, box 100i); - let t = f(box box(GC) vec!(100i)); - assert_eq!(t, box box(GC) vec!(100i)); } diff --git a/src/test/run-pass/unwind-box.rs b/src/test/run-pass/unwind-box.rs deleted file mode 100644 index 70c8c5b64e408..0000000000000 --- a/src/test/run-pass/unwind-box.rs +++ /dev/null @@ -1,22 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::task; -use std::gc::GC; - -fn f() { - let _a = box(GC) 0i; - fail!(); -} - -pub fn main() { - task::spawn(f); -} diff --git a/src/test/run-pass/unwind-resource2.rs b/src/test/run-pass/unwind-resource2.rs deleted file mode 100644 index 6d04c0e26ad0c..0000000000000 --- a/src/test/run-pass/unwind-resource2.rs +++ /dev/null @@ -1,38 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(unsafe_destructor)] - -use std::task; -use std::gc::{Gc, GC}; - -struct complainer { - c: Gc, -} - -#[unsafe_destructor] -impl Drop for complainer { - fn drop(&mut self) {} -} - -fn complainer(c: Gc) -> complainer { - complainer { - c: c - } -} - -fn f() { - let _c = complainer(box(GC) 0); - fail!(); -} - -pub fn main() { - task::spawn(f); -} diff --git a/src/test/run-pass/vec-drop.rs b/src/test/run-pass/vec-drop.rs deleted file mode 100644 index 6cc95a2e548b1..0000000000000 --- a/src/test/run-pass/vec-drop.rs +++ /dev/null @@ -1,23 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -use std::gc::{GC, Gc}; - -struct Pair { x: int, y: int } - -pub fn main() { - // This just tests whether the vec leaks its members. - - let _pvec: Vec> = - vec!(box(GC) Pair{x: 1, y: 2}, - box(GC) Pair{x: 3, y: 4}, - box(GC) Pair{x: 5, y: 6}); -} diff --git a/src/test/run-pass/vec-slice-drop.rs b/src/test/run-pass/vec-slice-drop.rs index 42132f0a12f4b..498ec0e8fbaf1 100644 --- a/src/test/run-pass/vec-slice-drop.rs +++ b/src/test/run-pass/vec-slice-drop.rs @@ -11,28 +11,27 @@ #![feature(unsafe_destructor)] use std::cell::Cell; -use std::gc::{Gc, GC}; // Make sure that destructors get run on slice literals -struct foo { - x: Gc>, +struct foo<'a> { + x: &'a Cell, } #[unsafe_destructor] -impl Drop for foo { +impl<'a> Drop for foo<'a> { fn drop(&mut self) { self.x.set(self.x.get() + 1); } } -fn foo(x: Gc>) -> foo { +fn foo(x: &Cell) -> foo { foo { x: x } } pub fn main() { - let x = box(GC) Cell::new(0); + let x = &Cell::new(0); { let l = &[foo(x)]; assert_eq!(l[0].x.get(), 0); diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index e8489e7c386cb..72204c28f82ad 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -11,7 +11,6 @@ use std::cell::Cell; use std::mem::swap; -use std::gc::{Gc, GC}; // Just a grab bag of stuff that you wouldn't want to actually write. @@ -23,10 +22,10 @@ fn funny() { } fn what() { - fn the(x: Gc>) { + fn the(x: &Cell) { return while !x.get() { x.set(true); }; } - let i = box(GC) Cell::new(false); + let i = &Cell::new(false); let dont = {||the(i)}; dont(); assert!((i.get()));