Skip to content

Commit 6da64a7

Browse files
committed
Default unused_labels to allow, move to "unused"
1 parent 5586cd8 commit 6da64a7

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

src/librustc/lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ declare_lint! {
281281

282282
declare_lint! {
283283
pub UNUSED_LABELS,
284-
Warn,
284+
Allow,
285285
"detects labels that are never used"
286286
}
287287

src/librustc_lint/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
177177
UNUSED_DOC_COMMENT,
178178
UNUSED_EXTERN_CRATES,
179179
UNUSED_FEATURES,
180+
UNUSED_LABELS,
180181
UNUSED_PARENS);
181182

182183
add_lint_group!(sess,

src/test/ui/lint/unused_labels.rs

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// compile-pass
1616

1717
#![feature(label_break_value)]
18+
#![warn(unused_labels)]
1819

1920
fn main() {
2021
'unused_while_label: while 0 == 0 {
@@ -55,6 +56,15 @@ fn main() {
5556
}
5657
}
5758

59+
// You should be able to break the same label many times
60+
'many_used: loop {
61+
if true {
62+
break 'many_used;
63+
} else {
64+
break 'many_used;
65+
}
66+
}
67+
5868
// Test breaking many times with the same inner label doesn't break the
5969
// warning on the outer label
6070
'many_used_shadowed: for _ in 0..10 {

src/test/ui/lint/unused_labels.stderr

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,59 @@
11
warning: unused label
2-
--> $DIR/unused_labels.rs:20:5
2+
--> $DIR/unused_labels.rs:21:5
33
|
44
LL | 'unused_while_label: while 0 == 0 {
55
| ^^^^^^^^^^^^^^^^^^^
66
|
7-
= note: #[warn(unused_labels)] on by default
7+
note: lint level defined here
8+
--> $DIR/unused_labels.rs:18:9
9+
|
10+
LL | #![warn(unused_labels)]
11+
| ^^^^^^^^^^^^^
812

913
warning: unused label
10-
--> $DIR/unused_labels.rs:25:5
14+
--> $DIR/unused_labels.rs:26:5
1115
|
1216
LL | 'unused_while_let_label: while let Some(_) = opt {
1317
| ^^^^^^^^^^^^^^^^^^^^^^^
1418

1519
warning: unused label
16-
--> $DIR/unused_labels.rs:29:5
20+
--> $DIR/unused_labels.rs:30:5
1721
|
1822
LL | 'unused_for_label: for _ in 0..10 {
1923
| ^^^^^^^^^^^^^^^^^
2024

2125
warning: unused label
22-
--> $DIR/unused_labels.rs:45:9
26+
--> $DIR/unused_labels.rs:46:9
2327
|
2428
LL | 'unused_loop_label_inner_2: for _ in 0..10 {
2529
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
2630

2731
warning: unused label
28-
--> $DIR/unused_labels.rs:51:5
32+
--> $DIR/unused_labels.rs:52:5
2933
|
3034
LL | 'unused_loop_label_outer_3: for _ in 0..10 {
3135
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
3236

3337
warning: unused label
34-
--> $DIR/unused_labels.rs:60:5
38+
--> $DIR/unused_labels.rs:70:5
3539
|
3640
LL | 'many_used_shadowed: for _ in 0..10 {
3741
| ^^^^^^^^^^^^^^^^^^^
3842

3943
warning: unused label
40-
--> $DIR/unused_labels.rs:72:5
44+
--> $DIR/unused_labels.rs:82:5
4145
|
4246
LL | 'unused_loop_label: loop {
4347
| ^^^^^^^^^^^^^^^^^^
4448

4549
warning: unused label
46-
--> $DIR/unused_labels.rs:78:5
50+
--> $DIR/unused_labels.rs:88:5
4751
|
4852
LL | 'unused_block_label: {
4953
| ^^^^^^^^^^^^^^^^^^^
5054

5155
warning: label name `'many_used_shadowed` shadows a label name that is already in scope
52-
--> $DIR/unused_labels.rs:62:9
56+
--> $DIR/unused_labels.rs:72:9
5357
|
5458
LL | 'many_used_shadowed: for _ in 0..10 {
5559
| ------------------- first declared here

0 commit comments

Comments
 (0)