Skip to content

Lifetimes are parsed without errors when they occur in most ExpressionWithBlocks in front of the contained block expression #103983

Closed
@Veykril

Description

@Veykril

I tried this code playground:

fn main() {
    if let () = () 'a {}
    if true 'a {}
    loop 'a {}
    while true 'a {}
    while let () = () 'a {}
    for _ in 0..0 'a {}
    unsafe 'a {}
}

I expected to see this happen: The compiler rejects all these expressions as the lifetimes are in a nonsensical position.

Instead, this happened: The compiler accepted the expressions without saying anything

Meta

This behavior seems to occur since 1.61.
1.60 and below properly reject the code.

Metadata

Metadata

Labels

A-parserArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions