-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Fixed ICEs with pattern matching in const expression #41055
Fixed ICEs with pattern matching in const expression #41055
Conversation
…ixes rust-lang#31577, fixes rust-lang#29093, and fixes rust-lang#40012.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @arielb1 (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
if self.mode != Mode::Fn { | ||
bug!("implement discriminant const qualify"); | ||
} | ||
// Discriminants in consts will error elsewhere as an unimplemented expression type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are not calling .not_const()
because we report an error for the SwitchInt
terminator too? I don't think there is any way of it getting split from its Discriminant
now before qualify_consts
, but it sounds like we want some other way to avoid duplicate errors.
Maybe have not_const
keep a (per-function) HashSet of spans?
Or maybe just not set NOT_CONST
and implement Discriminant
in trans::mir::consts
?
r+ if you make |
Awesome fixes for old ices @Archytaus! |
@arielb1 To clarify, do you mean making it valid by removing I wouldn't mind trying to implement it in trans, but I would be taking my time learning how that part of the compiler works. So I would want to do that in another PR if possible. |
@Archytaus Yup. Remove the |
@bors r+ |
📌 Commit c9932b3 has been approved by |
…, r=arielb1 Fixed ICEs with pattern matching in const expression Fixed 2 ICEs with when pattern matching inside a constant expression. Both of these ICEs now resolve to an appropriate compiler error. 1. ICE was caused by a compiler bug to implement discriminant const qualify. I removed this intentionally thrown bug and changed it to a FIXME as the unimplemented expression type is handled as a compiler error elsewhere. 2. ICE was caused during a drop check when checking if a variable lifetime outlives the current scope if there was no parent scope . I've changed it to stop checking if there is no parent scope for the current scope. It is valid syntax for a const variable to be assigned a match expression with no enclosing scope. The ICE seemed to mainly be used as a defensive check for bugs elsewhere. Fixes #38199. Fixes #31577. Fixes #29093. Fixes #40012.
☀️ Test successful - status-appveyor, status-travis |
Fixed 2 ICEs with when pattern matching inside a constant expression.
Both of these ICEs now resolve to an appropriate compiler error.
ICE was caused by a compiler bug to implement discriminant const qualify.
I removed this intentionally thrown bug and changed it to a FIXME as the unimplemented expression type is handled as a compiler error elsewhere.
ICE was caused during a drop check when checking if a variable lifetime outlives the current scope if there was no parent scope .
I've changed it to stop checking if there is no parent scope for the current scope. It is valid syntax for a const variable to be assigned a match expression with no enclosing scope.
The ICE seemed to mainly be used as a defensive check for bugs elsewhere.
Fixes #38199.
Fixes #31577.
Fixes #29093.
Fixes #40012.