-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Regression ICE - broken MIR under -C opt-level=s
on if let Some(v) = None as Option<...>
#88307
Comments
@c410-f3r @matthewjasper - We're encountering this new ICE since early last week, and it looks like it started when #80357 landed. Can you take a look? |
Playground, ICE happens in release builds. |
Reduced. Wildcard and primitive values don't trigger ICE. fn main() {
if let Some(_val) = None as Option<String> {
}
} I will do my best to fix this issue but I might not be the fastest |
Looks like a joined block is dropping state only initialized on the "true/then" side. |
FYI, I confirmed the problem was introduced in #80357. |
Assigning priority as discussed in the Zulip thread of the Prioritization Working Group. @rustbot label -I-prioritize +P-high |
MIR diff of unoptimized to optimized fn main() -> () {
let mut _0: (); // return place in scope 0 at src/test/ui/issues/issue-88307.rs:4:11: 4:11
let mut _1: std::option::Option<std::string::String>; // in scope 0 at src/test/ui/issues/issue-88307.rs:5:25: 5:47
let _2: std::string::String; // in scope 0 at src/test/ui/issues/issue-88307.rs:5:17: 5:21
let mut _3: bool; // in scope 0 at src/test/ui/issues/issue-88307.rs:6:5: 6:6
let mut _4: bool; // in scope 0 at src/test/ui/issues/issue-88307.rs:7:1: 7:2
let mut _5: isize; // in scope 0 at src/test/ui/issues/issue-88307.rs:7:1: 7:2
let mut _6: isize; // in scope 0 at src/test/ui/issues/issue-88307.rs:7:1: 7:2
scope 1 {
debug _val => _2; // in scope 1 at src/test/ui/issues/issue-88307.rs:5:17: 5:21
}
bb0: {
_4 = const false; // scope 0 at src/test/ui/issues/issue-88307.rs:5:25: 5:47
_3 = const false; // scope 0 at src/test/ui/issues/issue-88307.rs:5:25: 5:47
+ StorageLive(_1); // scope 0 at src/test/ui/issues/issue-88307.rs:5:25: 5:47
_4 = const true; // scope 0 at src/test/ui/issues/issue-88307.rs:5:25: 5:29
discriminant(_1) = 0; // scope 0 at src/test/ui/issues/issue-88307.rs:5:25: 5:29
switchInt(_3) -> [false: bb1, otherwise: bb4]; // scope 0 at src/test/ui/issues/issue-88307.rs:6:5: 6:6
}
bb1: {
_3 = const false; // scope 0 at src/test/ui/issues/issue-88307.rs:6:5: 6:6
+ StorageDead(_2); // scope 0 at src/test/ui/issues/issue-88307.rs:6:5: 6:6
_5 = discriminant(_1); // scope 0 at src/test/ui/issues/issue-88307.rs:7:1: 7:2
switchInt(move _5) -> [1_isize: bb6, otherwise: bb5]; // scope 0 at src/test/ui/issues/issue-88307.rs:7:1: 7:2
}
bb2 (cleanup): {
_6 = discriminant(_1); // scope 0 at src/test/ui/issues/issue-88307.rs:7:1: 7:2
switchInt(move _6) -> [1_isize: bb8, otherwise: bb3]; // scope 0 at src/test/ui/issues/issue-88307.rs:7:1: 7:2
}
bb3 (cleanup): {
resume; // scope 0 at src/test/ui/issues/issue-88307.rs:4:1: 7:2
}
bb4: {
drop(_2) -> [return: bb1, unwind: bb2]; // scope 0 at src/test/ui/issues/issue-88307.rs:6:5: 6:6
}
bb5: {
_4 = const false; // scope 0 at src/test/ui/issues/issue-88307.rs:7:1: 7:2
+ StorageDead(_1); // scope 0 at src/test/ui/issues/issue-88307.rs:7:1: 7:2
return; // scope 0 at src/test/ui/issues/issue-88307.rs:7:2: 7:2
}
bb6: {
switchInt(_4) -> [false: bb5, otherwise: bb7]; // scope 0 at src/test/ui/issues/issue-88307.rs:7:1: 7:2
}
bb7: {
drop(((_1 as Some).0: std::string::String)) -> bb5; // scope 0 at src/test/ui/issues/issue-88307.rs:7:1: 7:2
}
bb8 (cleanup): {
switchInt(_4) -> [false: bb3, otherwise: bb9]; // scope 0 at src/test/ui/issues/issue-88307.rs:7:1: 7:2
}
bb9 (cleanup): {
drop(((_1 as Some).0: std::string::String)) -> bb3; // scope 0 at src/test/ui/issues/issue-88307.rs:7:1: 7:2
}
} |
@c410-f3r - Can you offer an update on the fix for this? Thanks. |
After several days and several failed attempts, I couldn't solve the issue on my own but Matthew kindly applied to look into the underlying problem. FWICT, he was far more MIR knowledge and Rustc experience so I guess a final outcome probably won't take long. |
@c410-f3r @matthewjasper (I assume you meant this Matthew?) Do you know if you can provide a fix for this in-time or if the revert has to go through? We want to sync Clippy one more time before the beta branching on Friday and this is kind of blocking that (since we don't want to make a revert harder, if it should come to that). |
As for myself, I did everything I could. |
I tried this code (reduced from a macro expansion in previously working code):
I expected to see this happen:
Prior to a recent change, this compiles and running the program prints "end of test".
Instead, this happened:
Meta
rustc --version --verbose
:Note, I also tested with a version of the compiler just prior to the commit-hash above, and the program compiles and runs correctly under
-C opt-level=s
:So this appears to confirm the error was introduced with the PR Introduce hir::ExprKind::Let - Take 2 #80357
Backtrace
The text was updated successfully, but these errors were encountered: