Skip to content

Commit 46e2842

Browse files
committed
---
yaml --- r: 66233 b: refs/heads/master c: 2afdf0d h: refs/heads/master i: 66231: 1775615 v: v3
1 parent 8fbfe17 commit 46e2842

File tree

8 files changed

+28
-113
lines changed

8 files changed

+28
-113
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 721164d5ec0c8b617bd72df36830fe1861e6362b
2+
refs/heads/master: 2afdf0d6a18bd0fb3369088eff1f8d9c707ad43d
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/libextra/rc.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,10 @@ impl<T> Rc<T> {
7070
impl<T> Drop for Rc<T> {
7171
fn finalize(&self) {
7272
unsafe {
73-
if self.ptr.is_not_null() {
74-
(*self.ptr).count -= 1;
75-
if (*self.ptr).count == 0 {
76-
ptr::replace_ptr(self.ptr, intrinsics::uninit());
77-
free(self.ptr as *c_void)
78-
}
73+
(*self.ptr).count -= 1;
74+
if (*self.ptr).count == 0 {
75+
ptr::replace_ptr(self.ptr, intrinsics::uninit());
76+
free(self.ptr as *c_void)
7977
}
8078
}
8179
}
@@ -222,12 +220,10 @@ impl<T> RcMut<T> {
222220
impl<T> Drop for RcMut<T> {
223221
fn finalize(&self) {
224222
unsafe {
225-
if self.ptr.is_not_null() {
226-
(*self.ptr).count -= 1;
227-
if (*self.ptr).count == 0 {
228-
ptr::replace_ptr(self.ptr, uninit());
229-
free(self.ptr as *c_void)
230-
}
223+
(*self.ptr).count -= 1;
224+
if (*self.ptr).count == 0 {
225+
ptr::replace_ptr(self.ptr, uninit());
226+
free(self.ptr as *c_void)
231227
}
232228
}
233229
}

trunk/src/librustc/middle/trans/adt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ fn represent_type_uncached(cx: &mut CrateContext, t: ty::t) -> Repr {
135135
ty::lookup_field_type(cx.tcx, def_id, field.id, substs)
136136
};
137137
let packed = ty::lookup_packed(cx.tcx, def_id);
138-
let dtor = ty::ty_dtor(cx.tcx, def_id).has_drop_flag();
138+
let dtor = ty::ty_dtor(cx.tcx, def_id).is_present();
139139
let ftys =
140140
if dtor { ftys + [ty::mk_bool()] } else { ftys };
141141
return Univariant(mk_struct(cx, ftys, packed), dtor)

trunk/src/librustc/middle/trans/glue.rs

Lines changed: 8 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,13 @@ pub fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) {
406406
build_return(bcx);
407407
}
408408

409-
pub fn trans_struct_drop_flag(bcx: block, t: ty::t, v0: ValueRef, dtor_did: ast::def_id,
410-
class_did: ast::def_id, substs: &ty::substs) -> block {
409+
pub fn trans_struct_drop(bcx: block,
410+
t: ty::t,
411+
v0: ValueRef,
412+
dtor_did: ast::def_id,
413+
class_did: ast::def_id,
414+
substs: &ty::substs)
415+
-> block {
411416
let repr = adt::represent_type(bcx.ccx(), t);
412417
let drop_flag = adt::trans_drop_flag_ptr(bcx, repr, v0);
413418
do with_cond(bcx, IsNotNull(bcx, Load(bcx, drop_flag))) |cx| {
@@ -449,43 +454,6 @@ pub fn trans_struct_drop_flag(bcx: block, t: ty::t, v0: ValueRef, dtor_did: ast:
449454
}
450455
}
451456

452-
pub fn trans_struct_drop(mut bcx: block, t: ty::t, v0: ValueRef, dtor_did: ast::def_id,
453-
class_did: ast::def_id, substs: &ty::substs) -> block {
454-
let repr = adt::represent_type(bcx.ccx(), t);
455-
456-
// Find and call the actual destructor
457-
let dtor_addr = get_res_dtor(bcx.ccx(), dtor_did,
458-
class_did, /*bad*/copy substs.tps);
459-
460-
// The second argument is the "self" argument for drop
461-
let params = unsafe {
462-
let ty = Type::from_ref(llvm::LLVMTypeOf(dtor_addr));
463-
ty.element_type().func_params()
464-
};
465-
466-
// Class dtors have no explicit args, so the params should
467-
// just consist of the environment (self)
468-
assert_eq!(params.len(), 1);
469-
470-
// Take a reference to the class (because it's using the Drop trait),
471-
// do so now.
472-
let llval = alloca(bcx, val_ty(v0));
473-
Store(bcx, v0, llval);
474-
475-
let self_arg = PointerCast(bcx, llval, params[0]);
476-
let args = ~[self_arg];
477-
478-
Call(bcx, dtor_addr, args);
479-
480-
// Drop the fields
481-
let field_tys = ty::struct_fields(bcx.tcx(), class_did, substs);
482-
for field_tys.iter().enumerate().advance |(i, fld)| {
483-
let llfld_a = adt::trans_field_ptr(bcx, repr, v0, 0, i);
484-
bcx = drop_ty(bcx, llfld_a, fld.mt.ty);
485-
}
486-
487-
bcx
488-
}
489457

490458
pub fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
491459
// NB: v0 is an *alias* of type t here, not a direct value.
@@ -506,10 +474,7 @@ pub fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) {
506474
ty::ty_struct(did, ref substs) => {
507475
let tcx = bcx.tcx();
508476
match ty::ty_dtor(tcx, did) {
509-
ty::TraitDtor(dtor, true) => {
510-
trans_struct_drop_flag(bcx, t, v0, dtor, did, substs)
511-
}
512-
ty::TraitDtor(dtor, false) => {
477+
ty::TraitDtor(dtor) => {
513478
trans_struct_drop(bcx, t, v0, dtor, did, substs)
514479
}
515480
ty::NoDtor => {
@@ -629,23 +594,6 @@ pub fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) {
629594
ty::ty_opaque_closure_ptr(ck) => {
630595
closure::make_opaque_cbox_take_glue(bcx, ck, v)
631596
}
632-
ty::ty_struct(did, ref substs) => {
633-
let tcx = bcx.tcx();
634-
let bcx = iter_structural_ty(bcx, v, t, take_ty);
635-
636-
match ty::ty_dtor(tcx, did) {
637-
ty::TraitDtor(dtor, false) => {
638-
// Zero out the struct
639-
unsafe {
640-
let ty = Type::from_ref(llvm::LLVMTypeOf(v));
641-
memzero(bcx, v, ty);
642-
}
643-
644-
}
645-
_ => { }
646-
}
647-
bcx
648-
}
649597
_ if ty::type_is_structural(t) => {
650598
iter_structural_ty(bcx, v, t, take_ty)
651599
}

trunk/src/librustc/middle/ty.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3855,7 +3855,7 @@ pub fn item_path_str(cx: ctxt, id: ast::def_id) -> ~str {
38553855

38563856
pub enum DtorKind {
38573857
NoDtor,
3858-
TraitDtor(def_id, bool)
3858+
TraitDtor(def_id)
38593859
}
38603860

38613861
impl DtorKind {
@@ -3869,24 +3869,13 @@ impl DtorKind {
38693869
pub fn is_present(&const self) -> bool {
38703870
!self.is_not_present()
38713871
}
3872-
3873-
pub fn has_drop_flag(&self) -> bool {
3874-
match self {
3875-
&NoDtor => false,
3876-
&TraitDtor(_, flag) => flag
3877-
}
3878-
}
38793872
}
38803873

38813874
/* If struct_id names a struct with a dtor, return Some(the dtor's id).
38823875
Otherwise return none. */
38833876
pub fn ty_dtor(cx: ctxt, struct_id: def_id) -> DtorKind {
38843877
match cx.destructor_for_type.find(&struct_id) {
3885-
Some(&method_def_id) => {
3886-
let flag = !has_attr(cx, struct_id, "no_drop_flag");
3887-
3888-
TraitDtor(method_def_id, flag)
3889-
}
3878+
Some(&method_def_id) => TraitDtor(method_def_id),
38903879
None => NoDtor,
38913880
}
38923881
}

trunk/src/libstd/unstable/atomics.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ pub struct AtomicPtr<T> {
6262
/**
6363
* An owned atomic pointer. Ensures that only a single reference to the data is held at any time.
6464
*/
65-
#[no_drop_flag]
6665
pub struct AtomicOption<T> {
6766
priv p: *mut c_void
6867
}

trunk/src/snapshots.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
S 2013-06-23 f827561
2+
macos-i386 63ffbcf99b6853d7840bdfe01380068518d0e466
3+
macos-x86_64 b34fdf3845f8ef4760817007d8ef820cd32f2e07
4+
winnt-i386 6602150074ec442fd376fddb2eaf63f5da6fdff9
5+
freebsd-x86_64 a05bdda2d9ec0e66336d81b98bee8a95442a501f
6+
linux-i386 b8f4a0f0c2250aa4d76ec1eb57c83bfae5725f93
7+
linux-x86_64 caea3402663334d0a3967c21f58a860c060d5474
8+
19
S 2013-06-21 6759ce4
210
macos-i386 6e5395d2fda1db356f64af28ba525031bf9871c7
311
macos-x86_64 7b8ded4e1ba1e999a5614eea3a4acacb2c7cef1d

trunk/src/test/run-pass/attr-no-drop-flag-size.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)