Skip to content

Commit 0b080f0

Browse files
committed
Auto merge of rust-lang#137944 - davidtwco:sized-hierarchy, r=<try>
Sized Hierarchy: Part I This patch implements the non-const parts of rust-lang/rfcs#3729. It introduces two new traits to the standard library, `MetaSized` and `PointeeSized`. See the RFC for the rationale behind these traits and to discuss whether this change makes sense in the abstract. These traits are unstable (as is their constness), so users cannot refer to them without opting-in to `feature(sized_hierarchy)`. These traits are not behind `cfg`s as this would make implementation unfeasible, there would simply be too many `cfg`s required to add the necessary bounds everywhere. So, like `Sized`, these traits are automatically implemented by the compiler. RFC 3729 describes changes which are necessary to preserve backwards compatibility given the introduction of these traits, which are implemented and as follows: - `?Sized` is rewritten as `MetaSized` - `MetaSized` is added as a default supertrait for all traits w/out an explicit sizedness supertrait already. There are no edition migrations implemented in this, as these are primarily required for the constness parts of the RFC and prior to stabilisation of this (and so will come in follow-up PRs alongside the const parts). All diagnostic output should remain the same (showing `?Sized` even if the compiler sees `MetaSized`) unless the `sized_hierarchy` feature is enabled. Due to the use of unstable extern types in the standard library and rustc, some bounds in both projects have had to be relaxed already - this is unfortunate but unavoidable so that these extern types can continue to be used where they were before. Performing these relaxations in the standard library and rustc are desirable longer-term anyway, but some bounds are not as relaxed as they ideally would be due to the inability to relax `Deref::Target` (this will be investigated separately). It is hoped that this is implemented such that it could be merged and these traits could exist "under the hood" without that being observable to the user (other than in any performance impact this has on the compiler, etc). Some details might leak through due to the standard library relaxations, but this has not been observed in test output. **Notes:** - Any commits starting with "upstream:" can be ignored, as these correspond to other upstream PRs that this is based on which have yet to be merged. - This best reviewed commit-by-commit. I've attempted to make the implementation easy to follow and keep similar changes and test output updates together. - Each commit has a short description describing its purpose. - This patch is large but it's primarily in the test suite. - I've worked on the performance of this patch and a few optimisations are implemented so that the performance impact is neutral-to-minor. - `PointeeSized` is a different name from the RFC just to make it more obvious that it is different from `std::ptr::Pointee` but all the names are yet to be bikeshed anyway. - `@nikomatsakis` has confirmed [that this can proceed as an experiment from the t-lang side](https://rust-lang.zulipchat.com/#narrow/channel/435869-project-goals/topic/SVE.20and.20SME.20on.20AArch64.20.28goals.23270.29/near/506196491) Fixes rust-lang#79409. r? `@ghost` (I'll discuss this with relevant teams to find a reviewer)
2 parents dc8fe1f + 60dec26 commit 0b080f0

File tree

271 files changed

+4047
-1020
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

271 files changed

+4047
-1020
lines changed

compiler/rustc_codegen_cranelift/example/mini_core.rs

+36-30
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@
1414
#![no_core]
1515
#![allow(dead_code, internal_features, ambiguous_wide_pointer_comparisons)]
1616

17+
#[lang = "pointee_sized"]
18+
pub trait PointeeSized {}
19+
20+
#[lang = "meta_sized"]
21+
pub trait MetaSized: PointeeSized {}
22+
1723
#[lang = "sized"]
18-
pub trait Sized {}
24+
pub trait Sized: MetaSized {}
1925

2026
#[lang = "destruct"]
2127
pub trait Destruct {}
@@ -24,35 +30,35 @@ pub trait Destruct {}
2430
pub trait Tuple {}
2531

2632
#[lang = "unsize"]
27-
pub trait Unsize<T: ?Sized> {}
33+
pub trait Unsize<T: PointeeSized>: PointeeSized {}
2834

2935
#[lang = "coerce_unsized"]
3036
pub trait CoerceUnsized<T> {}
3137

32-
impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
33-
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {}
34-
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
35-
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
38+
impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a U> for &'b T {}
39+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a mut U> for &'a mut T {}
40+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for *const T {}
41+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*mut U> for *mut T {}
3642

3743
#[lang = "dispatch_from_dyn"]
3844
pub trait DispatchFromDyn<T> {}
3945

