-
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
Fix ICE when there is a continue in a labeled block #121682
Conversation
r? compiler This needs an explanation for why it's correct. I'm also somewhat concerned that this could affect good-path code. I'd prefer if we did something else, like lower |
46d6915
to
17a6cf3
Compare
@compiler-errors I updated the pr, now when the ast is being lowered it checks if the label belongs to a loop and if it does not it will lower to an error. rust/compiler/rustc_passes/src/loops.rs Lines 189 to 194 in 6cbf092
|
This comment has been minimized.
This comment has been minimized.
17a6cf3
to
237576c
Compare
This comment has been minimized.
This comment has been minimized.
237576c
to
d5c2dd6
Compare
☔ The latest upstream changes (presumably #121780) made this pull request unmergeable. Please resolve the merge conflicts. |
d5c2dd6
to
8361b80
Compare
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.
I'm surprised we weren't emitting such an error anywhere before. What about break
on non-loop blocks?
@@ -279,7 +280,26 @@ impl<'hir> LoweringContext<'_, 'hir> { | |||
hir::ExprKind::Break(self.lower_jump_destination(e.id, *opt_label), opt_expr) |
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.
Should we do the same thing with break
?
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.
We are doing the same for break
here https://github.com/rust-lang/rust/blob/master/compiler/rustc_ast_lowering/src/expr.rs#L1455
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.
wait, maybe we are not doing it. This just assumes that the label is a loop https://github.com/rust-lang/rust/blob/master/compiler/rustc_ast_lowering/src/expr.rs#L1446-L1448
8361b80
to
58ba609
Compare
@cjgillot We were emitting this error but just much later. #121682 (comment) As asked #121682 (comment) I moved the error to when the ast is lowered. I would also like your opinion on if it would be better to lower it to a |
@rustbot label -S-waiting-on-author +S-waiting-on-review |
Using For |
☔ The latest upstream changes (presumably #123468) made this pull request unmergeable. Please resolve the merge conflicts. |
@SarthakSingh31 any updates on this? thanks |
@oskgo I had forgotten about this PR, going to try to fix it up in the next few days. |
58ba609
to
eee8b0c
Compare
This comment has been minimized.
This comment has been minimized.
eee8b0c
to
60ed3d1
Compare
This comment has been minimized.
This comment has been minimized.
60ed3d1
to
078c572
Compare
This comment has been minimized.
This comment has been minimized.
@cjgillot I have removed the redundant error. This should be ready to merge. This does not change the |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #125443) made this pull request unmergeable. Please resolve the merge conflicts. |
60485b9
to
f490a0e
Compare
☔ The latest upstream changes (presumably #128614) made this pull request unmergeable. Please resolve the merge conflicts. |
r=me after rebase |
@SarthakSingh31 |
@SarthakSingh31 |
Fixes #113379
Fixes #121623
r? @matthiaskrgr