-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Transmute doesn't work on arrays of generic types #80899
Comments
Hmm, that does seem weird. |
This compiles fine, so it's not that rustc thinks fn transmute_to_self<T: Sized>(v: [T; 10]) -> impl Sized {
v
} |
The error also comes from transmuting generics: fn transmute_to_self<T>(t: T) -> T {
unsafe { core::mem::transmute(t) }
} gives the same error. |
Looks like the code that does this check might not work on generic parameters: rust/compiler/rustc_passes/src/intrinsicck.rs Lines 71 to 73 in 26d451f
It does say that it's conservative: rust/compiler/rustc_middle/src/ty/layout.rs Lines 1792 to 1810 in 26d451f
|
See #61956 for a previously opened issue |
If and when the Project Safe Transmute's ext-layout-traits rfc goes through the process, |
Closing as duplicate of #61956 and removing |
I tried transmuting an array of [T; 10] to itself, but rustc gives an error.
Error:
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: