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

Projects
None yet
7 participants
@pnkfelix
Copy link
Member

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

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Apr 7, 2015

r? @eddyb

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

@pnkfelix

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Apr 8, 2015

r+ modulo nit

@pnkfelix pnkfelix force-pushed the pnkfelix:fsk-detect-duplicate-loop-labels branch 2 times, most recently from 05d4881 to 816a500 Apr 9, 2015

@pnkfelix

This comment has been minimized.

Copy link
Member Author

pnkfelix commented Apr 9, 2015

@bors r=nikomatsakis 816a500 rollup

@pnkfelix

This comment has been minimized.

Copy link
Member Author

pnkfelix commented Apr 9, 2015

@nikomatsakis Mind skimming over the additions from ed5ac77 ?

@pnkfelix pnkfelix force-pushed the pnkfelix:fsk-detect-duplicate-loop-labels branch 3 times, most recently from 096f296 to 46e0d94 Apr 10, 2015

@pnkfelix

This comment has been minimized.

Copy link
Member Author

pnkfelix commented Apr 10, 2015

@nikomatsakis this definitely needs a re-review now.

@pnkfelix pnkfelix force-pushed the pnkfelix:fsk-detect-duplicate-loop-labels branch from 46e0d94 to f4c39cb Apr 10, 2015

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Apr 10, 2015

@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

This comment has been minimized.

Copy link
Member Author

pnkfelix commented Apr 10, 2015

@bors r=nikomatsakis e6880ab rollup

steveklabnik added a commit to steveklabnik/rust that referenced this pull request Apr 10, 2015

@pnkfelix

This comment has been minimized.

Copy link
Member Author

pnkfelix commented Apr 10, 2015

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

@pnkfelix

This comment has been minimized.

Copy link
Member Author

pnkfelix commented Apr 11, 2015

(no this still does not work...)

@pnkfelix

This comment has been minimized.

Copy link
Member Author

pnkfelix commented Apr 17, 2015

(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 pnkfelix:fsk-detect-duplicate-loop-labels branch from fdb8414 to aafed03 Apr 18, 2015

@pnkfelix

This comment has been minimized.

Copy link
Member Author

pnkfelix commented Apr 21, 2015

@bors r=nikomatsakis 464e586

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

Auto merge of #24162 - pnkfelix:fsk-detect-duplicate-loop-labels, r=n…
…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

This comment has been minimized.

Copy link
Contributor

bors commented Apr 21, 2015

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

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Apr 21, 2015

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

@steveklabnik

This comment has been minimized.

Copy link
Member

steveklabnik commented Apr 21, 2015

@pnkfelix travis only runs make tidy, it doesn't actually do a build

@pnkfelix

This comment has been minimized.

Copy link
Member Author

pnkfelix commented Apr 21, 2015

@steveklabnik ah, I had been under the impression that it did a make rustc-stage1 but did not do any testing of the result. Okay.

pnkfelix added some commits Apr 3, 2015

Check for shadowing between lifetimes and loop labels in function bod…
…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 pnkfelix:fsk-detect-duplicate-loop-labels branch from e46b32b to 2b3cd40 Apr 21, 2015

@pnkfelix

This comment has been minimized.

Copy link
Member Author

pnkfelix commented Apr 21, 2015

@bors r=nikomatsakis 2b3cd40

@steveklabnik

This comment has been minimized.

Copy link
Member

steveklabnik commented Apr 21, 2015

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

@steveklabnik

This comment has been minimized.

Copy link
Member

steveklabnik commented Apr 21, 2015

@bors: rollup-

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

Auto merge of #24162 - pnkfelix:fsk-detect-duplicate-loop-labels, r=n…
…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

This comment has been minimized.

Copy link
Contributor

bors commented Apr 21, 2015

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

@steveklabnik

This comment has been minimized.

Copy link
Member

steveklabnik commented Apr 21, 2015

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

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Apr 21, 2015

@bors: p=1

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

rollup merge of rust-lang#24162: pnkfelix/fsk-detect-duplicate-loop-l…
…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

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@bors bors referenced this pull request Apr 21, 2015

Merged

Rolling up PRs in the queue #24674

@pnkfelix

This comment has been minimized.

Copy link
Member Author

pnkfelix commented Apr 22, 2015

@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

This comment has been minimized.

Copy link
Member Author

pnkfelix commented Apr 23, 2015

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
You can’t perform that action at this time.