Skip to content

Back-compat risk: same label can be attached to distinct blocks in the same scope #21633

Closed
@pnkfelix

Description

@pnkfelix

The current Rust alpha allows one to attach two lifetimes with the same name to two distinct loop blocks.

This is a backwards compatibility risk for hypothesized future versions of Rust where the lifetime labels can be used in e.g. type annotations (rather than solely used for labelled break/continue statements).

Example:

fn main() {
    let d = 3;
    'a: for i in (0..d).rev() {
        println!("i: {}", i);
    }

    'a: for i in (d..d*2).rev() {
        println!("i: {}", i);
    }
}

Metadata

Metadata

Assignees

Labels

E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.P-lowLow priority

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions