Skip to content

Commit ff13dd5

Browse files
committed
aux: add {Meta,Pointee}Sized bounds to minicore
With `MetaSized` bounds replacing `?Sized` and being added as a supertrait, the same relaxations applied to the standard library must be applied to minicore.
1 parent 01af1ac commit ff13dd5

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

tests/auxiliary/minicore.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ pub trait Sized: MetaSized {}
5151

5252
#[lang = "legacy_receiver"]
5353
pub trait LegacyReceiver {}
54-
impl<T: ?Sized> LegacyReceiver for &T {}
55-
impl<T: ?Sized> LegacyReceiver for &mut T {}
54+
impl<T: PointeeSized> LegacyReceiver for &T {}
55+
impl<T: PointeeSized> LegacyReceiver for &mut T {}
5656

5757
#[lang = "copy"]
5858
pub trait Copy: Sized {}
@@ -74,14 +74,14 @@ impl_marker_trait!(
7474
f16, f32, f64, f128,
7575
]
7676
);
77-
impl<'a, T: ?Sized> Copy for &'a T {}
78-
impl<T: ?Sized> Copy for *const T {}
79-
impl<T: ?Sized> Copy for *mut T {}
77+
impl<'a, T: PointeeSized> Copy for &'a T {}
78+
impl<T: PointeeSized> Copy for *const T {}
79+
impl<T: PointeeSized> Copy for *mut T {}
8080
impl<T: Copy, const N: usize> Copy for [T; N] {}
8181

8282
#[lang = "phantom_data"]
83-
pub struct PhantomData<T: ?Sized>;
84-
impl<T: ?Sized> Copy for PhantomData<T> {}
83+
pub struct PhantomData<T: PointeeSized>;
84+
impl<T: PointeeSized> Copy for PhantomData<T> {}
8585

