-
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 <[email protected]>
For those following along or catching up, these are the notable the changes to the RFC since this was posted:
And these are all the other smaller changes that don't materially impact what is being proposed:
I've yet to respond to and/or incorporate the following comments, but will be working on those this week:
At the moment, I prefer the following alternatives to the primary proposal of the RFC, and may re-write to incorporate these as the primary proposal:
|
I guess I just disagree with this. It's a subjective statement anyway. I would appreciate if the RFC could list the syntax as an unresolved question: should there be some clear syntactic marker that the default bound is removed, or are we okay with that being an entirely implicit side-effect of adding another bound? I am not sure if it is necessary to commit to a particular syntax for this already, and seeing this used in practice will help determine how confusing it really is. As one point for why this is confusing, imagine I have trait MyTrait: const ValueSized {} and now I write
👍 , given that all the types we currently have determine their size based on the metadata, not the value, this seems prudent. The name of
So the idea is that
|
I've added this as an unresolved question.
That makes sense. You're right that
I've added this as an unresolved question too.
I've added explicit parentheses to make this clearer for now until a |
| `Sized` | `T: Sized` | `T: ?(const Sized) + Sized` | | ||
| `const ValueSized` | `T: const ValueSized` | `T: ?(const Sized) + const ValueSized` | | ||
| `ValueSized` | `T: ValueSized` | `T: ?(const Sized) + ValueSized` | | ||
| `Pointee` | `T: Pointee` | `T: ?(const Sized)` | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| `Pointee` | `T: Pointee` | `T: ?(const Sized)` | | |
| `Pointee` | `T: Pointee` | `T: ?(const Sized) + Pointee` | |
in the future some types may not implement Pointee
such as wasm externref
types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true but I've written all of the guide-level and reference-level explanation sections assuming that the future possibilities are not included.
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