Skip to content
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 never_loop false positive #9837

Merged
merged 1 commit into from
Nov 13, 2022
Merged

fix never_loop false positive #9837

merged 1 commit into from
Nov 13, 2022

Conversation

kartva
Copy link
Contributor

@kartva kartva commented Nov 12, 2022

fixes #9831

changelog: [never_loop]: fixed false positive on unconditional break in internal labeled block

on unconditional break to internal labeled block

ref rust-lang#9831
@rust-highfive
Copy link

r? @dswij

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 12, 2022
Copy link
Member

@dswij dswij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for this!

@dswij
Copy link
Member

dswij commented Nov 13, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Nov 13, 2022

📌 Commit 9899861 has been approved by dswij

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Nov 13, 2022

⌛ Testing commit 9899861 with merge a599527...

@bors
Copy link
Contributor

bors commented Nov 13, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: dswij
Pushing a599527 to master...

@bors bors merged commit a599527 into rust-lang:master Nov 13, 2022
@kartva
Copy link
Contributor Author

kartva commented Nov 13, 2022

Note:
I have discovered that this fix causes a false negative in the following case:

pub fn test20() {
    'a: loop {
        'b: {
            break 'a;
        }
    }
}

Working on it!

bors added a commit that referenced this pull request Nov 18, 2022
`never_loop`: don't emit AlwaysBreaks if it targets a block

ref: #9837 (comment)

The previous fix (#9837) was too simple and ignored all break commands inside a labelled block, regardless of whether their destination was a labelled block or a loop. This fix tracks all the labelled blocks in scope to ensure that only breaks targeting loops are considered.

changelog: [`never_loop`]: prevent false negatives from `breaks` nested in labelled blocks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

never_loop false positive on unconditional break to internal labeled block
4 participants