diff --git a/src/test/ui/label_break_value_continue.rs b/src/test/ui/label_break_value_continue.rs index 52e24b759d1..4a505dff3d4 100644 --- a/src/test/ui/label_break_value_continue.rs +++ b/src/test/ui/label_break_value_continue.rs @@ -9,6 +9,7 @@ // except according to those terms. #![feature(label_break_value)] +#![allow(unused_labels)] // Simple continue pointing to an unlabeled break should yield in an error fn continue_simple() { diff --git a/src/test/ui/label_break_value_continue.stderr b/src/test/ui/label_break_value_continue.stderr index 24c2d1a22d0..12a21a8a594 100644 --- a/src/test/ui/label_break_value_continue.stderr +++ b/src/test/ui/label_break_value_continue.stderr @@ -1,17 +1,17 @@ error[E0695]: unlabeled `continue` inside of a labeled block - --> $DIR/label_break_value_continue.rs:16:9 + --> $DIR/label_break_value_continue.rs:17:9 | LL | continue; //~ ERROR unlabeled `continue` inside of a labeled block | ^^^^^^^^ `continue` statements that would diverge to or through a labeled block need to bear a label error[E0696]: `continue` pointing to a labeled block - --> $DIR/label_break_value_continue.rs:23:9 + --> $DIR/label_break_value_continue.rs:24:9 | LL | continue 'b; //~ ERROR `continue` pointing to a labeled block | ^^^^^^^^^^^ labeled blocks cannot be `continue`'d | note: labeled block the continue points to - --> $DIR/label_break_value_continue.rs:22:5 + --> $DIR/label_break_value_continue.rs:23:5 | LL | / 'b: { LL | | continue 'b; //~ ERROR `continue` pointing to a labeled block @@ -19,7 +19,7 @@ LL | | } | |_____^ error[E0695]: unlabeled `continue` inside of a labeled block - --> $DIR/label_break_value_continue.rs:31:13 + --> $DIR/label_break_value_continue.rs:32:13 | LL | continue; //~ ERROR unlabeled `continue` inside of a labeled block | ^^^^^^^^ `continue` statements that would diverge to or through a labeled block need to bear a label diff --git a/src/test/ui/label_break_value_unlabeled_break.rs b/src/test/ui/label_break_value_unlabeled_break.rs index 38918da291c..454ebd4c6cf 100644 --- a/src/test/ui/label_break_value_unlabeled_break.rs +++ b/src/test/ui/label_break_value_unlabeled_break.rs @@ -9,6 +9,7 @@ // except according to those terms. #![feature(label_break_value)] +#![allow(unused_labels)] // Simple unlabeled break should yield in an error fn unlabeled_break_simple() { diff --git a/src/test/ui/label_break_value_unlabeled_break.stderr b/src/test/ui/label_break_value_unlabeled_break.stderr index 8a25975a7bd..62c4a12231b 100644 --- a/src/test/ui/label_break_value_unlabeled_break.stderr +++ b/src/test/ui/label_break_value_unlabeled_break.stderr @@ -1,11 +1,11 @@ error[E0695]: unlabeled `break` inside of a labeled block - --> $DIR/label_break_value_unlabeled_break.rs:16:9 + --> $DIR/label_break_value_unlabeled_break.rs:17:9 | LL | break; //~ ERROR unlabeled `break` inside of a labeled block | ^^^^^ `break` statements that would diverge to or through a labeled block need to bear a label error[E0695]: unlabeled `break` inside of a labeled block - --> $DIR/label_break_value_unlabeled_break.rs:24:13 + --> $DIR/label_break_value_unlabeled_break.rs:25:13 | LL | break; //~ ERROR unlabeled `break` inside of a labeled block | ^^^^^ `break` statements that would diverge to or through a labeled block need to bear a label diff --git a/src/test/ui/lint/unused_labels.rs b/src/test/ui/lint/unused_labels.rs index 86abb34658a..22b7ad4e6a7 100644 --- a/src/test/ui/lint/unused_labels.rs +++ b/src/test/ui/lint/unused_labels.rs @@ -14,6 +14,8 @@ // compile-pass +#![feature(label_break_value)] + fn main() { 'unused_while_label: while 0 == 0 { //~^ WARN unused label @@ -67,9 +69,18 @@ fn main() { } } - // This is diverging, so put it at the end so we don't get - // unreachable_code errors everywhere else 'unused_loop_label: loop { //~^ WARN unused label + break; + } + + // Make sure unused block labels give warnings... + 'unused_block_label: { + //~^ WARN unused label + } + + // ...and that used ones don't: + 'used_block_label: { + break 'used_block_label; } } diff --git a/src/test/ui/lint/unused_labels.stderr b/src/test/ui/lint/unused_labels.stderr index 425b0b1769d..d09209853e3 100644 --- a/src/test/ui/lint/unused_labels.stderr +++ b/src/test/ui/lint/unused_labels.stderr @@ -1,5 +1,5 @@ warning: unused label - --> $DIR/unused_labels.rs:18:5 + --> $DIR/unused_labels.rs:20:5 | LL | 'unused_while_label: while 0 == 0 { | ^^^^^^^^^^^^^^^^^^^ @@ -7,31 +7,31 @@ LL | 'unused_while_label: while 0 == 0 { = note: #[warn(unused_labels)] on by default warning: unused label - --> $DIR/unused_labels.rs:23:5 + --> $DIR/unused_labels.rs:25:5 | LL | 'unused_while_let_label: while let Some(_) = opt { | ^^^^^^^^^^^^^^^^^^^^^^^ warning: unused label - --> $DIR/unused_labels.rs:27:5 + --> $DIR/unused_labels.rs:29:5 | LL | 'unused_for_label: for _ in 0..10 { | ^^^^^^^^^^^^^^^^^ warning: unused label - --> $DIR/unused_labels.rs:43:9 + --> $DIR/unused_labels.rs:45:9 | LL | 'unused_loop_label_inner_2: for _ in 0..10 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused label - --> $DIR/unused_labels.rs:49:5 + --> $DIR/unused_labels.rs:51:5 | LL | 'unused_loop_label_outer_3: for _ in 0..10 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: unused label - --> $DIR/unused_labels.rs:58:5 + --> $DIR/unused_labels.rs:60:5 | LL | 'many_used_shadowed: for _ in 0..10 { | ^^^^^^^^^^^^^^^^^^^ @@ -42,8 +42,14 @@ warning: unused label LL | 'unused_loop_label: loop { | ^^^^^^^^^^^^^^^^^^ +warning: unused label + --> $DIR/unused_labels.rs:78:5 + | +LL | 'unused_block_label: { + | ^^^^^^^^^^^^^^^^^^^ + warning: label name `'many_used_shadowed` shadows a label name that is already in scope - --> $DIR/unused_labels.rs:60:9 + --> $DIR/unused_labels.rs:62:9 | LL | 'many_used_shadowed: for _ in 0..10 { | ------------------- first declared here