Skip to content

Commit

Permalink
rustc: remove support for Gc.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Oct 2, 2014
1 parent d1a57e4 commit 8a91d33
Show file tree
Hide file tree
Showing 43 changed files with 55 additions and 565 deletions.
20 changes: 1 addition & 19 deletions src/librustc/lint/builtin.rs
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
1 change: 0 additions & 1 deletion src/librustc/metadata/tydecode.rs
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
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
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
1 change: 0 additions & 1 deletion src/librustc/middle/borrowck/gather_loans/gather_moves.rs
Expand Up @@ -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, .. }) => {
Expand Down
4 changes: 1 addition & 3 deletions src/librustc/middle/borrowck/gather_loans/lifetime.rs
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/librustc/middle/borrowck/gather_loans/move_error.rs
Expand Up @@ -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, .. }) => {
Expand Down
5 changes: 1 addition & 4 deletions src/librustc/middle/borrowck/gather_loans/restrictions.rs
Expand Up @@ -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<T> implementation.
let result = self.restrict(cmt_base);
Expand Down
5 changes: 0 additions & 5 deletions src/librustc/middle/borrowck/mod.rs
Expand Up @@ -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,
Expand Down
7 changes: 1 addition & 6 deletions src/librustc/middle/check_match.rs
Expand Up @@ -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![])
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/intrinsicck.rs
Expand Up @@ -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(_) => {
Expand Down
4 changes: 0 additions & 4 deletions src/librustc/middle/lang_items.rs
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
17 changes: 1 addition & 16 deletions src/librustc/middle/mem_categorization.rs
Expand Up @@ -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)
Expand Down Expand Up @@ -191,10 +190,6 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
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)))
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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))
}
}
Expand Down Expand Up @@ -1237,7 +1229,6 @@ pub enum InteriorSafety {
}

pub enum AliasableReason {
AliasableManaged,
AliasableBorrowed,
AliasableOther,
AliasableStatic(InteriorSafety),
Expand All @@ -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(..) => {
Expand Down Expand Up @@ -1320,10 +1310,6 @@ impl cmt_ {
}
}

cat_deref(_, _, GcPtr) => {
Some(AliasableManaged)
}

cat_deref(_, _, BorrowedPtr(ty::ImmBorrow, _)) |
cat_deref(_, _, Implicit(ty::ImmBorrow, _)) => {
Some(AliasableBorrowed)
Expand Down Expand Up @@ -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, _) |
Expand Down
5 changes: 0 additions & 5 deletions src/librustc/middle/traits/coherence.rs
Expand Up @@ -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, .. }) => {
Expand Down
17 changes: 0 additions & 17 deletions src/librustc/middle/traits/select.rs
Expand Up @@ -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<T>
match bound {
ty::BoundCopy => {
Expand Down
3 changes: 0 additions & 3 deletions src/librustc/middle/trans/adt.rs
Expand Up @@ -321,9 +321,6 @@ impl Case {
_ => return Some(ThinPointer(i))
},

// Gc<T> is just a pointer
ty::ty_box(..) => return Some(ThinPointer(i)),

// Functions are just pointers
ty::ty_bare_fn(..) => return Some(ThinPointer(i)),

Expand Down
30 changes: 0 additions & 30 deletions src/librustc/middle/trans/base.rs
Expand Up @@ -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<tydesc_info> {
Expand Down
7 changes: 0 additions & 7 deletions src/librustc/middle/trans/cleanup.rs
Expand Up @@ -960,7 +960,6 @@ impl Cleanup for DropValue {
}

pub enum Heap {
HeapManaged,
HeapExchange
}

Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/common.rs
Expand Up @@ -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);
Expand Down

0 comments on commit 8a91d33

Please sign in to comment.