Skip to content
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

Support prefix transmutes in transmute! et al #1852

Open
joshlf opened this issue Oct 8, 2024 · 1 comment · May be fixed by #2024
Open

Support prefix transmutes in transmute! et al #1852

joshlf opened this issue Oct 8, 2024 · 1 comment · May be fixed by #2024
Labels
experience-hard This issue is hard, and requires a lot of experience help wanted Extra attention is needed

Comments

@joshlf
Copy link
Member

joshlf commented Oct 8, 2024

Syntax

We should be able to add special syntax so that existing uses of transmute! are unaffected, while users are able to opt-in to prefix transmute behavior:

// Current behavior, remains the default.
transmute!(a);
// Opt-in to prefix transmutation (exact syntax to be bikeshedded)
transmute!(@prefix a);

Design

Currently, we require that mem::transmute::<T, U>() compiles, which ensures that size_of::<T>() == size_of::<U>(). If we instead introduce a union MaxSizesOf<T, U> type, then we can instead require that mem::transmute::<MaxSizesOf<T, U>, T>() compiles. This ensures that size_of::<T>() >= size_of::<U>(), which ensures that it's sound to perform a prefix transmute from T to U.

@joshlf joshlf added help wanted Extra attention is needed experience-hard This issue is hard, and requires a lot of experience labels Oct 23, 2024
@Aditya-PS-05
Copy link
Contributor

Can you assign me this issue? Though I have beginner to medium level experience, I can try to solve it/

@Aditya-PS-05 Aditya-PS-05 linked a pull request Nov 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experience-hard This issue is hard, and requires a lot of experience help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants