]> git.lizzy.rs Git - rust.git/commit
Auto merge of #50763 - KyleStach1678:unused-loop-label, r=petrochenkov
authorbors <bors@rust-lang.org>
Sat, 19 May 2018 14:52:30 +0000 (14:52 +0000)
committerbors <bors@rust-lang.org>
Sat, 19 May 2018 14:52:30 +0000 (14:52 +0000)
commit1b240dad0648dc45e50fd0421a29390343ad5808
tree32a9591c9cd4f961182958e1d238f6065c826928
parentef8ee647749ad2f0acf235aaf18debacb974a048
parent6da64a7666e89b39b99d728aaa3a40c124f31563
Auto merge of #50763 - KyleStach1678:unused-loop-label, r=petrochenkov

Add lint checks for unused loop labels

Previously no warning was generated when a loop label was written out but never used (i.e. in a `break` or `continue` statement):
```rust
fn main() {
    'unused_label: loop {}
}
```
would compile without complaint.

This fix introduces `-W unused_loop_label`, which generates the following warning message for the above snippet:
```
warning: unused loop label
 --> main.rs:2:5
  |
2 |     'unused_label: loop {}
  |     ^^^^^^^^^^^^^
  |
  = note: #[warn(unused_loop_label)] on by default
```

Fixes: #50751.
src/librustc/lint/builtin.rs
src/librustc_lint/lib.rs
src/librustc_resolve/lib.rs