-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hierarchy of Sized traits #3729
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
Since there seems to be consensus on it, I've adopted the alternative for replacing |
Edit: oops, I see that thin What about thin And I absolutely want to be able to use thin |
Wow, a funny (but good!) feeling to think that this might finally get resolved after a decade. :)
I think
Also, I agree with @RalfJung than the After we do that, we we can debate syntax. In particular, the "Why have Pointee?" is a bit misleading in that semantically there currently is indeed no reason, it is just there for syntactic purposes. However, if we reuse At the point I still think it is good education to talk about the empty trait set as:
Oh and a final thing on semantics, I might also also present the back compat / editions story this way:
In particular, the existing old syntax maps to the new semantics via the old semantics; we can cleanly factor that into those two steps, and I think this brings conceptual clarity. |
imo having an associated type on practically every type will be annoying, so I think it might be useful to require writing |
the trait's unstable, if it's just a matter of bikeshedding we can rename the type |
I've added this as one of the unresolved questions.
I've rewritten this section, it should have been updated earlier with the addition of the alternatives which keep the
I haven't made these changes at the moment - I've had good feedback about the explanations in the RFC and would prefer not to make major changes to that until the proposal itself needs changing. |
I've updated the previous summary comment so it is still accurate. |
I've pushed one small change with a reference to the now-upstream const traits RFC in #3762. |
All of Rust's types are either sized, which implement the
Sized
trait and have a statically known size during compilation, or unsized, which do not implement theSized
trait and are assumed to have a size which can be computed at runtime. However, this dichotomy misses two categories of type - types whose size is unknown during compilation but is a runtime constant, and types whose size can never be known. Supporting the former is a prerequisite to stable scalable vector types and supporting the latter is a prerequisite to unblocking extern types. This RFC proposes a hierarchy ofSized
traits in order to be able to support these use cases.This RFC relies on experimental, yet-to-be-RFC'd const traits, so this is blocked on that. I haven't squashed any of the previous revisions but can do so if/when this is approved. Already discussed in the 2024-11-13 t-lang design meeting with feedback incorporated.
See this comment for the most recent summary of changes to this RFC since it was opened.
Rendered