Skip to content

Commit 1868cf5

Browse files
committed
std: Remove bump_box_refcount. Deprecated and unused. Deprecused.
1 parent 87115fd commit 1868cf5

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

src/libcore/cast.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
3333
#[inline]
3434
pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing); }
3535

36-
/**
37-
* Force-increment the reference count on a shared box. If used
38-
* carelessly, this can leak the box.
39-
*/
40-
#[inline]
41-
pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
42-
4336
/**
4437
* Transform a value of one type into a value of another type.
4538
* Both types must have the same size and alignment.
@@ -106,7 +99,7 @@ pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T {
10699

107100
#[cfg(test)]
108101
mod tests {
109-
use cast::{bump_box_refcount, transmute};
102+
use cast::transmute;
110103
use raw;
111104
use realstd::str::StrAllocating;
112105

@@ -115,21 +108,6 @@ mod tests {
115108
assert_eq!(1u, unsafe { ::cast::transmute_copy(&1) });
116109
}
117110

118-
#[test]
119-
fn test_bump_managed_refcount() {
120-
unsafe {
121-
let managed = @"box box box".to_owned(); // refcount 1
122-
bump_box_refcount(managed); // refcount 2
123-
let ptr: *int = transmute(managed); // refcount 2
124-
let _box1: @~str = ::cast::transmute_copy(&ptr);
125-
let _box2: @~str = ::cast::transmute_copy(&ptr);
126-
assert!(*_box1 == "box box box".to_owned());
127-
assert!(*_box2 == "box box box".to_owned());
128-
// Will destroy _box1 and _box2. Without the bump, this would
129-
// use-after-free. With too many bumps, it would leak.
130-
}
131-
}
132-
133111
#[test]
134112
fn test_transmute() {
135113
unsafe {

0 commit comments

Comments
 (0)