Skip to content

Commit 256c6ac

Browse files
committed
Auto merge of rust-lang#137944 - davidtwco:sized-hierarchy, r=<try>
Sized Hierarchy This patch implements rust-lang/rfcs#3729. It introduces two new traits to the standard library, `MetaSized` and `PointeeSized`, and makes `MetaSized` and `Sized` into const traits (relying on unstable `feature(const_trait_impl)`). 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 migrations which are necessary to preserve backwards compatibility given the introduction of these traits, which are implemented and as follows: - On the current edition, `Sized` is rewritten as `const Sized` - If the `sized_hierarchy` feature is enabled, then an edition migration lint to rewrite the bound to `const Sized` will be emitted. - On the next edition, non-const `Sized` will resume being the default bound. - On the current edition, `?Sized` is rewritten as `const MetaSized` - If the `sized_hierarchy` feature is enabled, then an edition migration lint to rewrite the bound to `const MetaSized` will be emitted. - On the next edition, writing `?Sized` will be prohibited. - On the current edition, `const MetaSized` is added as a default supertrait for all traits w/out an explicit sizedness supertrait already. - If the `sized_hierarchy` feature is enabled, then an edition migration lint to add an explicit `const MetaSized` supertrait will be emitted. - On the next edition, there is no default `const MetaSized` supertrait. Each of these migrations is not conditional on whether the item being migrated *needs* the migration to the stricter bound - this would be preferable but is not yet implemented (if it is possible to implement). All diagnostic output should remain the same (showing `?Sized` even if the compiler sees `const 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). Only once `sized_hierarchy` is stabilised would edition migration lints start to be emitted and diagnostic output show the "real" sizedness traits behind-the-scenes, rather than `?Sized`. 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 (library: +573/-184, compiler: +1268/-310, tests: +3720/-452). - It is expected that this will have performance regressions initially and I'll aim to resolve those prior to merging if possible. - I'd appreciate feedback on how best to go about this from those familiar with the type system. - On my local machine, this passes all of the test suites, a stage two build and a tidy check. - `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 259fdb5 + 121b836 commit 256c6ac

File tree

288 files changed

+5429
-1078
lines changed

Some content is hidden

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

288 files changed

+5429
-1078
lines changed

compiler/rustc_codegen_cranelift/example/mini_core.rs

+40-31
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,22 @@
99
transparent_unions,
1010
auto_traits,
1111
freeze_impls,
12-
thread_local
12+
thread_local,
13+
const_trait_impl
1314
)]
1415
#![no_core]
1516
#![allow(dead_code, internal_features, ambiguous_wide_pointer_comparisons)]
1617

18+
#[lang = "pointee_sized"]
19+
pub trait PointeeSized {}
20+
21+
#[lang = "meta_sized"]
22+
#[const_trait]
23+
pub trait MetaSized: PointeeSized {}
24+
1725
#[lang = "sized"]
18-
pub trait Sized {}
26+
#[const_trait]
27+
pub trait Sized: MetaSized {}
1928

2029
#[lang = "destruct"]
2130
pub trait Destruct {}
@@ -24,35 +33,35 @@ pub trait Destruct {}
2433
pub trait Tuple {}
2534

2635
#[lang = "unsize"]
27-
pub trait Unsize<T: ?Sized> {}
36+
pub trait Unsize<T: PointeeSized>: PointeeSized {}
2837

2938
#[lang = "coerce_unsized"]
3039
pub trait CoerceUnsized<T> {}
3140

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 {}
41+
impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a U> for &'b T {}
42+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a mut U> for &'a mut T {}
43+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for *const T {}
44+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*mut U> for *mut T {}
3645

3746
#[lang = "dispatch_from_dyn"]
3847
pub trait DispatchFromDyn<T> {}
3948

4049
// &T -> &U
41-
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
50+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a U> for &'a T {}
4251
// &mut T -> &mut U
43-
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut T {}
52+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a mut U> for &'a mut T {}
4453
// *const T -> *const U
45-
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
54+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*const U> for *const T {}
4655
// *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> {}
56+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*mut U> for *mut T {}
57+
impl<T: MetaSized + Unsize<U>, U: MetaSized> DispatchFromDyn<Box<U>> for Box<T> {}
4958

5059
#[lang = "legacy_receiver"]
5160
pub trait LegacyReceiver {}
5261

53-
impl<T: ?Sized> LegacyReceiver for &T {}
54-
impl<T: ?Sized> LegacyReceiver for &mut T {}
55-
impl<T: ?Sized> LegacyReceiver for Box<T> {}
62+
impl<T: PointeeSized> LegacyReceiver for &T {}
63+
impl<T: PointeeSized> LegacyReceiver for &mut T {}
64+
impl<T: MetaSized> LegacyReceiver for Box<T> {}
5665

5766
#[lang = "copy"]
5867
pub trait Copy {}
@@ -74,9 +83,9 @@ impl Copy for isize {}
7483
impl Copy for f32 {}
7584
impl Copy for f64 {}
7685
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 {}
86+
impl<'a, T: PointeeSized> Copy for &'a T {}
87+
impl<T: PointeeSized> Copy for *const T {}
88+
impl<T: PointeeSized> Copy for *mut T {}
8089
impl<T: Copy> Copy for Option<T> {}
8190

8291
#[lang = "sync"]
@@ -94,17 +103,17 @@ unsafe impl Sync for i32 {}
94103
unsafe impl Sync for isize {}
95104
unsafe impl Sync for char {}
96105
unsafe impl Sync for f32 {}
97-
unsafe impl<'a, T: ?Sized> Sync for &'a T {}
106+
unsafe impl<'a, T: PointeeSized> Sync for &'a T {}
98107
unsafe impl<T: Sync, const N: usize> Sync for [T; N] {}
99108

100109
#[lang = "freeze"]
101110
unsafe auto trait Freeze {}
102111

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 {}
112+
unsafe impl<T: PointeeSized> Freeze for PhantomData<T> {}
113+
unsafe impl<T: PointeeSized> Freeze for *const T {}
114+
unsafe impl<T: PointeeSized> Freeze for *mut T {}
115+
unsafe impl<T: PointeeSized> Freeze for &T {}
116+
unsafe impl<T: PointeeSized> Freeze for &mut T {}
108117

109118
#[lang = "structural_peq"]
110119
pub trait StructuralPartialEq {}
@@ -443,7 +452,7 @@ pub enum Option<T> {
443452
pub use Option::*;
444453

445454
#[lang = "phantom_data"]
446-
pub struct PhantomData<T: ?Sized>;
455+
pub struct PhantomData<T: PointeeSized>;
447456

448457
#[lang = "fn_once"]
449458
#[rustc_paren_sugar]
@@ -546,18 +555,18 @@ pub trait Deref {
546555
#[repr(transparent)]
547556
#[rustc_layout_scalar_valid_range_start(1)]
548557
#[rustc_nonnull_optimization_guaranteed]
549-
pub struct NonNull<T: ?Sized>(pub *const T);
558+
pub struct NonNull<T: PointeeSized>(pub *const T);
550559

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> {}
560+
impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
561+
impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
553562

554-
pub struct Unique<T: ?Sized> {
563+
pub struct Unique<T: PointeeSized> {
555564
pub pointer: NonNull<T>,
556565
pub _marker: PhantomData<T>,
557566
}
558567

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> {}
568+
impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
569+
impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
561570

562571
#[lang = "global_alloc_ty"]
563572
pub struct Global;

compiler/rustc_codegen_gcc/example/mini_core.rs

+39-31
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![feature(
22
no_core, lang_items, intrinsics, unboxed_closures, extern_types,
33
decl_macro, rustc_attrs, transparent_unions, auto_traits, freeze_impls,
4-
thread_local
4+
thread_local, const_trait_impl
55
)]
66
#![no_core]
77
#![allow(dead_code, internal_features, ambiguous_wide_pointer_comparisons)]
@@ -11,8 +11,16 @@ 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+
#[const_trait]
19+
pub trait MetaSized: PointeeSized {}
20+
1421
#[lang = "sized"]
15-
pub trait Sized {}
22+
#[const_trait]
23+
pub trait Sized: MetaSized {}
1624

1725
#[lang = "destruct"]
1826
pub trait Destruct {}
@@ -21,35 +29,35 @@ pub trait Destruct {}
2129
pub trait Tuple {}
2230

2331
#[lang = "unsize"]
24-
pub trait Unsize<T: ?Sized> {}
32+
pub trait Unsize<T: PointeeSized>: PointeeSized {}
2533

2634
#[lang = "coerce_unsized"]
2735
pub trait CoerceUnsized<T> {}
2836

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 {}
37+
impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a U> for &'b T {}
38+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a mut U> for &'a mut T {}
39+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*const U> for *const T {}
40+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<*mut U> for *mut T {}
3341

3442
#[lang = "dispatch_from_dyn"]
3543
pub trait DispatchFromDyn<T> {}
3644

3745
// &T -> &U
38-
impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {}
46+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a U> for &'a T {}
3947
// &mut T -> &mut U
40-
impl<'a, T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<&'a mut U> for &'a mut T {}
48+
impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a mut U> for &'a mut T {}
4149
// *const T -> *const U
42-
impl<T: ?Sized+Unsize<U>, U: ?Sized> DispatchFromDyn<*const U> for *const T {}
50+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*const U> for *const T {}
4351
// *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, ()> {}
52+
impl<T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<*mut U> for *mut T {}
53+
impl<T: MetaSized + Unsize<U>, U: MetaSized> DispatchFromDyn<Box<U, ()>> for Box<T, ()> {}
4654

4755
#[lang = "legacy_receiver"]
4856
pub trait LegacyReceiver {}
4957

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> {}
58+
impl<T: PointeeSized> LegacyReceiver for &T {}
59+
impl<T: PointeeSized> LegacyReceiver for &mut T {}
60+
impl<T: MetaSized> LegacyReceiver for Box<T> {}
5361

5462
#[lang = "copy"]
5563
pub trait Copy {}
@@ -70,9 +78,9 @@ impl Copy for isize {}
7078
impl Copy for f32 {}
7179
impl Copy for f64 {}
7280
impl Copy for char {}
73-
impl<'a, T: ?Sized> Copy for &'a T {}
74-
impl<T: ?Sized> Copy for *const T {}
75-
impl<T: ?Sized> Copy for *mut T {}
81+
impl<'a, T: PointeeSized> Copy for &'a T {}
82+
impl<T: PointeeSized> Copy for *const T {}
83+
impl<T: PointeeSized> Copy for *mut T {}
7684

7785
#[lang = "sync"]
7886
pub unsafe trait Sync {}
@@ -88,17 +96,17 @@ unsafe impl Sync for i16 {}
8896
unsafe impl Sync for i32 {}
8997
unsafe impl Sync for isize {}
9098
unsafe impl Sync for char {}
91-
unsafe impl<'a, T: ?Sized> Sync for &'a T {}
99+
unsafe impl<'a, T: PointeeSized> Sync for &'a T {}
92100
unsafe impl Sync for [u8; 16] {}
93101

94102
#[lang = "freeze"]
95103
unsafe auto trait Freeze {}
96104

97-
unsafe impl<T: ?Sized> Freeze for PhantomData<T> {}
98-
unsafe impl<T: ?Sized> Freeze for *const T {}
99-
unsafe impl<T: ?Sized> Freeze for *mut T {}
100-
unsafe impl<T: ?Sized> Freeze for &T {}
101-
unsafe impl<T: ?Sized> Freeze for &mut T {}
105+
unsafe impl<T: PointeeSized> Freeze for PhantomData<T> {}
106+
unsafe impl<T: PointeeSized> Freeze for *const T {}
107+
unsafe impl<T: PointeeSized> Freeze for *mut T {}
108+
unsafe impl<T: PointeeSized> Freeze for &T {}
109+
unsafe impl<T: PointeeSized> Freeze for &mut T {}
102110

103111
#[lang = "structural_peq"]
104112
pub trait StructuralPartialEq {}
@@ -403,7 +411,7 @@ pub enum Option<T> {
403411
pub use Option::*;
404412

405413
#[lang = "phantom_data"]
406-
pub struct PhantomData<T: ?Sized>;
414+
pub struct PhantomData<T: PointeeSized>;
407415

408416
#[lang = "fn_once"]
409417
#[rustc_paren_sugar]
@@ -520,18 +528,18 @@ impl Allocator for Global {}
520528
#[repr(transparent)]
521529
#[rustc_layout_scalar_valid_range_start(1)]
522530
#[rustc_nonnull_optimization_guaranteed]
523-
pub struct NonNull<T: ?Sized>(pub *const T);
531+
pub struct NonNull<T: PointeeSized>(pub *const T);
524532

525-
impl<T: ?Sized, U: ?Sized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
526-
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
533+
impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
534+
impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<NonNull<U>> for NonNull<T> where T: Unsize<U> {}
527535

528-
pub struct Unique<T: ?Sized> {
536+
pub struct Unique<T: PointeeSized> {
529537
pub pointer: NonNull<T>,
530538
pub _marker: PhantomData<T>,
531539
}
532540

533-
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
534-
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
541+
impl<T: PointeeSized, U: PointeeSized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
542+
impl<T: PointeeSized, U: PointeeSized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
535543

536544
#[lang = "owned_box"]
537545
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

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#![allow(internal_features)]
1111
#![allow(rustc::default_hash_types)]
1212
#![allow(rustc::potential_query_instability)]
13+
#![cfg_attr(not(bootstrap), allow(sized_hierarchy_migration))]
1314
#![deny(unsafe_op_in_unsafe_fn)]
1415
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1516
#![doc(rust_logo)]
@@ -32,6 +33,7 @@
3233
#![feature(ptr_alignment_type)]
3334
#![feature(rustc_attrs)]
3435
#![feature(rustdoc_internals)]
36+
#![feature(sized_hierarchy)]
3537
#![feature(test)]
3638
#![feature(thread_id_value)]
3739
#![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
#[rustc_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);
@@ -204,10 +205,10 @@ impl<T> std::ops::Deref for FromDyn<T> {
204205
// an instance of `DynSend` and `DynSync`, since the compiler cannot infer
205206
// it automatically in some cases. (e.g. Box<dyn Send / Sync>)
206207
#[derive(Copy, Clone)]
207-
pub struct IntoDynSyncSend<T: ?Sized>(pub T);
208+
pub struct IntoDynSyncSend<T: ?Sized + PointeeSized>(pub T);
208209

209-
unsafe impl<T: ?Sized + Send> DynSend for IntoDynSyncSend<T> {}
210-
unsafe impl<T: ?Sized + Sync> DynSync for IntoDynSyncSend<T> {}
210+
unsafe impl<T: ?Sized + PointeeSized + Send> DynSend for IntoDynSyncSend<T> {}
211+
unsafe impl<T: ?Sized + PointeeSized + Sync> DynSync for IntoDynSyncSend<T> {}
211212

212213
impl<T> std::ops::Deref for IntoDynSyncSend<T> {
213214
type Target = T;

0 commit comments

Comments
 (0)