-
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
Trying to pattern-match field 1
of Box
causes an ICE
#82772
Comments
Seems to be the indicated function: rust/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs Lines 1329 to 1359 in ec7f258
|
1
of Box
causes an ICE1
of Box
causes an ICE
Assigning @rustbot label -I-prioritize +P-medium |
Issue: rust-lang/rust#82772
Get with field index from pattern slice instead of directly indexing Closes rust-lang#82772 r? `@estebank` rust-lang#82789 (comment) > `@estebank` So the real cause is we only generate single pattern for Box here https://github.com/csmoe/rust/blob/615b03aeaa8ce9819de7828740ab3cd7def4fa76/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs#L1130-L1132 But in the replacing function, it tries to index on the 1-length pattern slice with field 1, thus out of bounds. https://github.com/csmoe/rust/blob/615b03aeaa8ce9819de7828740ab3cd7def4fa76/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs#L1346
Oh this is ugly x) Reading the PR, the problem is that there are two ways to match a Box: via a box-pattern or via match Box::new(true) {
Box(true, _) => {}
box true => {} //~ ERROR unreachable pattern
_ => {}
}
match Box::new(true) {
box true => {}
box false => {}
Box(_, _) => {} //~ ERROR unreachable pattern
} We'll need to figure out a real solution when we implement generalized Deref patterns... |
@Nadrieril in that case we should open a new ticket for that work, tagged something like |
Code
[playground]
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: