@@ -33,13 +33,6 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
3333#[ inline]
3434pub 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) ]
108101mod 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 ! ( 1 u, 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