Skip to content

Commit 1775615

Browse files
James MillerAatch
authored andcommitted
---
yaml --- r: 66231 b: refs/heads/master c: d9f6dd2 h: refs/heads/master i: 66229: 889a62b 66227: a5e37ab 66223: 1dca157 v: v3
1 parent 4a074ec commit 1775615

File tree

5 files changed

+40
-10
lines changed

5 files changed

+40
-10
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: 0cca08a21a33b60f9a27a4bab119b5ec8261be56
2+
refs/heads/master: d9f6dd263c16a21108c27dbf15a3d59a43a5b490
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/libextra/rc.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ impl<T> Rc<T> {
7070
impl<T> Drop for Rc<T> {
7171
fn finalize(&self) {
7272
unsafe {
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)
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+
}
7779
}
7880
}
7981
}
@@ -220,10 +222,12 @@ impl<T> RcMut<T> {
220222
impl<T> Drop for RcMut<T> {
221223
fn finalize(&self) {
222224
unsafe {
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)
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+
}
227231
}
228232
}
229233
}

trunk/src/librustc/middle/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3883,7 +3883,7 @@ impl DtorKind {
38833883
pub fn ty_dtor(cx: ctxt, struct_id: def_id) -> DtorKind {
38843884
match cx.destructor_for_type.find(&struct_id) {
38853885
Some(&method_def_id) => {
3886-
let flag = has_attr(cx, struct_id, "no_drop_flag");
3886+
let flag = !has_attr(cx, struct_id, "no_drop_flag");
38873887

38883888
TraitDtor(method_def_id, flag)
38893889
}

trunk/src/libstd/unstable/atomics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ 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]
6566
pub struct AtomicOption<T> {
6667
priv p: *mut c_void
6768
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::sys::size_of;
12+
13+
#[no_drop_flag]
14+
struct Test<T> {
15+
a: T
16+
}
17+
18+
#[unsafe_destructor]
19+
impl<T> Drop for Test<T> {
20+
fn finalize(&self) { }
21+
}
22+
23+
fn main() {
24+
assert_eq!(size_of::<int>(), size_of::<Test<int>>());
25+
}

0 commit comments

Comments
 (0)