Skip to content

It is not intuitive which loop is broken out from in loop { while break {} } #37576

Closed
@nagisa

Description

@nagisa

From #37487 (comment)

As for whether while break { } should break out of the while loop (as it does today) or out of the containing loop (as it does under this PR), it seems like neither is particularly intuitive. Our [NB: lang team] preference would be to simply make it an error to put break in the condition of a while loop.

We can make it a hard error and do a test, but it may be that we want to go through a warning period here.

cc @nikomatsakis and the lang team in general

UPDATE: See this comment which includes a number of examples that we will want to check when fixing this bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions