-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Extend pointer cast to be able to return thin (including extern) types #101259
Conversation
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
This is achievable today using a normal `as` cast when the type is known, but allowing this makes it possible to easily cast extern types in generic contexts, as well as `cast` being generally preferable to `as`.
1cd0b45
to
004288e
Compare
The job Click to see the possible cause of the failure (guessed by this bot)
|
One approach would be to create |
☔ The latest upstream changes (presumably #105262) made this pull request unmergeable. Please resolve the merge conflicts. |
Yeah, I didn't really have the time to dig further into it, so I just kinda left it. Thanks for responding and following up! |
Motivation: To make migrating to
extern type
easier.While this type of casting is achievable today using a normal
as
cast, it requires that the type is known since the compiler doesn't know that it can handle aThin
bound specially. While that would also be nice to fix, this PR is at least a first step.Unsure of how to proceed with this, as the implementation now uses
from_raw_parts
andfrom_raw_parts_mut
which are unstable inconst
contexts.Relatedly, see #93959.