Skip to content

Commit eba2d19

Browse files
committed
Auto merge of #137944 - davidtwco:sized-hierarchy, r=oli-obk
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) - FCP in #137944 (comment) Fixes #79409. r? `@ghost` (I'll discuss this with relevant teams to find a reviewer)
2 parents 8da6239 + c290ee6 commit eba2d19

File tree

283 files changed

+4109
-1024
lines changed

Some content is hidden

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

283 files changed

+4109
-1024
lines changed

compiler/rustc_codegen_cranelift/example/mini_core.rs

Lines changed: 36 additions & 30 deletions
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]
@@ -564,18 +570,18 @@ pub trait Deref {
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 = "global_alloc_ty"]
581587
pub struct Global;

compiler/rustc_codegen_gcc/example/mini_core.rs

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@ unsafe extern "C" fn _Unwind_Resume() {
1919
intrinsics::unreachable();
2020
}
2121

22+
#[lang = "pointee_sized"]
23+
pub trait PointeeSized {}
24+
25+
#[lang = "meta_sized"]
26+
pub trait MetaSized: PointeeSized {}
27+
2228
#[lang = "sized"]
23-
pub trait Sized {}
29+
pub trait Sized: MetaSized {}
2430

2531
#[lang = "destruct"]
2632
pub trait Destruct {}
@@ -29,35 +35,35 @@ pub trait Destruct {}
2935
pub trait Tuple {}
3036

3137
#[lang = "unsize"]
32-
pub trait Unsize<T: ?Sized> {}
38+
pub trait Unsize<T: PointeeSized>: PointeeSized {}
3339

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

37-
impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
38-
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {}
39-
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*const U> for *const T {}
40-
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
43+
impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a U> for &'b T {}
44+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a mut U> for &'a mut T {}
45+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for *const T {}
46+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*mut U> for *mut T {}
4147

4248
#[lang = "dispatch_from_dyn"]
4349
pub trait DispatchFromDyn<T> {}
4450

4551
// &T -> &U
46-
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
52+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a U> for &'a T {}
4753
// &mut T -> &mut U
48-
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut T {}
54+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a mut U> for &'a mut T {}
4955
// *const T -> *const U
50-
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
56+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*const U> for *const T {}
5157
// *mut T -> *mut U
52-
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<*mut U> for *mut T {}
53-
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U, ()>> for Box<T, ()> {}
58+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*mut U> for *mut T {}
59+
impl<T: MetaSized + Unsize<U>, U: MetaSized> DispatchFromDyn<Box<U, ()>> for Box<T, ()> {}
5460

5561
#[lang = "legacy_receiver"]
5662
pub trait LegacyReceiver {}
5763

58-
impl<T: ?Sized> LegacyReceiver for &T {}
59-
impl<T: ?Sized> LegacyReceiver for &mut T {}
60-
impl<T: ?Sized, A: Allocator> LegacyReceiver for Box<T, A> {}
64+
impl<T: PointeeSized> LegacyReceiver for &T {}
65+
impl<T: PointeeSized> LegacyReceiver for &mut T {}
66+
impl<T: MetaSized> LegacyReceiver for Box<T> {}
6167

6268
#[lang = "receiver"]
6369
trait Receiver {}
@@ -84,9 +90,9 @@ impl Copy for i128 {}
8490
impl Copy for f32 {}
8591
impl Copy for f64 {}
8692
impl Copy for char {}
87-
impl<'a, T: ?Sized> Copy for &'a T {}
88-
impl<T: ?Sized> Copy for *const T {}
89-
impl<T: ?Sized> Copy for *mut T {}
93+
impl<'a, T: PointeeSized> Copy for &'a T {}
94+
impl<T: PointeeSized> Copy for *const T {}
95+
impl<T: PointeeSized> Copy for *mut T {}
9096

9197
#[lang = "sync"]
9298
pub unsafe trait Sync {}
@@ -102,17 +108,17 @@ unsafe impl Sync for i16 {}
102108
unsafe impl Sync for i32 {}
103109
unsafe impl Sync for isize {}
104110
unsafe impl Sync for char {}
105-
unsafe impl<'a, T: ?Sized> Sync for &'a T {}
111+
unsafe impl<'a, T: PointeeSized> Sync for &'a T {}
106112
unsafe impl Sync for [u8; 16] {}
107113

108114
#[lang = "freeze"]
109115
unsafe auto trait Freeze {}
110116

111-
unsafe impl<T: ?Sized> Freeze for PhantomData<T> {}
112-
unsafe impl<T: ?Sized> Freeze for *const T {}
113-
unsafe impl<T: ?Sized> Freeze for *mut T {}
114-
unsafe impl<T: ?Sized> Freeze for &T {}
115-
unsafe impl<T: ?Sized> Freeze for &mut T {}
117+
unsafe impl<T: PointeeSized> Freeze for PhantomData<T> {}
118+
unsafe impl<T: PointeeSized> Freeze for *const T {}
119+
unsafe impl<T: PointeeSized> Freeze for *mut T {}
120+
unsafe impl<T: PointeeSized> Freeze for &T {}
121+
unsafe impl<T: PointeeSized> Freeze for &mut T {}
116122

117123
#[lang = "structural_peq"]
118124
pub trait StructuralPartialEq {}
@@ -456,7 +462,7 @@ pub enum Option<T> {
456462
pub use Option::*;
457463

458464
#[lang = "phantom_data"]
459-
pub struct PhantomData<T: ?Sized>;
465+
pub struct PhantomData<T: PointeeSized>;
460466

461467
#[lang = "fn_once"]
462468
#[rustc_paren_sugar]
@@ -576,18 +582,18 @@ impl Allocator for Global {}
576582
#[repr(transparent)]
577583
#[rustc_layout_scalar_valid_range_start(1)]
578584
#[rustc_nonnull_optimization_guaranteed]
579-
pub struct NonNull<T: ?Sized>(pub *const T);
585+
pub struct NonNull<T: PointeeSized>(pub *const T);
580586

581-
impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
582-
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
587+
impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
588+
impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
583589

584-
pub struct Unique<T: ?Sized> {
590+
pub struct Unique<T: PointeeSized> {
585591
pub pointer: NonNull<T>,
586592
pub _marker: PhantomData<T>,
587593
}
588594

589-
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
590-
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
595+
impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
596+
impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
591597

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

compiler/rustc_data_structures/src/aligned.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::ptr::Alignment;
22

3+
use rustc_serialize::PointeeSized;
4+
35
/// Returns the ABI-required minimum alignment of a type in bytes.
46
///
57
/// This is equivalent to [`align_of`], but also works for some unsized
@@ -17,7 +19,7 @@ pub const fn align_of<T: ?Sized + Aligned>() -> Alignment {
1719
/// example `[T]` has alignment of `T`.
1820
///
1921
/// [`align_of::<Self>()`]: align_of
20-
pub unsafe trait Aligned {
22+
pub unsafe trait Aligned: PointeeSized {
2123
/// Alignment of `Self`.
2224
const ALIGN: Alignment;
2325
}

compiler/rustc_data_structures/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#![allow(rustc::potential_query_instability)]
1313
#![cfg_attr(bootstrap, feature(cfg_match))]
1414
#![cfg_attr(not(bootstrap), feature(cfg_select))]
15+
#![cfg_attr(not(bootstrap), feature(sized_hierarchy))]
1516
#![deny(unsafe_op_in_unsafe_fn)]
1617
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1718
#![doc(rust_logo)]
@@ -43,6 +44,9 @@ use std::fmt;
4344
pub use atomic_ref::AtomicRef;
4445
pub use ena::{snapshot_vec, undo_log, unify};
4546
pub use rustc_index::static_assert_size;
47+
// re-exported for `rustc_smir`
48+
// FIXME(sized_hierarchy): remove with `cfg(bootstrap)`, see `rustc_serialize/src/lib.rs`
49+
pub use rustc_serialize::PointeeSized;
4650

4751
pub mod aligned;
4852
pub mod base_n;

compiler/rustc_data_structures/src/marker.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use std::alloc::Allocator;
22

3+
use rustc_serialize::PointeeSized;
4+
35
#[diagnostic::on_unimplemented(message = "`{Self}` doesn't implement `DynSend`. \
46
Add it to `rustc_data_structures::marker` or use `IntoDynSyncSend` if it's already `Send`")]
57
// This is an auto trait for types which can be sent across threads if `sync::is_dyn_thread_safe()`
@@ -15,7 +17,7 @@ pub unsafe auto trait DynSend {}
1517
pub unsafe auto trait DynSync {}
1618

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

2022
macro_rules! impls_dyn_send_neg {
2123
($([$t1: ty $(where $($generics1: tt)*)?])*) => {
@@ -27,9 +29,9 @@ macro_rules! impls_dyn_send_neg {
2729
impls_dyn_send_neg!(
2830
[std::env::Args]
2931
[std::env::ArgsOs]
30-
[*const T where T: ?Sized]
31-
[*mut T where T: ?Sized]
32-
[std::ptr::NonNull<T> where T: ?Sized]
32+
[*const T where T: ?Sized + PointeeSized]
33+
[*mut T where T: ?Sized + PointeeSized]
34+
[std::ptr::NonNull<T> where T: ?Sized + PointeeSized]
3335
[std::rc::Rc<T, A> where T: ?Sized, A: Allocator]
3436
[std::rc::Weak<T, A> where T: ?Sized, A: Allocator]
3537
[std::sync::MutexGuard<'_, T> where T: ?Sized]
@@ -100,12 +102,12 @@ macro_rules! impls_dyn_sync_neg {
100102
impls_dyn_sync_neg!(
101103
[std::env::Args]
102104
[std::env::ArgsOs]
103-
[*const T where T: ?Sized]
104-
[*mut T where T: ?Sized]
105+
[*const T where T: ?Sized + PointeeSized]
106+
[*mut T where T: ?Sized + PointeeSized]
105107
[std::cell::Cell<T> where T: ?Sized]
106108
[std::cell::RefCell<T> where T: ?Sized]
107109
[std::cell::UnsafeCell<T> where T: ?Sized]
108-
[std::ptr::NonNull<T> where T: ?Sized]
110+
[std::ptr::NonNull<T> where T: ?Sized + PointeeSized]
109111
[std::rc::Rc<T, A> where T: ?Sized, A: Allocator]
110112
[std::rc::Weak<T, A> where T: ?Sized, A: Allocator]
111113
[std::cell::OnceCell<T> where T]
@@ -175,10 +177,10 @@ impl_dyn_sync!(
175177
[thin_vec::ThinVec<T> where T: DynSync]
176178
);
177179

178-
pub fn assert_dyn_sync<T: ?Sized + DynSync>() {}
179-
pub fn assert_dyn_send<T: ?Sized + DynSend>() {}
180-
pub fn assert_dyn_send_val<T: ?Sized + DynSend>(_t: &T) {}
181-
pub fn assert_dyn_send_sync_val<T: ?Sized + DynSync + DynSend>(_t: &T) {}
180+
pub fn assert_dyn_sync<T: ?Sized + PointeeSized + DynSync>() {}
181+
pub fn assert_dyn_send<T: ?Sized + PointeeSized + DynSend>() {}
182+
pub fn assert_dyn_send_val<T: ?Sized + PointeeSized + DynSend>(_t: &T) {}
183+
pub fn assert_dyn_send_sync_val<T: ?Sized + PointeeSized + DynSync + DynSend>(_t: &T) {}
182184

183185
#[derive(Copy, Clone)]
184186
pub struct FromDyn<T>(T);
@@ -231,10 +233,10 @@ impl<T> std::ops::DerefMut for FromDyn<T> {
231233
// an instance of `DynSend` and `DynSync`, since the compiler cannot infer
232234
// it automatically in some cases. (e.g. Box<dyn Send / Sync>)
233235
#[derive(Copy, Clone)]
234-
pub struct IntoDynSyncSend<T: ?Sized>(pub T);
236+
pub struct IntoDynSyncSend<T: ?Sized + PointeeSized>(pub T);
235237

236-
unsafe impl<T: ?Sized + Send> DynSend for IntoDynSyncSend<T> {}
237-
unsafe impl<T: ?Sized + Sync> DynSync for IntoDynSyncSend<T> {}
238+
unsafe impl<T: ?Sized + PointeeSized + Send> DynSend for IntoDynSyncSend<T> {}
239+
unsafe impl<T: ?Sized + PointeeSized + Sync> DynSync for IntoDynSyncSend<T> {}
238240

239241
impl<T> std::ops::Deref for IntoDynSyncSend<T> {
240242
type Target = T;

compiler/rustc_feature/src/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ declare_features! (
237237
(internal, profiler_runtime, "1.18.0", None),
238238
/// Allows using `rustc_*` attributes (RFC 572).
239239
(internal, rustc_attrs, "1.0.0", None),
240+
/// Introduces a hierarchy of `Sized` traits (RFC 3729).
241+
(unstable, sized_hierarchy, "CURRENT_RUSTC_VERSION", None),
240242
/// Allows using the `#[stable]` and `#[unstable]` attributes.
241243
(internal, staged_api, "1.0.0", None),
242244
/// Added for testing unstable lints; perma-unstable.

compiler/rustc_hir/src/lang_items.rs

Lines changed: 2 additions & 0 deletions
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)