Skip to content

Commit 5f6edef

Browse files
committed
bring back some lost Freezes
1 parent 105df08 commit 5f6edef

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

library/alloc/src/rc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ pub struct Rc<
318318
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
319319
> {
320320
ptr: NonNull<RcBox<T>>,
321-
phantom: PhantomData<RcBox<T>>,
321+
phantom: PhantomData<Box<RcBox<T>>>,
322322
alloc: A,
323323
}
324324

@@ -3400,7 +3400,7 @@ fn data_offset_align(align: usize) -> usize {
34003400
#[derive(Debug)]
34013401
pub struct UniqueRc<T> {
34023402
ptr: NonNull<RcBox<T>>,
3403-
phantom: PhantomData<RcBox<T>>,
3403+
phantom: PhantomData<Box<RcBox<T>>>,
34043404
}
34053405

34063406
impl<T> UniqueRc<T> {

library/alloc/src/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ pub struct Arc<
251251
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
252252
> {
253253
ptr: NonNull<ArcInner<T>>,
254-
phantom: PhantomData<ArcInner<T>>,
254+
phantom: PhantomData<Box<ArcInner<T>>>,
255255
alloc: A,
256256
}
257257

library/core/src/ptr/unique.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::convert::From;
22
use crate::fmt;
3-
use crate::marker::{PhantomData, Unsize};
3+
use crate::marker::{Freeze, PhantomData, Unsize};
44
use crate::ops::{CoerceUnsized, DispatchFromDyn};
55
use crate::ptr::NonNull;
66

@@ -58,6 +58,10 @@ unsafe impl<T: Send + ?Sized> Send for Unique<T> {}
5858
#[unstable(feature = "ptr_internals", issue = "none")]
5959
unsafe impl<T: Sync + ?Sized> Sync for Unique<T> {}
6060

61+
/// `Unique` pointers are always `Freeze` since any interior mutability that might exist in `T` is
62+
/// masked by the pointer indirection.
63+
unsafe impl<T: ?Sized> Freeze for Unique<T> {}
64+
6165
#[unstable(feature = "ptr_internals", issue = "none")]
6266
impl<T: Sized> Unique<T> {
6367
/// Creates a new `Unique` that is dangling, but well-aligned.

0 commit comments

Comments
 (0)