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

Check for duplicate loop labels in function bodies. #24162

Merged
merged 3 commits into from
Apr 21, 2015

Conversation

pnkfelix
Copy link
Member

@pnkfelix pnkfelix commented Apr 7, 2015

Check for duplicate loop labels in function bodies.

See also: http://internals.rust-lang.org/t/psa-rejecting-duplicate-loop-labels/1833

The change, which we are putting in as future-proofing in preparation for future potential additions to the language (namely labeling arbitrary blocks and using those labels in borrow expressions), means that code like this will start emitting warnings:

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

To make the above code compile without warnings, write this instead:

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

Since this change is only introducing a new warnings, this change is non-breaking.

Fix #21633

@rust-highfive
Copy link
Collaborator

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 7, 2015

(this isn't really done; at the very least, it needs a test or two, and I want to wait to see feedback from the internals thread.)

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 8, 2015

Okay, added tests, and I guess the internals thread isn't going to get much action now.

r? @nikomatsakis

@rust-highfive rust-highfive assigned nikomatsakis and unassigned eddyb Apr 8, 2015
@nikomatsakis
Copy link
Contributor

r+ modulo nit

@pnkfelix pnkfelix force-pushed the fsk-detect-duplicate-loop-labels branch 2 times, most recently from 05d4881 to 816a500 Compare April 9, 2015 07:01
@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 9, 2015

@bors r=nikomatsakis 816a500 rollup

@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 9, 2015

@nikomatsakis Mind skimming over the additions from ed5ac77 ?

@pnkfelix pnkfelix force-pushed the fsk-detect-duplicate-loop-labels branch 3 times, most recently from 096f296 to 46e0d94 Compare April 10, 2015 00:31
@pnkfelix
Copy link
Member Author

@nikomatsakis this definitely needs a re-review now.

@pnkfelix pnkfelix force-pushed the fsk-detect-duplicate-loop-labels branch from 46e0d94 to f4c39cb Compare April 10, 2015 00:38
@nikomatsakis
Copy link
Contributor

@pnkfelix r+ modulo nit (your call on whether to make an issue)

This actually does feel cleaner to me. Doing the pre-pass to collect the labels is nice.

@pnkfelix
Copy link
Member Author

@bors r=nikomatsakis e6880ab rollup

steveklabnik added a commit to steveklabnik/rust that referenced this pull request Apr 10, 2015
@pnkfelix
Copy link
Member Author

@bors r- (there's some test fallout I need to address)

@pnkfelix
Copy link
Member Author

(no this still does not work...)

@pnkfelix
Copy link
Member Author

(The main difficulty remaining is the handling of hygiene. My current approach to collapsing the rules so that labels are scoped to the entire function body does not play well with our (mis)handling of hygiene for lifetime-like things... at this point this might not happen for 1.0, in which case we will just have to live with the unfortunate scoping rules and work around them if we add e.g. &'lifetime <expr>expressions in the future.)

@pnkfelix pnkfelix force-pushed the fsk-detect-duplicate-loop-labels branch from fdb8414 to aafed03 Compare April 18, 2015 10:06
@pnkfelix
Copy link
Member Author

@bors r=nikomatsakis 464e586

@bors
Copy link
Contributor

bors commented Apr 21, 2015

⌛ Testing commit 464e586 with merge 1fd19cf...

@bors
Copy link
Contributor

bors commented Apr 21, 2015

💔 Test failed - auto-linux-64-nopt-t

…ies.

Note: this Warns rather than error on shadowing problems involving labels.
We took this more conservative option mostly due to issues with
hygiene being broken for labels and/or lifetimes.

Add FIXME regarding non-hygienic comparison.
@pnkfelix pnkfelix force-pushed the fsk-detect-duplicate-loop-labels branch from e46b32b to 2b3cd40 Compare April 21, 2015 16:09
@pnkfelix
Copy link
Member Author

@bors r=nikomatsakis 2b3cd40

@steveklabnik
Copy link
Member

long ago it did, but it would time out and such so https://github.com/rust-lang/rust/blob/master/.travis.yml#L17

@steveklabnik
Copy link
Member

@bors: rollup-

bors added a commit that referenced this pull request Apr 21, 2015
…ikomatsakis

Check for duplicate loop labels in function bodies.

See also: http://internals.rust-lang.org/t/psa-rejecting-duplicate-loop-labels/1833

The change, which we are putting in as future-proofing in preparation for future potential additions to the language (namely labeling arbitrary blocks and using those labels in borrow expressions), means that code like this will start emitting warnings:

```rust
fn main() {
    { 'a: loop { break; } }
    { 'a: loop { break; } }
}
```

To make the above code compile without warnings, write this instead:

```rust
fn main() {
    { 'a: loop { break; } }
    { 'b: loop { break; } }
}
```

Since this change is only introducing a new warnings, this change is non-breaking.

Fix #21633
@bors
Copy link
Contributor

bors commented Apr 21, 2015

⌛ Testing commit 2b3cd40 with merge 2baf348...

@steveklabnik steveklabnik added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Apr 21, 2015
@steveklabnik
Copy link
Member

Since this is future-proofing, I'm adding beta-nominated

@alexcrichton
Copy link
Member

@bors: p=1

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Apr 21, 2015
…abels

Check for duplicate loop labels in function bodies.

See also: http://internals.rust-lang.org/t/psa-rejecting-duplicate-loop-labels/1833

The change, which we are putting in as future-proofing in preparation for future potential additions to the language (namely labeling arbitrary blocks and using those labels in borrow expressions), means that code like this will start emitting warnings:

```rust
fn main() {
    { 'a: loop { break; } }
    { 'a: loop { break; } }
}
```

To make the above code compile without warnings, write this instead:

```rust
fn main() {
    { 'a: loop { break; } }
    { 'b: loop { break; } }
}
```

Since this change is only introducing a new warnings, this change is non-breaking.

Fix rust-lang#21633
@bors bors merged commit 2b3cd40 into rust-lang:master Apr 21, 2015
@pnkfelix
Copy link
Member Author

@steveklabnik wrote:

long ago it did, but it would time out and such so https://github.com/rust-lang/rust/blob/master/.travis.yml#L17

ah. Maybe we could try doing a "build" that just runs the type+borrow checking for a stage1 build, via -Z no-trans ... that in combination with not doing an LLVM build could be "sufficiently speedy", maybe ...

Update: never mind, that would not suffice today, since -Z no-trans today does not generate any output, and thus we would not have the metadata that later crates need after compiling the first crate.

@pnkfelix pnkfelix added beta-accepted Accepted for backporting to the compiler in the beta channel. and removed beta-accepted Accepted for backporting to the compiler in the beta channel. labels Apr 23, 2015
@pnkfelix
Copy link
Member Author

i was not sure about whether to accept, but since it is already part of alex's rollup:

going from nominated to (nominated, accepted)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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