Skip to content

Commit c895f6e

Browse files
committed
Access alloc field directly in Arc/Rc::into_raw_with_allocator.
... since fn allocator doesn't exist yet.
1 parent 28cb2d7 commit c895f6e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

library/alloc/src/rc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ impl<T: ?Sized, A: Allocator> Rc<T, A> {
13791379
let this = mem::ManuallyDrop::new(this);
13801380
let ptr = Self::as_ptr(&this);
13811381
// Safety: `this` is ManuallyDrop so the allocator will not be double-dropped
1382-
let alloc = unsafe { ptr::read(Self::allocator(&this)) };
1382+
let alloc = unsafe { ptr::read(&this.alloc) };
13831383
(ptr, alloc)
13841384
}
13851385

@@ -3061,7 +3061,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
30613061
let this = mem::ManuallyDrop::new(self);
30623062
let result = this.as_ptr();
30633063
// Safety: `this` is ManuallyDrop so the allocator will not be double-dropped
3064-
let alloc = unsafe { ptr::read(this.allocator()) };
3064+
let alloc = unsafe { ptr::read(&this.alloc) };
30653065
(result, alloc)
30663066
}
30673067

library/alloc/src/sync.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
15201520
let this = mem::ManuallyDrop::new(this);
15211521
let ptr = Self::as_ptr(&this);
15221522
// Safety: `this` is ManuallyDrop so the allocator will not be double-dropped
1523-
let alloc = unsafe { ptr::read(Self::allocator(&this)) };
1523+
let alloc = unsafe { ptr::read(&this.alloc) };
15241524
(ptr, alloc)
15251525
}
15261526

@@ -2803,7 +2803,7 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
28032803
let this = mem::ManuallyDrop::new(self);
28042804
let result = this.as_ptr();
28052805
// Safety: `this` is ManuallyDrop so the allocator will not be double-dropped
2806-
let alloc = unsafe { ptr::read(Self::allocator(&this)) };
2806+
let alloc = unsafe { ptr::read(&this.alloc) };
28072807
(result, alloc)
28082808
}
28092809

0 commit comments

Comments
 (0)