-
Notifications
You must be signed in to change notification settings - Fork 108
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
[project] Initial commit #1934
base: main
Are you sure you want to change the base?
[project] Initial commit #1934
Conversation
This supersedes #1933, which has a soundness hole. This only supports sized types for now, but maybe we'll figure out a way to lift that limitation eventually. |
451d820
to
21338e0
Compare
TODO: Could we support unsized types so long as we never call offset_of! on the trailing unsized field? TODO: Use `Name` type parameter trick to emit better error messages: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=97771667892860935bea60b218f8fdf4 gherrit-pr-id: I54eb863c96f056738f58727fc0fec4e1630bf97a
21338e0
to
5ef235b
Compare
impl<'a, T, I> Ptr<'a, T, I> | ||
where | ||
T: 'a + ?Sized, | ||
I: Invariants, |
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.
Note that this can only ever be sound for invariants that structurally propagate to their fields. This doesn't apply for the Pin
invariant.
// NOTE: Doing the actual cast inside this function makes the `project!` | ||
// macro simpler, but it also means that we can't handle both const code and | ||
// unsized types at the same time. In order to be const, we can't call trait | ||
// methods, but in order to support unsized types, we'd need to provide a |
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.
For slice DSTs, all you need is the offset of the last field, which is the same for all sizes. This could be stored as a const
.
TODO: Could we support unsized types so long as we never call offset_of!
on the trailing unsized field?
TODO: Use
Name
type parameter trick to emit better error messages:https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=97771667892860935bea60b218f8fdf4
This PR is on branch projection-sized.