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

Labels scoped too highly #75433

Closed
evanrichter opened this issue Aug 12, 2020 · 2 comments
Closed

Labels scoped too highly #75433

evanrichter opened this issue Aug 12, 2020 · 2 comments
Labels
C-bug Category: This is a bug.

Comments

@evanrichter
Copy link
Contributor

Hello, I believe I found a bug in how labels are defined to a scope. The same text abcd defines two distinct labels, each inside an anonymous scope using { ... }.

I tried this code:

fn main() {
    {
        'abcd: loop {
            break 'abcd;
        }
    }
    {
        'abcd: loop {
            break 'abcd;
        }
    }
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
warning: label name `'abcd` shadows a label name that is already in scope
 --> src/main.rs:8:9
  |
3 |         'abcd: loop {
  |         ----- first declared here
...
8 |         'abcd: loop {
  |         ^^^^^ lifetime 'abcd already in scope

warning: 1 warning emitted

    Finished dev [unoptimized + debuginfo] target(s) in 0.42s
     Running `target/debug/playground`

I expected to see this happen: code compiles

Instead, this happened: labels are identified as the same, but they actually have different scopes

Meta

This appears to happen on both nightly and stable.

@evanrichter evanrichter added the C-bug Category: This is a bug. label Aug 12, 2020
@abnormalmaps
Copy link

This seems to be intentional, as indicated by tests for this situation in src/test/compile-fail/loops-reject-duplicate-labels-2.rs, but I think it would be nice if there was someone else to discuss this with.

(also see #21633)

@jonas-schievink
Copy link
Contributor

Yeah, this is working as intended. Feel free to discuss this on https://internals.rust-lang.org/ though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants