Sized Hierarchy: Part I by davidtwco · Pull Request #137944 · rust-lang/rust (original) (raw)

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

@davidtwco

This was referenced

Mar 3, 2025

@rustbot rustbot added the T-bootstrap

Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

label

Mar 3, 2025

workingjubilee

bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request

Jun 19, 2025

@bors

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 cfgs as this would make implementation unfeasible, there would simply be too many cfgs 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:

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:

Fixes rust-lang/rust#79409.

r? @ghost (I'll discuss this with relevant teams to find a reviewer)

github-merge-queue bot pushed a commit to model-checking/kani that referenced this pull request

Jun 24, 2025

@tautschnig

Relevant upstream PR: rust-lang/rust#137944 (Sized Hierarchy: Part I). This PR implements a part of RFC 3729, which prescribes a hierarchy of Sized traits. Notably, this disallows instantiation of size_of_val and align_of_val with extern types. Consequently, the code in tests unsized_foreign.rs as well as parts of foreign_type.rs no longer compile (when previously some of the tests would panic). These test were therefore removed.

Resolves: #4165

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this pull request

Jun 24, 2025

@bors

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 cfgs as this would make implementation unfeasible, there would simply be too many cfgs 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:

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:

Fixes rust-lang#79409.

r? @ghost (I'll discuss this with relevant teams to find a reviewer)

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request

Jun 27, 2025

@GuillaumeGomez

…r=lcnr

add #![rustc_no_implicit_bounds]

Follow-up from rust-lang#137944.

Adds a new rustc_attrs attribute that stops rustc from adding any default bounds. Useful for tests where default bounds just add noise and make debugging harder.

After reviewing all tests with ?Sized, these tests seem like they could probably benefit from #![rustc_no_implicit_bounds].

r? @lcnr

rust-timer added a commit that referenced this pull request

Jun 27, 2025

@rust-timer

Rollup merge of #142671 - davidtwco:no-default-bounds-attr, r=lcnr

add #![rustc_no_implicit_bounds]

Follow-up from #137944.

Adds a new rustc_attrs attribute that stops rustc from adding any default bounds. Useful for tests where default bounds just add noise and make debugging harder.

After reviewing all tests with ?Sized, these tests seem like they could probably benefit from #![rustc_no_implicit_bounds].

r? @lcnr

github-actions bot pushed a commit to rust-lang/miri that referenced this pull request

Jun 28, 2025

@GuillaumeGomez

add #![rustc_no_implicit_bounds]

Follow-up from rust-lang/rust#137944.

Adds a new rustc_attrs attribute that stops rustc from adding any default bounds. Useful for tests where default bounds just add noise and make debugging harder.

After reviewing all tests with ?Sized, these tests seem like they could probably benefit from #![rustc_no_implicit_bounds].

r? @lcnr

antoyo pushed a commit to rust-lang/rustc_codegen_gcc that referenced this pull request

Jun 28, 2025

@bors

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 cfgs as this would make implementation unfeasible, there would simply be too many cfgs 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:

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:

Fixes rust-lang/rust#79409.

r? @ghost (I'll discuss this with relevant teams to find a reviewer)

@lcnr lcnr mentioned this pull request

Jul 22, 2025

wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this pull request

Aug 11, 2025

@he32

Pkgsrc changes:

Upstream changes relative to 1.88.0:

Version 1.89.0 (2025-08-07)

Language

Compiler

Platform Support

Refer to Rust's platform support page for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These previously stable APIs are now stable in const contexts:

Cargo

Rustdoc

Compatibility Notes

Internal Changes

These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools.

tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request

Aug 12, 2025

@tmeijn

This MR contains the following updates:

Package Update Change
rust minor 1.88.0 -> 1.89.0

MR created with the help of el-capitano/tools/renovate-bot.

Proposed changes to behavior should be submitted there as MRs.


Release Notes

rust-lang/rust (rust)

v1.89.0

Compare Source

==========================

Language

Compiler

Platform Support

Refer to Rust's platform support page for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These previously stable APIs are now stable in const contexts:

Cargo

Rustdoc

Compatibility Notes

Internal Changes

These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools.


Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this MR and you won't be reminded about this update again.



This MR has been generated by Renovate Bot.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request

Oct 18, 2025

@he32

Pkgsrc changes:

Upstream changes:

Version 1.90 (2025-09-18)

Language

Compiler

Platform Support

Refer to Rust's platform support page for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These previously stable APIs are now stable in const contexts:

Cargo

Rustdoc

Compatibility Notes

Version 1.89.0 (2025-08-07)

Language

Compiler

Platform Support

Refer to Rust's platform support page for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These previously stable APIs are now stable in const contexts:

Cargo

Rustdoc

Compatibility Notes

Internal Changes

These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request

Oct 23, 2025

@he32

Pkgsrc changes:

Upstream changes:

Version 1.90 (2025-09-18)

Language

Compiler

Platform Support

Refer to Rust's platform support page for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These previously stable APIs are now stable in const contexts:

Cargo

Rustdoc

Compatibility Notes

Version 1.89.0 (2025-08-07)

Language

Compiler

Platform Support

Refer to Rust's platform support page for more information on Rust's tiered platform support.

Libraries

Stabilized APIs

These previously stable APIs are now stable in const contexts:

Cargo

Rustdoc

Compatibility Notes

Internal Changes

These changes do not affect any public interfaces of Rust, but they represent significant improvements to the performance or internals of rustc and related tools.

theemathas added a commit to theemathas/rust that referenced this pull request

Dec 10, 2025

@theemathas

These TrivialClone impls previously had ?Sized bounds, which are different from the PointeeSized bounds on the corresponding Clone and Copy impls. So, I've changed the ?Sized bounds into PointeeSized bounds.

This mistake was made presumably because the TrivialClone PR (rust-lang#135634) was opened in Jan 2025, but merged in Nov 2025. During that time, the sized hierachy PR (rust-lang#137944) was opened in Mar 2025, and merged in Jun 2025. The TrivialClone PR was not updated to account for the sized hierachy changes.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Dec 10, 2025

@matthiaskrgr

…ized, r=joboet

Use PointeeSized bound for TrivialClone impls

These TrivialClone impls previously had ?Sized bounds, which are different from the PointeeSized bounds on the corresponding Clone and Copy impls. So, I've changed the ?Sized bounds into PointeeSized bounds.

This mistake was made presumably because the TrivialClone PR (rust-lang#135634) was opened in Jan 2025, but merged in Nov 2025. During that time, the sized hierachy PR (rust-lang#137944) was opened in Mar 2025, and merged in Jun 2025. The TrivialClone PR was not updated to account for the sized hierachy changes.

r? @joboet

rust-timer added a commit that referenced this pull request

Dec 10, 2025

@rust-timer

Rollup merge of #149839 - theemathas:trivial-clone-pointee-sized, r=joboet

Use PointeeSized bound for TrivialClone impls

These TrivialClone impls previously had ?Sized bounds, which are different from the PointeeSized bounds on the corresponding Clone and Copy impls. So, I've changed the ?Sized bounds into PointeeSized bounds.

This mistake was made presumably because the TrivialClone PR (#135634) was opened in Jan 2025, but merged in Nov 2025. During that time, the sized hierachy PR (#137944) was opened in Mar 2025, and merged in Jun 2025. The TrivialClone PR was not updated to account for the sized hierachy changes.

r? @joboet