8686
pub enum Option<T> {
8787
None,
@@ -97,14 +97,14 @@ impl<T: Copy, E: Copy> Copy for Result<T, E> {}
9797

9898
#[lang = "manually_drop"]
9999
#[repr(transparent)]
100-
pub struct ManuallyDrop<T: ?Sized> {
100+
pub struct ManuallyDrop<T: PointeeSized> {
101101
value: T,
102102
}
103-
impl<T: Copy + ?Sized> Copy for ManuallyDrop<T> {}
103+
impl<T: Copy + PointeeSized> Copy for ManuallyDrop<T> {}
104104

105105
#[lang = "unsafe_cell"]
106106
#[repr(transparent)]
107-
pub struct UnsafeCell<T: ?Sized> {
107+
pub struct UnsafeCell<T: PointeeSized> {
108108
value: T,
109109
}
110110
impl<T: ?Sized> !Freeze for UnsafeCell<T> {}
@@ -183,15 +183,15 @@ pub trait Fn<Args: Tuple>: FnMut<Args> {
183183
#[lang = "dispatch_from_dyn"]
184184
trait DispatchFromDyn<T> {}
185185

186-
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
186+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a U> for &'a T {}
187187

188188
#[lang = "unsize"]
189-
trait Unsize<T: ?Sized> {}
189+
trait Unsize<T: PointeeSized>: PointeeSized {}
190190

191191
#[lang = "coerce_unsized"]
192-
pub trait CoerceUnsized<T: ?Sized> {}
192+
pub trait CoerceUnsized<T: PointeeSized> {}
193193

194-
impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
194+
impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a U> for &'b T {}
195195

196196
#[lang = "drop"]
197197
trait Drop {

tests/ui/traits/const-traits/auxiliary/minicore.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
fundamental,
1313
marker_trait_attr,
1414
const_trait_impl,
15-
const_destruct
15+
const_destruct,
1616
)]
1717
#![allow(internal_features, incomplete_features)]
1818
#![no_std]
@@ -32,7 +32,7 @@ pub trait Copy {}
3232

3333
impl Copy for bool {}
3434
impl Copy for u8 {}
35-
impl<T: ?Sized> Copy for &T {}
35+
impl<T: PointeeSized> Copy for &T {}
3636

3737
#[lang = "add"]
3838
#[const_trait]
@@ -113,17 +113,17 @@ pub trait Tuple {}
113113
#[lang = "legacy_receiver"]
114114
pub trait LegacyReceiver {}
115115

116-
impl<T: ?Sized> LegacyReceiver for &T {}
116+
impl<T: PointeeSized> LegacyReceiver for &T {}
117117

118-
impl<T: ?Sized> LegacyReceiver for &mut T {}
118+
impl<T: PointeeSized> LegacyReceiver for &mut T {}
119119

120120
#[lang = "receiver"]
121121
pub trait Receiver {
122122
#[lang = "receiver_target"]
123-
type Target: ?Sized;
123+
type Target: MetaSized;
124124
}
125125

126-
impl<T: Deref + ?Sized> Receiver for T {
126+
impl<T: Deref + MetaSized> Receiver for T {
127127
type Target = <T as Deref>::Target;
128128
}
129129

@@ -169,15 +169,15 @@ fn panic_fmt() {}
169169

170170
#[lang = "index"]
171171
#[const_trait]
172-
pub trait Index<Idx: ?Sized> {
173-
type Output: ?Sized;
172+
pub trait Index<Idx: PointeeSized> {
173+
type Output: MetaSized;
174174

175175
fn index(&self, index: Idx) -> &Self::Output;
176176
}
177177

178178
#[const_trait]
179-
pub unsafe trait SliceIndex<T: ?Sized> {
180-
type Output: ?Sized;
179+
pub unsafe trait SliceIndex<T: PointeeSized> {
180+
type Output: MetaSized;
181181
fn index(self, slice: &T) -> &Self::Output;
182182
}
183183

@@ -206,31 +206,31 @@ where
206206
}
207207

208208
#[lang = "unsize"]
209-
pub trait Unsize<T: ?Sized> {}
209+
pub trait Unsize<T: PointeeSized>: PointeeSized {}
210210

211211
#[lang = "coerce_unsized"]
212-
pub trait CoerceUnsized<T: ?Sized> {}
212+
pub trait CoerceUnsized<T: PointeeSized> {}
213213

214-
impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
214+
impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a U> for &'b T {}
215215

216216
#[lang = "deref"]
217217
#[const_trait]
218218
pub trait Deref {
219219
#[lang = "deref_target"]
220-
type Target: ?Sized;
220+
type Target: MetaSized;
221221

222222
fn deref(&self) -> &Self::Target;
223223
}
224224

225-
impl<T: ?Sized> const Deref for &T {
225+
impl<T: MetaSized> const Deref for &T {
226226
type Target = T;
227227

228228
fn deref(&self) -> &T {
229229
*self
230230
}
231231
}
232232

233-
impl<T: ?Sized> const Deref for &mut T {
233+
impl<T: MetaSized> const Deref for &mut T {
234234
type Target = T;
235235

236236
fn deref(&self) -> &T {
@@ -314,14 +314,14 @@ fn from_str(s: &str) -> Result<bool, ()> {
314314

315315
#[lang = "eq"]
316316
#[const_trait]
317-
pub trait PartialEq<Rhs: ?Sized = Self> {
317+
pub trait PartialEq<Rhs: PointeeSized = Self>: PointeeSized {
318318
fn eq(&self, other: &Rhs) -> bool;
319319
fn ne(&self, other: &Rhs) -> bool {
320320
!self.eq(other)
321321
}
322322
}
323323

324-
impl<A: ?Sized, B: ?Sized> const PartialEq<&B> for &A
324+
impl<A: PointeeSized, B: PointeeSized> const PartialEq<&B> for &A
325325
where
326326
A: ~const PartialEq<B>,
327327
{
@@ -364,7 +364,7 @@ impl<P> Pin<P> {
364364
}
365365
}
366366

367-
impl<'a, T: ?Sized> Pin<&'a T> {
367+
impl<'a, T: PointeeSized> Pin<&'a T> {
368368
const fn get_ref(self) -> &'a T {
369369
self.pointer
370370
}
@@ -379,7 +379,7 @@ impl<P: Deref> Pin<P> {
379379
}
380380
}
381381

382-
impl<'a, T: ?Sized> Pin<&'a mut T> {
382+
impl<'a, T: PointeeSized> Pin<&'a mut T> {
383383
const unsafe fn get_unchecked_mut(self) -> &'a mut T {
384384
self.pointer
385385
}
@@ -425,7 +425,7 @@ impl<T: Clone> Clone for RefCell<T> {
425425
}
426426
}
427427

428-
struct RefCell<T: ?Sized> {
428+
struct RefCell<T: PointeeSized> {
429429
borrow: UnsafeCell<()>,
430430
value: UnsafeCell<T>,
431431
}
@@ -434,24 +434,24 @@ impl<T> RefCell<T> {
434434
loop {}
435435
}
436436
}
437-
impl<T: ?Sized> RefCell<T> {
437+
impl<T: PointeeSized> RefCell<T> {
438438
fn borrow(&self) -> Ref<'_, T> {
439439
loop {}
440440
}
441441
}
442442

443443
#[lang = "unsafe_cell"]
444444
#[repr(transparent)]
445-
struct UnsafeCell<T: ?Sized> {
445+
struct UnsafeCell<T: PointeeSized> {
446446
value: T,
447447
}
448448

449-
struct Ref<'b, T: ?Sized + 'b> {
449+
struct Ref<'b, T: PointeeSized + 'b> {
450450
value: *const T,
451451
borrow: &'b UnsafeCell<()>,
452452
}
453453

454-
impl<T: ?Sized> Deref for Ref<'_, T> {
454+
impl<T: MetaSized> Deref for Ref<'_, T> {
455455
type Target = T;
456456

457457
#[inline]

0 commit comments

Comments
 (0)