-
Notifications
You must be signed in to change notification settings - Fork 144
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
Rebinding match expressions on structs are unhandled #2906
Comments
a very simple fix which is probably not correct is the following: if (scrutinee_kind == TyTy::TypeKind::ADT)
{
// this will need to change but for now the first pass implementation,
// lets assert this is the case
TyTy::ADTType *adt = static_cast<TyTy::ADTType *> (scrutinee_expr_tyty);
if (adt->is_enum ())
rust_assert (adt->number_of_variants () > 0);
}
|
Hey, I wanted to work on this. Thinking trivially I would have thought of the same solution as the last reply but could you please explain why this might not be right? Testing locally the above solution does seem to remove the ICE. |
@nobel-sh it removes the ICE, but I whipped it up in 5 minutes without really thinking or testing it out so that's why I'm saying it might not be correct :) should I assign you to the issue? |
Yeah sure. |
I tried this code:
this is very ugly Rust code, but it's used by rustc in a number of places for desugaring purposes, for example for loops - which get desugared as something of the form:
becomes
I expected to see this happen: no error: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=eedc6ff5cd556e9e703c52cf601d2f4c
The issue lies in here:
we are asserting that the scrutinee we're matching on is an enum, which is not the case here
Instead, this happened: explanation
Meta
The text was updated successfully, but these errors were encountered: