Skip to content

Commit 8a91d33

Browse files
committed
rustc: remove support for Gc.
1 parent d1a57e4 commit 8a91d33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+55
-565
lines changed

src/librustc/lint/builtin.rs

+1-19
Original file line numberDiff line numberDiff line change
@@ -412,26 +412,16 @@ impl LintPass for CTypes {
412412
}
413413
}
414414

415-
declare_lint!(MANAGED_HEAP_MEMORY, Allow,
416-
"use of managed (@ type) heap memory")
417-
418415
declare_lint!(OWNED_HEAP_MEMORY, Allow,
419416
"use of owned (Box type) heap memory")
420417

421-
declare_lint!(HEAP_MEMORY, Allow,
422-
"use of any (Box type or @ type) heap memory")
423-
424418
pub struct HeapMemory;
425419

426420
impl HeapMemory {
427421
fn check_heap_type(&self, cx: &Context, span: Span, ty: ty::t) {
428-
let mut n_box = 0i;
429422
let mut n_uniq = 0i;
430423
ty::fold_ty(cx.tcx, ty, |t| {
431424
match ty::get(t).sty {
432-
ty::ty_box(_) => {
433-
n_box += 1;
434-
}
435425
ty::ty_uniq(_) |
436426
ty::ty_closure(box ty::ClosureTy {
437427
store: ty::UniqTraitStore,
@@ -449,21 +439,13 @@ impl HeapMemory {
449439
let s = ty_to_string(cx.tcx, ty);
450440
let m = format!("type uses owned (Box type) pointers: {}", s);
451441
cx.span_lint(OWNED_HEAP_MEMORY, span, m.as_slice());
452-
cx.span_lint(HEAP_MEMORY, span, m.as_slice());
453-
}
454-
455-
if n_box > 0 {
456-
let s = ty_to_string(cx.tcx, ty);
457-
let m = format!("type uses managed (@ type) pointers: {}", s);
458-
cx.span_lint(MANAGED_HEAP_MEMORY, span, m.as_slice());
459-
cx.span_lint(HEAP_MEMORY, span, m.as_slice());
460442
}
461443
}
462444
}
463445

464446
impl LintPass for HeapMemory {
465447
fn get_lints(&self) -> LintArray {
466-
lint_array!(MANAGED_HEAP_MEMORY, OWNED_HEAP_MEMORY, HEAP_MEMORY)
448+
lint_array!(OWNED_HEAP_MEMORY)
467449
}
468450

469451
fn check_item(&mut self, cx: &Context, it: &ast::Item) {

src/librustc/metadata/tydecode.rs

-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
397397
assert_eq!(next(st), '|');
398398
return ty::mk_param(st.tcx, space, index, did);
399399
}
400-
'@' => return ty::mk_box(st.tcx, parse_ty(st, |x,y| conv(x,y))),
401400
'~' => return ty::mk_uniq(st.tcx, parse_ty(st, |x,y| conv(x,y))),
402401
'*' => return ty::mk_ptr(st.tcx, parse_mt(st, |x,y| conv(x,y))),
403402
'&' => {

src/librustc/metadata/tyencode.rs

-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ fn enc_sty(w: &mut SeekableMemWriter, cx: &ctxt, st: &ty::sty) {
244244
for t in ts.iter() { enc_ty(w, cx, *t); }
245245
mywrite!(w, "]");
246246
}
247-
ty::ty_box(typ) => { mywrite!(w, "@"); enc_ty(w, cx, typ); }
248247
ty::ty_uniq(typ) => { mywrite!(w, "~"); enc_ty(w, cx, typ); }
249248
ty::ty_ptr(mt) => { mywrite!(w, "*"); enc_mt(w, cx, mt); }
250249
ty::ty_rptr(r, mt) => {

src/librustc/middle/borrowck/check_loans.rs

-5
Original file line numberDiff line numberDiff line change
@@ -815,11 +815,6 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
815815
return;
816816
}
817817

818-
mc::cat_deref(_, _, mc::GcPtr) => {
819-
assert_eq!(cmt.mutbl, mc::McImmutable);
820-
return;
821-
}
822-
823818
mc::cat_rvalue(..) |
824819
mc::cat_static_item |
825820
mc::cat_deref(_, _, mc::UnsafePtr(..)) |

src/librustc/middle/borrowck/gather_loans/gather_moves.rs

-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ fn check_and_get_illegal_move_origin(bccx: &BorrowckCtxt,
132132
match cmt.cat {
133133
mc::cat_deref(_, _, mc::BorrowedPtr(..)) |
134134
mc::cat_deref(_, _, mc::Implicit(..)) |
135-
mc::cat_deref(_, _, mc::GcPtr) |
136135
mc::cat_deref(_, _, mc::UnsafePtr(..)) |
137136
mc::cat_upvar(..) | mc::cat_static_item |
138137
mc::cat_copied_upvar(mc::CopiedUpvar { onceness: ast::Many, .. }) => {

src/librustc/middle/borrowck/gather_loans/lifetime.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
8282

8383
mc::cat_downcast(ref base) |
8484
mc::cat_deref(ref base, _, mc::OwnedPtr) | // L-Deref-Send
85-
mc::cat_interior(ref base, _) | // L-Field
86-
mc::cat_deref(ref base, _, mc::GcPtr) => {
85+
mc::cat_interior(ref base, _) => { // L-Field
8786
self.check(base, discr_scope)
8887
}
8988

@@ -185,7 +184,6 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> {
185184
}
186185
mc::cat_downcast(ref cmt) |
187186
mc::cat_deref(ref cmt, _, mc::OwnedPtr) |
188-
mc::cat_deref(ref cmt, _, mc::GcPtr) |
189187
mc::cat_interior(ref cmt, _) |
190188
mc::cat_discr(ref cmt, _) => {
191189
self.scope(cmt)

src/librustc/middle/borrowck/gather_loans/move_error.rs

-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ fn report_cannot_move_out_of(bccx: &BorrowckCtxt, move_from: mc::cmt) {
114114
match move_from.cat {
115115
mc::cat_deref(_, _, mc::BorrowedPtr(..)) |
116116
mc::cat_deref(_, _, mc::Implicit(..)) |
117-
mc::cat_deref(_, _, mc::GcPtr) |
118117
mc::cat_deref(_, _, mc::UnsafePtr(..)) |
119118
mc::cat_upvar(..) | mc::cat_static_item |
120119
mc::cat_copied_upvar(mc::CopiedUpvar { onceness: ast::Many, .. }) => {

src/librustc/middle/borrowck/gather_loans/restrictions.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,13 @@ impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> {
101101
self.extend(result, cmt.mutbl, LpInterior(i))
102102
}
103103

104-
mc::cat_deref(cmt_base, _, pk @ mc::OwnedPtr) |
105-
mc::cat_deref(cmt_base, _, pk @ mc::GcPtr) => {
104+
mc::cat_deref(cmt_base, _, pk @ mc::OwnedPtr) => {
106105
// R-Deref-Send-Pointer
107106
//
108107
// When we borrow the interior of an owned pointer, we
109108
// cannot permit the base to be mutated, because that
110109
// would cause the unique pointer to be freed.
111110
//
112-
// For a managed pointer, the rules are basically the
113-
// same, because this could be the last ref.
114111
// Eventually we should make these non-special and
115112
// just rely on Deref<T> implementation.
116113
let result = self.restrict(cmt_base);

src/librustc/middle/borrowck/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -730,11 +730,6 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
730730
span,
731731
format!("{} in a static location", prefix).as_slice());
732732
}
733-
mc::AliasableManaged => {
734-
self.tcx.sess.span_err(
735-
span,
736-
format!("{} in a `Gc` pointer", prefix).as_slice());
737-
}
738733
mc::AliasableBorrowed => {
739734
self.tcx.sess.span_err(
740735
span,

src/librustc/middle/check_match.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,6 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
440440
}
441441
}
442442

443-
ty::ty_box(_) => {
444-
assert_eq!(pats_len, 1);
445-
PatBox(pats.nth(0).unwrap())
446-
}
447-
448443
ty::ty_vec(_, Some(len)) => {
449444
assert_eq!(pats_len, len);
450445
PatVec(pats.collect(), None, vec![])
@@ -681,7 +676,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
681676
pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: ty::t) -> uint {
682677
match ty::get(ty).sty {
683678
ty::ty_tup(ref fs) => fs.len(),
684-
ty::ty_box(_) | ty::ty_uniq(_) => 1u,
679+
ty::ty_uniq(_) => 1u,
685680
ty::ty_rptr(_, ty::mt { ty: ty, .. }) => match ty::get(ty).sty {
686681
ty::ty_vec(_, None) => match *ctor {
687682
Slice(length) => length,

src/librustc/middle/intrinsicck.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ fn type_size_is_affected_by_type_parameters(tcx: &ty::ctxt, typ: ty::t)
2828
let mut result = false;
2929
ty::maybe_walk_ty(typ, |typ| {
3030
match ty::get(typ).sty {
31-
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_ptr(_) |
32-
ty::ty_rptr(..) | ty::ty_bare_fn(..) | ty::ty_closure(..) => {
31+
ty::ty_uniq(_) | ty::ty_ptr(_) | ty::ty_rptr(..) |
32+
ty::ty_bare_fn(..) | ty::ty_closure(..) => {
3333
false
3434
}
3535
ty::ty_param(_) => {

src/librustc/middle/lang_items.rs

-4
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,6 @@ lets_do_this! {
279279

280280
ExchangeMallocFnLangItem, "exchange_malloc", exchange_malloc_fn;
281281
ExchangeFreeFnLangItem, "exchange_free", exchange_free_fn;
282-
MallocFnLangItem, "malloc", malloc_fn;
283-
FreeFnLangItem, "free", free_fn;
284282
StrDupUniqFnLangItem, "strdup_uniq", strdup_uniq_fn;
285283

286284
StartFnLangItem, "start", start_fn;
@@ -293,9 +291,7 @@ lets_do_this! {
293291

294292
EhPersonalityLangItem, "eh_personality", eh_personality;
295293

296-
ManagedHeapLangItem, "managed_heap", managed_heap;
297294
ExchangeHeapLangItem, "exchange_heap", exchange_heap;
298-
GcLangItem, "gc", gc;
299295
OwnedBoxLangItem, "owned_box", owned_box;
300296

301297
CovariantTypeItem, "covariant_type", covariant_type;

src/librustc/middle/mem_categorization.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ pub struct CopiedUpvar {
104104
#[deriving(Clone, PartialEq, Eq, Hash)]
105105
pub enum PointerKind {
106106
OwnedPtr,
107-
GcPtr,
108107
BorrowedPtr(ty::BorrowKind, ty::Region),
109108
Implicit(ty::BorrowKind, ty::Region), // Implicit deref of a borrowed ptr.
110109
UnsafePtr(ast::Mutability)
@@ -191,10 +190,6 @@ pub fn opt_deref_kind(t: ty::t) -> Option<deref_kind> {
191190
Some(deref_ptr(BorrowedPtr(ty::ImmBorrow, r)))
192191
}
193192

194-
ty::ty_box(..) => {
195-
Some(deref_ptr(GcPtr))
196-
}
197-
198193
ty::ty_ptr(ref mt) => {
199194
Some(deref_ptr(UnsafePtr(mt.mutbl)))
200195
}
@@ -302,9 +297,6 @@ impl MutabilityCategory {
302297
BorrowedPtr(borrow_kind, _) | Implicit(borrow_kind, _) => {
303298
MutabilityCategory::from_borrow_kind(borrow_kind)
304299
}
305-
GcPtr => {
306-
McImmutable
307-
}
308300
UnsafePtr(m) => {
309301
MutabilityCategory::from_mutbl(m)
310302
}
@@ -1200,7 +1192,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
12001192
Implicit(..) => {
12011193
"dereference (dereference is implicit, due to indexing)".to_string()
12021194
}
1203-
OwnedPtr | GcPtr => format!("dereference of `{}`", ptr_sigil(pk)),
1195+
OwnedPtr => format!("dereference of `{}`", ptr_sigil(pk)),
12041196
_ => format!("dereference of `{}`-pointer", ptr_sigil(pk))
12051197
}
12061198
}
@@ -1237,7 +1229,6 @@ pub enum InteriorSafety {
12371229
}
12381230

12391231
pub enum AliasableReason {
1240-
AliasableManaged,
12411232
AliasableBorrowed,
12421233
AliasableOther,
12431234
AliasableStatic(InteriorSafety),
@@ -1256,7 +1247,6 @@ impl cmt_ {
12561247
cat_copied_upvar(..) |
12571248
cat_local(..) |
12581249
cat_deref(_, _, UnsafePtr(..)) |
1259-
cat_deref(_, _, GcPtr(..)) |
12601250
cat_deref(_, _, BorrowedPtr(..)) |
12611251
cat_deref(_, _, Implicit(..)) |
12621252
cat_upvar(..) => {
@@ -1320,10 +1310,6 @@ impl cmt_ {
13201310
}
13211311
}
13221312

1323-
cat_deref(_, _, GcPtr) => {
1324-
Some(AliasableManaged)
1325-
}
1326-
13271313
cat_deref(_, _, BorrowedPtr(ty::ImmBorrow, _)) |
13281314
cat_deref(_, _, Implicit(ty::ImmBorrow, _)) => {
13291315
Some(AliasableBorrowed)
@@ -1371,7 +1357,6 @@ impl Repr for categorization {
13711357
pub fn ptr_sigil(ptr: PointerKind) -> &'static str {
13721358
match ptr {
13731359
OwnedPtr => "Box",
1374-
GcPtr => "Gc",
13751360
BorrowedPtr(ty::ImmBorrow, _) |
13761361
Implicit(ty::ImmBorrow, _) => "&",
13771362
BorrowedPtr(ty::MutBorrow, _) |

src/librustc/middle/traits/coherence.rs

-5
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,6 @@ pub fn ty_is_local(tcx: &ty::ctxt,
104104
krate == Some(ast::LOCAL_CRATE) || ty_is_local(tcx, t)
105105
}
106106

107-
ty::ty_box(t) => {
108-
let krate = tcx.lang_items.gc().map(|d| d.krate);
109-
krate == Some(ast::LOCAL_CRATE) || ty_is_local(tcx, t)
110-
}
111-
112107
ty::ty_vec(t, _) |
113108
ty::ty_ptr(ty::mt { ty: t, .. }) |
114109
ty::ty_rptr(_, ty::mt { ty: t, .. }) => {

src/librustc/middle/traits/select.rs

-17
Original file line numberDiff line numberDiff line change
@@ -713,23 +713,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
713713
ok(self, Always)
714714
}
715715

716-
ty::ty_box(_) => {
717-
match bound {
718-
ty::BoundSync |
719-
ty::BoundSend |
720-
ty::BoundCopy => {
721-
// Managed data is not copyable, sendable, nor
722-
// synchronized, regardless of referent.
723-
ok(self, Never)
724-
}
725-
726-
ty::BoundSized => {
727-
// But it is sized, regardless of referent.
728-
ok(self, Always)
729-
}
730-
}
731-
}
732-
733716
ty::ty_uniq(referent_ty) => { // Box<T>
734717
match bound {
735718
ty::BoundCopy => {

src/librustc/middle/trans/adt.rs

-3
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,6 @@ impl Case {
321321
_ => return Some(ThinPointer(i))
322322
},
323323

324-
// Gc<T> is just a pointer
325-
ty::ty_box(..) => return Some(ThinPointer(i)),
326-
327324
// Functions are just pointers
328325
ty::ty_bare_fn(..) => return Some(ThinPointer(i)),
329326

src/librustc/middle/trans/base.rs

-30
Original file line numberDiff line numberDiff line change
@@ -397,36 +397,6 @@ pub fn malloc_raw_dyn_proc<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: ty::t) -> Resu
397397
Result::new(bcx, llbox)
398398
}
399399

400-
401-
pub fn malloc_raw_dyn_managed<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
402-
t: ty::t,
403-
alloc_fn: LangItem,
404-
size: ValueRef)
405-
-> Result<'blk, 'tcx> {
406-
let _icx = push_ctxt("malloc_raw_dyn_managed");
407-
let ccx = bcx.ccx();
408-
409-
let langcall = require_alloc_fn(bcx, t, alloc_fn);
410-
411-
// Grab the TypeRef type of box_ptr_ty.
412-
let box_ptr_ty = ty::mk_box(bcx.tcx(), t);
413-
let llty = type_of(ccx, box_ptr_ty);
414-
let llalign = C_uint(ccx, type_of::align_of(ccx, box_ptr_ty) as uint);
415-
416-
// Allocate space:
417-
let drop_glue = glue::get_drop_glue(ccx, t);
418-
let r = callee::trans_lang_call(
419-
bcx,
420-
langcall,
421-
[
422-
PointerCast(bcx, drop_glue, Type::glue_fn(ccx, Type::i8p(ccx)).ptr_to()),
423-
size,
424-
llalign
425-
],
426-
None);
427-
Result::new(r.bcx, PointerCast(r.bcx, r.val, llty))
428-
}
429-
430400
// Type descriptor and type glue stuff
431401

432402
pub fn get_tydesc(ccx: &CrateContext, t: ty::t) -> Rc<tydesc_info> {

src/librustc/middle/trans/cleanup.rs

-7
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,6 @@ impl Cleanup for DropValue {
960960
}
961961

962962
pub enum Heap {
963-
HeapManaged,
964963
HeapExchange
965964
}
966965

@@ -986,9 +985,6 @@ impl Cleanup for FreeValue {
986985
apply_debug_loc(bcx.fcx, debug_loc);
987986

988987
match self.heap {
989-
HeapManaged => {
990-
glue::trans_free(bcx, self.ptr)
991-
}
992988
HeapExchange => {
993989
glue::trans_exchange_free_ty(bcx, self.ptr, self.content_ty)
994990
}
@@ -1019,9 +1015,6 @@ impl Cleanup for FreeSlice {
10191015
apply_debug_loc(bcx.fcx, debug_loc);
10201016

10211017
match self.heap {
1022-
HeapManaged => {
1023-
glue::trans_free(bcx, self.ptr)
1024-
}
10251018
HeapExchange => {
10261019
glue::trans_exchange_free_dyn(bcx, self.ptr, self.size, self.align)
10271020
}

src/librustc/middle/trans/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub fn type_is_immediate(ccx: &CrateContext, ty: ty::t) -> bool {
7171
use middle::trans::type_of::sizing_type_of;
7272

7373
let tcx = ccx.tcx();
74-
let simple = ty::type_is_scalar(ty) || ty::type_is_boxed(ty) ||
74+
let simple = ty::type_is_scalar(ty) ||
7575
ty::type_is_unique(ty) || ty::type_is_region_ptr(ty) ||
7676
type_is_newtype_immediate(ccx, ty) || ty::type_is_bot(ty) ||
7777
ty::type_is_simd(tcx, ty);

0 commit comments

Comments
 (0)