-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Make transmuting inhabited to uninhabited types an error #36489
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
Conversation
This changes the behaviour of the transmute intrinsic so that, for any uninhabited type `Void` and any inhabited type `NonVoid`: * transmute::<Void, T> is okay * transmute::<NonVoid, Void> is an error
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.
transmute::<Void, T> is okay
This can’t be possibly called, can it? Good thing you cannot get function pointer of an intrinsic, as making one up for this particular function would be kinda tricky :)
Overall this patch LGTM.
the issue code should probably be used as a regression test. |
@nagisa you can still construct a void by using |
Why are you making |
The hackyness begins at whatever level we start pretending that uninhabited types are ZSTs, so I agree that the lower we can push that the better. What exactly do you have in mind though?
Why not? It's always safe to transmute from an uninhabited type to anything else (every element of |
ping, what's the status of this? |
@alexcrichton It prolly needs the lang team to have a look at it and see if they agree with it. Other than that though it should be good to merge. |
/cc @rust-lang/lang Also, there's no reviewer for this? I'm not sure who should be assigned. |
r? @eddyb |
The patch is alright, I suppose, but I don't understand the motivation between this change. |
Correct. Because it's an insane thing to do and it has the same problems as |
I definitely want a bunch of warnings in this area, not so sure about outright errors. |
If we're thinking of holding off on this until we've settled more questions about uninitialized types, perhaps we should close in the meantime? (to help clear out the queue) |
@alexcrichton Righto. Closed for now. |
This changes the behaviour of the transmute intrinsic so that, for any
uninhabited type
Void
and any inhabited typeNonVoid
:transmute::<Void, T>
is okaytransmute::<NonVoid, Void>
is an error