File tree 1 file changed +5
-1
lines changed
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -3381,7 +3381,11 @@ impl<T> Default for Arc<[T]> {
3381
3381
#[ inline]
3382
3382
fn default ( ) -> Self {
3383
3383
if mem:: align_of :: < T > ( ) <= MAX_STATIC_INNER_SLICE_ALIGNMENT {
3384
- let inner: NonNull < ArcInner < [ u8 ; 1 ] > > = NonNull :: from ( & STATIC_INNER_SLICE . inner ) ;
3384
+ // We take a reference to the whole struct instead of the ArcInner<[u8; 1]> inside it so
3385
+ // we don't shrink the range of bytes the ptr is allowed to access under Stacked Borrows.
3386
+ // (Miri complains on 32-bit targets with Arc<[Align16]> otherwise.)
3387
+ // (Note that NonNull::from(&STATIC_INNER_SLICE.inner) is fine under Tree Borrows.)
3388
+ let inner: NonNull < SliceArcInnerForStatic > = NonNull :: from ( & STATIC_INNER_SLICE ) ;
3385
3389
let inner: NonNull < ArcInner < [ T ; 0 ] > > = inner. cast ( ) ;
3386
3390
// `this` semantically is the Arc "owned" by the static, so make sure not to drop it.
3387
3391
let this: mem:: ManuallyDrop < Arc < [ T ; 0 ] > > = unsafe { mem:: ManuallyDrop :: new ( Arc :: from_inner ( inner) ) } ;
You can’t perform that action at this time.
0 commit comments