-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
ICE: transmute: called Result::unwrap()
on an Err
value: ReferencesError(ErrorGuaranteed(()))
#129327
Comments
reduced a bit use std::mem::BikeshedIntrinsicFrom;
pub fn is_transmutable<Src, Dst>()
where
Dst: BikeshedIntrinsicFrom<Src>,
{
}
struct Src {
g: G,
}
fn main() {
is_transmutable::<&mut Src, &mut Dst>();
} |
Hm, the problem seems to stem from |
@jswrenn: I don't think so, since you're only encountering these error types on field projection. I recommend reworking the layout computation code to stop unwrapping and handle the layout errors gracefully. |
The downside of doing so is that any misconceptions I have about Is there a way to query whether a |
No, and also I think the particular unwrap in this case is very weird. I have no idea why it's unwrapping when it's only being called in functions that also only return |
Because it's important to get this right. For this scenario, the ideal thing to do might be to accept the transmute, because doing so will avoid emitting a distracting 'trait not implemented' error. But, in scenarios that don't involved malformed types where My ideal solution would be to detect at a top-level whether the involved types are well-formed, unconditionally accept the transmute if they are not, and retain the unwraps in |
I don't believe the correct fix is to bubble up That error struct already has variants to represent the layout errors this API should be handling. I don't see why you'd be turning them into |
Yeah, that sounds right — forgot we had that impl. For some reason, There's probably a UI test or issue somewhere that prompted that, but I agree that it smells. |
I recommend you change that one to handle layout errors gracefully, too. |
Of course; will do! |
Changes `.unwrap()`s to `?` to avoid ICEs. Adds ui tests. Fixes rust-lang#129327
Changes `.unwrap()`s to `?` to avoid ICEs. Adds ui tests. Fixes rust-lang#129327
…ompiler-errors safe transmute: gracefully bubble-up layout errors Changes `.unwrap()`s to `?` to avoid ICEs. Adds ui tests. Fixes rust-lang#129327 Tracking Issue: rust-lang#99571 r? `@compiler-errors`
Rollup merge of rust-lang#129364 - jswrenn:transmute-layout-errs, r=compiler-errors safe transmute: gracefully bubble-up layout errors Changes `.unwrap()`s to `?` to avoid ICEs. Adds ui tests. Fixes rust-lang#129327 Tracking Issue: rust-lang#99571 r? `@compiler-errors`
auto-reduced (treereduce-rust):
original:
Version information
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
@rustbot label +F-transmutability
The text was updated successfully, but these errors were encountered: