Skip to content

Commit c162328

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 86ab2b6 commit c162328

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

tests/auxiliary/minicore.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ pub trait Sized: MetaSized {}
5050

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

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

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

8585
pub enum Option<T> {
8686
None,
@@ -96,17 +96,17 @@ impl<T: Copy, E: Copy> Copy for Result<T, E> {}
9696

9797
#[lang = "manually_drop"]
9898
#[repr(transparent)]
99-
pub struct ManuallyDrop<T: ?Sized> {
99+
pub struct ManuallyDrop<T: PointeeSized> {
100100
value: T,
101101
}
102-
impl<T: Copy + ?Sized> Copy for ManuallyDrop<T> {}
102+
impl<T: Copy + PointeeSized> Copy for ManuallyDrop<T> {}
103103

104104
#[lang = "unsafe_cell"]
105105
#[repr(transparent)]
106-
pub struct UnsafeCell<T: ?Sized> {
106+
pub struct UnsafeCell<T: PointeeSized> {
107107
value: T,
108108
}
109-
impl<T: ?Sized> !Freeze for UnsafeCell<T> {}
109+
impl<T: PointeeSized> !Freeze for UnsafeCell<T> {}
110110

111111
#[lang = "tuple_trait"]
112112
pub trait Tuple {}
@@ -182,15 +182,15 @@ pub trait Fn<Args: Tuple>: FnMut<Args> {
182182
#[lang = "dispatch_from_dyn"]
183183
trait DispatchFromDyn<T> {}
184184

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

187187
#[lang = "unsize"]
188-
trait Unsize<T: ?Sized> {}
188+
trait Unsize<T: PointeeSized>: PointeeSized {}
189189

190190
#[lang = "coerce_unsized"]
191-
pub trait CoerceUnsized<T: ?Sized> {}
191+
pub trait CoerceUnsized<T: PointeeSized> {}
192192

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

195195
#[lang = "drop"]
196196
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)