Skip to content

Commit

Permalink
rollup merge of rust-lang#17666 : eddyb/take-garbage-out
Browse files Browse the repository at this point in the history
Conflicts:
	src/libcollections/lib.rs
	src/libcore/lib.rs
	src/librustdoc/lib.rs
	src/librustrt/lib.rs
	src/libserialize/lib.rs
	src/libstd/lib.rs
	src/test/run-pass/issue-8898.rs
  • Loading branch information
alexcrichton committed Oct 2, 2014
2 parents ebe4da9 + 58bea31 commit 7ae802f
Show file tree
Hide file tree
Showing 287 changed files with 435 additions and 5,088 deletions.
13 changes: 0 additions & 13 deletions src/doc/guide-pointers.md
Original file line number Diff line number Diff line change
Expand Up @@ -632,19 +632,6 @@ This part is coming soon.

This part is coming soon.

# Gc

The `Gc<T>` 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<T>` type.

# Raw Pointers

This part is coming soon.
Expand Down
1 change: 0 additions & 1 deletion src/doc/guide-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ list):
* Task synchronization
* Task-local storage
* Logging
* Local heaps (GC heaps)
* Task unwinding

## What is the runtime accomplishing?
Expand Down
4 changes: 1 addition & 3 deletions src/doc/guide-unsafe.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ pub struct Unique<T> {
// 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<T: Send> Unique<T> {
pub fn new(value: T) -> Unique<T> {
unsafe {
Expand Down
2 changes: 1 addition & 1 deletion src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 0 additions & 8 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
30 changes: 0 additions & 30 deletions src/liballoc/util.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
html_root_url = "http://doc.rust-lang.org/master/",
html_playground_url = "http://play.rust-lang.org/")]

#![feature(macro_rules, managed_boxes, default_type_params, phase, globs)]
#![feature(macro_rules, default_type_params, phase, globs)]
#![feature(unsafe_destructor, import_shadowing)]
#![no_std]

Expand Down
44 changes: 0 additions & 44 deletions src/libcollections/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ impl<T: fmt::Show> fmt::Show for RingBuf<T> {
mod tests {
use std::fmt::Show;
use std::prelude::*;
use std::gc::{GC, Gc};
use std::hash;
use test::Bencher;
use test;
Expand Down Expand Up @@ -587,43 +586,6 @@ mod tests {
assert_eq!(*d.get(3), 4);
}

#[test]
#[allow(deprecated)]
fn test_boxes() {
let a: Gc<int> = box(GC) 5;
let b: Gc<int> = box(GC) 72;
let c: Gc<int> = box(GC) 64;
let d: Gc<int> = 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<T:Clone + PartialEq + Show>(a: T, b: T, c: T, d: T) {
let mut deq = RingBuf::new();
Expand Down Expand Up @@ -755,12 +717,6 @@ mod tests {
test_parameterized::<int>(5, 72, 64, 175);
}

#[test]
fn test_param_at_int() {
test_parameterized::<Gc<int>>(box(GC) 5, box(GC) 72,
box(GC) 64, box(GC) 175);
}

#[test]
fn test_param_taggy() {
test_parameterized::<Taggy>(One(1), Two(1, 2), Three(1, 2, 3), Two(17, 42));
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
html_playground_url = "http://play.rust-lang.org/")]

#![no_std]
#![feature(globs, intrinsics, lang_items, macro_rules, managed_boxes, phase)]
#![feature(globs, intrinsics, lang_items, macro_rules, phase)]
#![feature(simd, unsafe_destructor)]
#![deny(missing_doc)]

Expand Down
9 changes: 0 additions & 9 deletions src/libcore/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@

use mem;

/// The representation of `std::gc::Gc`.
pub struct GcBox<T> {
pub ref_count: uint,
pub drop_glue: fn(ptr: *mut u8),
pub prev: *mut GcBox<T>,
pub next: *mut GcBox<T>,
pub data: T,
}

/// The representation of a Rust slice
pub struct Slice<T> {
pub data: *const T,
Expand Down
5 changes: 2 additions & 3 deletions src/libcoretest/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,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 {
Expand Down
2 changes: 1 addition & 1 deletion src/libdebug/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions src/libdebug/reflect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -194,9 +193,9 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
}

fn visit_box(&mut self, mtbl: uint, inner: *const TyDesc) -> bool {
self.align_to::<Gc<u8>>();
self.align_to::<Box<u8>>();
if ! self.inner.visit_box(mtbl, inner) { return false; }
self.bump_past::<Gc<u8>>();
self.bump_past::<Box<u8>>();
true
}

Expand Down
14 changes: 3 additions & 11 deletions src/libdebug/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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: &T, e:&str) {
let mut m = io::MemWriter::new();
Expand All @@ -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;
Expand All @@ -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}");

Expand Down
2 changes: 1 addition & 1 deletion src/libfourcc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/libhexfloat/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/libregex_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
22 changes: 2 additions & 20 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -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
}

Expand Down
1 change: 0 additions & 1 deletion src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))),
'&' => {
Expand Down
1 change: 0 additions & 1 deletion src/librustc/metadata/tyencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
5 changes: 0 additions & 5 deletions src/librustc/middle/borrowck/check_loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(..)) |
Expand Down
Loading

0 comments on commit 7ae802f

Please sign in to comment.