Resolve infinite_loop FP for nested loops#16724
Resolve infinite_loop FP for nested loops#16724mikhailofff wants to merge 1 commit intorust-lang:masterfrom
infinite_loop FP for nested loops#16724Conversation
|
rustbot has assigned @samueltardieu. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
f119d02 to
cffeba2
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cffeba2 to
4bdea7d
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
There was a problem hiding this comment.
break and continue have a field of type Destination which contains the HirId of the target of the break or continue. Can't you use that instead of labels to match the various blocks and loops that can be the target of the break?
@rustbot author
|
Reminder, once the PR becomes ready for a review, use |
| }| { | ||
| if let ExprKind::Break(hir::Destination { label: _, target_id }, ..) = kind | ||
| && let Ok(t_id) = target_id | ||
| && t_id.local_id < self.ex.hir_id.local_id |
There was a problem hiding this comment.
Thanks for the review. I actually had this in mind. The use of potential_breaks in LoopVisitor is necessary to store the break statements that may terminate the original loop if it points to a loop that precedes the original loop. If the target_id only points to the loop that will actually be terminated by the break, then everything is fine. I hope.
Fixes #16134.
changelog: [
infinite_loop]: look thoroughly the case when there are nested loops that cannot be infinite, because there is a break statement that interrupts another loop that takes up space above.