4046
// &T -> &U
41-
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
47+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a U> for &'a T {}
4248
// &mut T -> &mut U
43-
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut T {}
49+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a mut U> for &'a mut T {}
4450
// *const T -> *const U
45-
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
51+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*const U> for *const T {}
4652
// *mut T -> *mut U
47-
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
48-
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U>> for Box<T> {}
53+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*mut U> for *mut T {}
54+
impl<T: MetaSized + Unsize<U>, U: MetaSized> DispatchFromDyn<Box<U>> for Box<T> {}
4955

5056
#[lang = "legacy_receiver"]
5157
pub trait LegacyReceiver {}
5258

53-
impl<T: ?Sized> LegacyReceiver for &T {}
54-
impl<T: ?Sized> LegacyReceiver for &mut T {}
55-
impl<T: ?Sized> LegacyReceiver for Box<T> {}
59+
impl<T: PointeeSized> LegacyReceiver for &T {}
60+
impl<T: PointeeSized> LegacyReceiver for &mut T {}
61+
impl<T: MetaSized> LegacyReceiver for Box<T> {}
5662

5763
#[lang = "copy"]
5864
pub trait Copy {}
@@ -74,9 +80,9 @@ impl Copy for isize {}
7480
impl Copy for f32 {}
7581
impl Copy for f64 {}
7682
impl Copy for char {}
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 {}
83+
impl<'a, T: PointeeSized> Copy for &'a T {}
84+
impl<T: PointeeSized> Copy for *const T {}
85+
impl<T: PointeeSized> Copy for *mut T {}
8086
impl<T: Copy> Copy for Option<T> {}
8187

8288
#[lang = "sync"]
@@ -94,17 +100,17 @@ unsafe impl Sync for i32 {}
94100
unsafe impl Sync for isize {}
95101
unsafe impl Sync for char {}
96102
unsafe impl Sync for f32 {}
97-
unsafe impl<'a, T: ?Sized> Sync for &'a T {}
103+
unsafe impl<'a, T: PointeeSized> Sync for &'a T {}
98104
unsafe impl<T: Sync, const N: usize> Sync for [T; N] {}
99105

100106
#[lang = "freeze"]
101107
unsafe auto trait Freeze {}
102108

103-
unsafe impl<T: ?Sized> Freeze for PhantomData<T> {}
104-
unsafe impl<T: ?Sized> Freeze for *const T {}
105-
unsafe impl<T: ?Sized> Freeze for *mut T {}
106-
unsafe impl<T: ?Sized> Freeze for &T {}
107-
unsafe impl<T: ?Sized> Freeze for &mut T {}
109+
unsafe impl<T: PointeeSized> Freeze for PhantomData<T> {}
110+
unsafe impl<T: PointeeSized> Freeze for *const T {}
111+
unsafe impl<T: PointeeSized> Freeze for *mut T {}
112+
unsafe impl<T: PointeeSized> Freeze for &T {}
113+
unsafe impl<T: PointeeSized> Freeze for &mut T {}
108114

109115
#[lang = "structural_peq"]
110116
pub trait StructuralPartialEq {}
@@ -443,7 +449,7 @@ pub enum Option<T> {
443449
pub use Option::*;
444450

445451
#[lang = "phantom_data"]
446-
pub struct PhantomData<T: ?Sized>;
452+
pub struct PhantomData<T: PointeeSized>;
447453

448454
#[lang = "fn_once"]
449455
#[rustc_paren_sugar]
@@ -546,18 +552,18 @@ pub trait Deref {
546552
#[repr(transparent)]
547553
#[rustc_layout_scalar_valid_range_start(1)]
548554
#[rustc_nonnull_optimization_guaranteed]
549-
pub struct NonNull<T: ?Sized>(pub *const T);
555+
pub struct NonNull<T: PointeeSized>(pub *const T);
550556

551-
impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
552-
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
557+
impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
558+
impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
553559

554-
pub struct Unique<T: ?Sized> {
560+
pub struct Unique<T: PointeeSized> {
555561
pub pointer: NonNull<T>,
556562
pub _marker: PhantomData<T>,
557563
}
558564

559-
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
560-
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
565+
impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
566+
impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
561567

562568
#[lang = "global_alloc_ty"]
563569
pub struct Global;

compiler/rustc_codegen_gcc/example/mini_core.rs

+36-30
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@ unsafe extern "C" fn _Unwind_Resume() {
1111
intrinsics::unreachable();
1212
}
1313

14+
#[lang = "pointee_sized"]
15+
pub trait PointeeSized {}
16+
17+
#[lang = "meta_sized"]
18+
pub trait MetaSized: PointeeSized {}
19+
1420
#[lang = "sized"]
15-
pub trait Sized {}
21+
pub trait Sized: MetaSized {}
1622

1723
#[lang = "destruct"]
1824
pub trait Destruct {}
@@ -21,35 +27,35 @@ pub trait Destruct {}
2127
pub trait Tuple {}
2228

2329
#[lang = "unsize"]
24-
pub trait Unsize<T: ?Sized> {}
30+
pub trait Unsize<T: PointeeSized>: PointeeSized {}
2531

2632
#[lang = "coerce_unsized"]
2733
pub trait CoerceUnsized<T> {}
2834

29-
impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
30-
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {}
31-
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
32-
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
35+
impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a U> for &'b T {}
36+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a mut U> for &'a mut T {}
37+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for *const T {}
38+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*mut U> for *mut T {}
3339

3440
#[lang = "dispatch_from_dyn"]
3541
pub trait DispatchFromDyn<T> {}
3642

3743
// &T -> &U
38-
impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
44+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a U> for &'a T {}
3945
// &mut T -> &mut U
40-
impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut T {}
46+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a mut U> for &'a mut T {}
4147
// *const T -> *const U
42-
impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
48+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*const U> for *const T {}
4349
// *mut T -> *mut U
44-
impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
45-
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U, ()>> for Box<T, ()> {}
50+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*mut U> for *mut T {}
51+
impl<T: MetaSized + Unsize<U>, U: MetaSized> DispatchFromDyn<Box<U, ()>> for Box<T, ()> {}
4652

4753
#[lang = "legacy_receiver"]
4854
pub trait LegacyReceiver {}
4955

50-
impl<T: ?Sized> LegacyReceiver for &T {}
51-
impl<T: ?Sized> LegacyReceiver for &mut T {}
52-
impl<T: ?Sized, A: Allocator> LegacyReceiver for Box<T, A> {}
56+
impl<T: PointeeSized> LegacyReceiver for &T {}
57+
impl<T: PointeeSized> LegacyReceiver for &mut T {}
58+
impl<T: MetaSized> LegacyReceiver for Box<T> {}
5359

5460
#[lang = "receiver"]
5561
trait Receiver {
@@ -74,9 +80,9 @@ impl Copy for isize {}
7480
impl Copy for f32 {}
7581
impl Copy for f64 {}
7682
impl Copy for char {}
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 {}
83+
impl<'a, T: PointeeSized> Copy for &'a T {}
84+
impl<T: PointeeSized> Copy for *const T {}
85+
impl<T: PointeeSized> Copy for *mut T {}
8086

8187
#[lang = "sync"]
8288
pub unsafe trait Sync {}
@@ -92,17 +98,17 @@ unsafe impl Sync for i16 {}
9298
unsafe impl Sync for i32 {}
9399
unsafe impl Sync for isize {}
94100
unsafe impl Sync for char {}
95-
unsafe impl<'a, T: ?Sized> Sync for &'a T {}
101+
unsafe impl<'a, T: PointeeSized> Sync for &'a T {}
96102
unsafe impl Sync for [u8; 16] {}
97103

98104
#[lang = "freeze"]
99105
unsafe auto trait Freeze {}
100106

101-
unsafe impl<T: ?Sized> Freeze for PhantomData<T> {}
102-
unsafe impl<T: ?Sized> Freeze for *const T {}
103-
unsafe impl<T: ?Sized> Freeze for *mut T {}
104-
unsafe impl<T: ?Sized> Freeze for &T {}
105-
unsafe impl<T: ?Sized> Freeze for &mut T {}
107+
unsafe impl<T: PointeeSized> Freeze for PhantomData<T> {}
108+
unsafe impl<T: PointeeSized> Freeze for *const T {}
109+
unsafe impl<T: PointeeSized> Freeze for *mut T {}
110+
unsafe impl<T: PointeeSized> Freeze for &T {}
111+
unsafe impl<T: PointeeSized> Freeze for &mut T {}
106112

107113
#[lang = "structural_peq"]
108114
pub trait StructuralPartialEq {}
@@ -447,7 +453,7 @@ pub enum Option<T> {
447453
pub use Option::*;
448454

449455
#[lang = "phantom_data"]
450-
pub struct PhantomData<T: ?Sized>;
456+
pub struct PhantomData<T: PointeeSized>;
451457

452458
#[lang = "fn_once"]
453459
#[rustc_paren_sugar]
@@ -564,18 +570,18 @@ impl Allocator for Global {}
564570
#[repr(transparent)]
565571
#[rustc_layout_scalar_valid_range_start(1)]
566572
#[rustc_nonnull_optimization_guaranteed]
567-
pub struct NonNull<T: ?Sized>(pub *const T);
573+
pub struct NonNull<T: PointeeSized>(pub *const T);
568574

569-
impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
570-
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
575+
impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
576+
impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
571577

572-
pub struct Unique<T: ?Sized> {
578+
pub struct Unique<T: PointeeSized> {
573579
pub pointer: NonNull<T>,
574580
pub _marker: PhantomData<T>,
575581
}
576582

577-
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
578-
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
583+
impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
584+
impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
579585

580586
#[lang = "owned_box"]
581587
pub struct Box<T: ?Sized, A: Allocator = Global>(Unique<T>, A);

compiler/rustc_data_structures/src/aligned.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::marker::PointeeSized;
12
use std::ptr::Alignment;
23

34
/// Returns the ABI-required minimum alignment of a type in bytes.
@@ -17,7 +18,7 @@ pub const fn align_of<T: ?Sized + Aligned>() -> Alignment {
1718
/// example `[T]` has alignment of `T`.
1819
///
1920
/// [`align_of::<Self>()`]: align_of
20-
pub unsafe trait Aligned {
21+
pub unsafe trait Aligned: PointeeSized {
2122
/// Alignment of `Self`.
2223
const ALIGN: Alignment;
2324
}

compiler/rustc_data_structures/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#![feature(ptr_alignment_type)]
3333
#![feature(rustc_attrs)]
3434
#![feature(rustdoc_internals)]
35+
#![feature(sized_hierarchy)]
3536
#![feature(test)]
3637
#![feature(thread_id_value)]
3738
#![feature(type_alias_impl_trait)]

compiler/rustc_data_structures/src/marker.rs

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::alloc::Allocator;
2+
use std::marker::PointeeSized;
23

34
#[diagnostic::on_unimplemented(message = "`{Self}` doesn't implement `DynSend`. \
45
Add it to `rustc_data_structures::marker` or use `IntoDynSyncSend` if it's already `Send`")]
@@ -15,7 +16,7 @@ pub unsafe auto trait DynSend {}
1516
pub unsafe auto trait DynSync {}
1617

1718
// Same with `Sync` and `Send`.
18-
unsafe impl<T: DynSync + ?Sized> DynSend for &T {}
19+
unsafe impl<T: DynSync + ?Sized + PointeeSized> DynSend for &T {}
1920

2021
macro_rules! impls_dyn_send_neg {
2122
($([$t1: ty $(where $($generics1: tt)*)?])*) => {
@@ -27,9 +28,9 @@ macro_rules! impls_dyn_send_neg {
2728
impls_dyn_send_neg!(
2829
[std::env::Args]
2930
[std::env::ArgsOs]
30-
[*const T where T: ?Sized]
31-
[*mut T where T: ?Sized]
32-
[std::ptr::NonNull<T> where T: ?Sized]
31+
[*const T where T: ?Sized + PointeeSized]
32+
[*mut T where T: ?Sized + PointeeSized]
33+
[std::ptr::NonNull<T> where T: ?Sized + PointeeSized]
3334
[std::rc::Rc<T, A> where T: ?Sized, A: Allocator]
3435
[std::rc::Weak<T, A> where T: ?Sized, A: Allocator]
3536
[std::sync::MutexGuard<'_, T> where T: ?Sized]
@@ -93,12 +94,12 @@ macro_rules! impls_dyn_sync_neg {
9394
impls_dyn_sync_neg!(
9495
[std::env::Args]
9596
[std::env::ArgsOs]
96-
[*const T where T: ?Sized]
97-
[*mut T where T: ?Sized]
97+
[*const T where T: ?Sized + PointeeSized]
98+
[*mut T where T: ?Sized + PointeeSized]
9899
[std::cell::Cell<T> where T: ?Sized]
99100
[std::cell::RefCell<T> where T: ?Sized]
100101
[std::cell::UnsafeCell<T> where T: ?Sized]
101-
[std::ptr::NonNull<T> where T: ?Sized]
102+
[std::ptr::NonNull<T> where T: ?Sized + PointeeSized]
102103
[std::rc::Rc<T, A> where T: ?Sized, A: Allocator]
103104
[std::rc::Weak<T, A> where T: ?Sized, A: Allocator]
104105
[std::cell::OnceCell<T> where T]
@@ -161,10 +162,10 @@ impl_dyn_sync!(
161162
[thin_vec::ThinVec<T> where T: DynSync]
162163
);
163164

164-
pub fn assert_dyn_sync<T: ?Sized + DynSync>() {}
165-
pub fn assert_dyn_send<T: ?Sized + DynSend>() {}
166-
pub fn assert_dyn_send_val<T: ?Sized + DynSend>(_t: &T) {}
167-
pub fn assert_dyn_send_sync_val<T: ?Sized + DynSync + DynSend>(_t: &T) {}
165+
pub fn assert_dyn_sync<T: ?Sized + PointeeSized + DynSync>() {}
166+
pub fn assert_dyn_send<T: ?Sized + PointeeSized + DynSend>() {}
167+
pub fn assert_dyn_send_val<T: ?Sized + PointeeSized + DynSend>(_t: &T) {}
168+
pub fn assert_dyn_send_sync_val<T: ?Sized + PointeeSized + DynSync + DynSend>(_t: &T) {}
168169

169170
#[derive(Copy, Clone)]
170171
pub struct FromDyn<T>(T);
@@ -217,10 +218,10 @@ impl<T> std::ops::DerefMut for FromDyn<T> {
217218
// an instance of `DynSend` and `DynSync`, since the compiler cannot infer
218219
// it automatically in some cases. (e.g. Box<dyn Send / Sync>)
219220
#[derive(Copy, Clone)]
220-
pub struct IntoDynSyncSend<T: ?Sized>(pub T);
221+
pub struct IntoDynSyncSend<T: ?Sized + PointeeSized>(pub T);
221222

222-
unsafe impl<T: ?Sized + Send> DynSend for IntoDynSyncSend<T> {}
223-
unsafe impl<T: ?Sized + Sync> DynSync for IntoDynSyncSend<T> {}
223+
unsafe impl<T: ?Sized + PointeeSized + Send> DynSend for IntoDynSyncSend<T> {}
224+
unsafe impl<T: ?Sized + PointeeSized + Sync> DynSync for IntoDynSyncSend<T> {}
224225

225226
impl<T> std::ops::Deref for IntoDynSyncSend<T> {
226227
type Target = T;

compiler/rustc_feature/src/unstable.rs

+2
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ declare_features! (
235235
(internal, profiler_runtime, "1.18.0", None),
236236
/// Allows using `rustc_*` attributes (RFC 572).
237237
(internal, rustc_attrs, "1.0.0", None),
238+
/// Introduces a hierarchy of `Sized` traits (RFC 3729).
239+
(unstable, sized_hierarchy, "CURRENT_RUSTC_VERSION", None),
238240
/// Allows using the `#[stable]` and `#[unstable]` attributes.
239241
(internal, staged_api, "1.0.0", None),
240242
/// Added for testing unstable lints; perma-unstable.

compiler/rustc_hir/src/lang_items.rs

+2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ pub fn extract(attrs: &[impl AttributeExt]) -> Option<(Symbol, Span)> {
165165
language_item_table! {
166166
// Variant name, Name, Getter method name, Target Generic requirements;
167167
Sized, sym::sized, sized_trait, Target::Trait, GenericRequirement::Exact(0);
168+
MetaSized, sym::meta_sized, meta_sized_trait, Target::Trait, GenericRequirement::Exact(0);
169+
PointeeSized, sym::pointee_sized, pointee_sized_trait, Target::Trait, GenericRequirement::Exact(0);
168170
Unsize, sym::unsize, unsize_trait, Target::Trait, GenericRequirement::Minimum(1);
169171
/// Trait injected by `#[derive(PartialEq)]`, (i.e. "Partial EQ").
170172
StructuralPeq, sym::structural_peq, structural_peq_trait, Target::Trait, GenericRequirement::None;

0 commit comments

Comments
 (0)