From ed56f867818f7f3fb29dac3cfc0faf316909fd23 Mon Sep 17 00:00:00 2001 From: Bart Massey Date: Tue, 12 Nov 2019 03:19:40 -0800 Subject: [PATCH 1/2] Cleaned up unused labels Deleted unused labels from compiler and fixed or allowed unused labels in tests. This patch removes some gratuitous unused labels and turns off the warning for unused labels that are a necessary part of tests. This will permit setting the `unused_labels` lint to `warn`. --- src/librustc/ty/layout.rs | 2 +- src/librustc_codegen_ssa/mir/block.rs | 2 +- .../nll/type_check/liveness/trace.rs | 2 +- src/libstd/keyword_docs.rs | 4 +- .../ui/for-loop-while/label_break_value.rs | 2 +- .../ui/for-loop-while/loop-label-shadowing.rs | 1 + src/test/ui/hygiene/hygienic-labels-in-let.rs | 1 + .../ui/hygiene/hygienic-labels-in-let.stderr | 56 +++++++++---------- src/test/ui/hygiene/hygienic-labels.rs | 1 + src/test/ui/hygiene/hygienic-labels.stderr | 56 +++++++++---------- src/test/ui/issues/issue-2216.rs | 2 +- .../macros/macro-lifetime-used-with-labels.rs | 2 +- 12 files changed, 67 insertions(+), 64 deletions(-) diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 972452601ddd5..b67aa77860050 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -2557,7 +2557,7 @@ where 'descend_newtypes: while !fat_pointer_layout.ty.is_unsafe_ptr() && !fat_pointer_layout.ty.is_region_ptr() { - 'iter_fields: for i in 0..fat_pointer_layout.fields.count() { + for i in 0..fat_pointer_layout.fields.count() { let field_layout = fat_pointer_layout.field(cx, i); if !field_layout.is_zst() { diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index 14be0e80fb482..8002b3fca8d14 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -721,7 +721,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { 'descend_newtypes: while !op.layout.ty.is_unsafe_ptr() && !op.layout.ty.is_region_ptr() { - 'iter_fields: for i in 0..op.layout.fields.count() { + for i in 0..op.layout.fields.count() { let field = op.extract_field(&mut bx, i); if !field.layout.is_zst() { // we found the one non-zero-sized field that is allowed diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs index eacc4d084dbb8..fefc6931c0be6 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs @@ -249,7 +249,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> { // Reverse DFS. But for drops, we do it a bit differently. // The stack only ever stores *terminators of blocks*. Within // a block, we walk back the statements in an inner loop. - 'next_block: while let Some(term_point) = self.stack.pop() { + while let Some(term_point) = self.stack.pop() { self.compute_drop_live_points_for_block(mpi, term_point); } } diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs index d025a7d16f256..4b237c1d1b665 100644 --- a/src/libstd/keyword_docs.rs +++ b/src/libstd/keyword_docs.rs @@ -57,7 +57,7 @@ mod as_keyword { } /// 'outer: for i in 1..=5 { /// println!("outer iteration (i): {}", i); /// -/// 'inner: for j in 1..=200 { +/// '_inner: for j in 1..=200 { /// println!(" inner iteration (j): {}", j); /// if j >= 3 { /// // breaks from inner loop, let's outer loop continue. @@ -178,7 +178,7 @@ mod const_keyword { } ///```rust /// // Print Odd numbers under 30 with unit <= 5 /// 'tens: for ten in 0..3 { -/// 'units: for unit in 0..=9 { +/// '_units: for unit in 0..=9 { /// if unit % 2 == 0 { /// continue; /// } diff --git a/src/test/ui/for-loop-while/label_break_value.rs b/src/test/ui/for-loop-while/label_break_value.rs index eb5be7742e082..18930ac811e80 100644 --- a/src/test/ui/for-loop-while/label_break_value.rs +++ b/src/test/ui/for-loop-while/label_break_value.rs @@ -77,7 +77,7 @@ fn label_break_mixed(v: u32) -> u32 { } // Labeled breaking an outer loop still works 'd: loop { - 'e: { + { if v == r { break 'b; } diff --git a/src/test/ui/for-loop-while/loop-label-shadowing.rs b/src/test/ui/for-loop-while/loop-label-shadowing.rs index acb53e254bb78..9bedde67b7888 100644 --- a/src/test/ui/for-loop-while/loop-label-shadowing.rs +++ b/src/test/ui/for-loop-while/loop-label-shadowing.rs @@ -5,6 +5,7 @@ fn main() { let mut foo = Vec::new(); + #[allow(unused_labels)] 'foo: for i in &[1, 2, 3] { foo.push(*i); } diff --git a/src/test/ui/hygiene/hygienic-labels-in-let.rs b/src/test/ui/hygiene/hygienic-labels-in-let.rs index 5d22cf857b7a1..491855d7becd1 100644 --- a/src/test/ui/hygiene/hygienic-labels-in-let.rs +++ b/src/test/ui/hygiene/hygienic-labels-in-let.rs @@ -1,5 +1,6 @@ // run-pass #![allow(unreachable_code)] +#![allow(unused_labels)] // Test that labels injected by macros do not break hygiene. This // checks cases where the macros invocations are under the rhs of a diff --git a/src/test/ui/hygiene/hygienic-labels-in-let.stderr b/src/test/ui/hygiene/hygienic-labels-in-let.stderr index d88470f32a3e0..4acb34f2dcebe 100644 --- a/src/test/ui/hygiene/hygienic-labels-in-let.stderr +++ b/src/test/ui/hygiene/hygienic-labels-in-let.stderr @@ -1,5 +1,5 @@ warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:15:9 + --> $DIR/hygienic-labels-in-let.rs:16:9 | LL | 'x: loop { $e } | ^^ lifetime 'x already in scope @@ -11,7 +11,7 @@ LL | loop_x!(break 'x); | ------------------ in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:63:9 + --> $DIR/hygienic-labels-in-let.rs:64:9 | LL | 'x: loop { | -- first declared here @@ -20,7 +20,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:63:9 + --> $DIR/hygienic-labels-in-let.rs:64:9 | LL | 'x: loop { $e } | -- first declared here @@ -29,7 +29,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:15:9 + --> $DIR/hygienic-labels-in-let.rs:16:9 | LL | 'x: loop { $e } | ^^ lifetime 'x already in scope @@ -41,7 +41,7 @@ LL | loop_x!(break 'x); | ------------------ in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:15:9 + --> $DIR/hygienic-labels-in-let.rs:16:9 | LL | 'x: loop { $e } | ^^ @@ -53,7 +53,7 @@ LL | loop_x!(break 'x); | ------------------ in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:15:9 + --> $DIR/hygienic-labels-in-let.rs:16:9 | LL | 'x: loop { $e } | ^^ lifetime 'x already in scope @@ -65,7 +65,7 @@ LL | loop_x!(break 'x); | ------------------ in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:75:9 + --> $DIR/hygienic-labels-in-let.rs:76:9 | LL | 'x: loop { | -- first declared here @@ -74,7 +74,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:75:9 + --> $DIR/hygienic-labels-in-let.rs:76:9 | LL | 'x: loop { $e } | -- first declared here @@ -83,7 +83,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:75:9 + --> $DIR/hygienic-labels-in-let.rs:76:9 | LL | 'x: for _ in 0..1 { | -- first declared here @@ -92,7 +92,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:75:9 + --> $DIR/hygienic-labels-in-let.rs:76:9 | LL | 'x: loop { $e } | -- first declared here @@ -101,7 +101,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:26:9 + --> $DIR/hygienic-labels-in-let.rs:27:9 | LL | 'x: while 1 + 1 == 2 { $e } | ^^ lifetime 'x already in scope @@ -113,7 +113,7 @@ LL | while_true!(break 'x); | ---------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:26:9 + --> $DIR/hygienic-labels-in-let.rs:27:9 | LL | 'x: loop { $e } | -- first declared here @@ -125,7 +125,7 @@ LL | while_true!(break 'x); | ---------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:26:9 + --> $DIR/hygienic-labels-in-let.rs:27:9 | LL | 'x: while 1 + 1 == 2 { $e } | ^^ lifetime 'x already in scope @@ -137,7 +137,7 @@ LL | while_true!(break 'x); | ---------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:26:9 + --> $DIR/hygienic-labels-in-let.rs:27:9 | LL | 'x: loop { $e } | -- first declared here @@ -149,7 +149,7 @@ LL | while_true!(break 'x); | ---------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:26:9 + --> $DIR/hygienic-labels-in-let.rs:27:9 | LL | 'x: while 1 + 1 == 2 { $e } | ^^ lifetime 'x already in scope @@ -161,7 +161,7 @@ LL | while_true!(break 'x); | ---------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:89:9 + --> $DIR/hygienic-labels-in-let.rs:90:9 | LL | 'x: loop { | -- first declared here @@ -170,7 +170,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:89:9 + --> $DIR/hygienic-labels-in-let.rs:90:9 | LL | 'x: loop { $e } | -- first declared here @@ -179,7 +179,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:89:9 + --> $DIR/hygienic-labels-in-let.rs:90:9 | LL | 'x: for _ in 0..1 { | -- first declared here @@ -188,7 +188,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:89:9 + --> $DIR/hygienic-labels-in-let.rs:90:9 | LL | 'x: loop { $e } | -- first declared here @@ -197,7 +197,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:89:9 + --> $DIR/hygienic-labels-in-let.rs:90:9 | LL | 'x: for _ in 0..1 { | -- first declared here @@ -206,7 +206,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:89:9 + --> $DIR/hygienic-labels-in-let.rs:90:9 | LL | 'x: while 1 + 1 == 2 { $e } | -- first declared here @@ -215,7 +215,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:38:9 + --> $DIR/hygienic-labels-in-let.rs:39:9 | LL | 'x: for _ in 0..1 { $e } | ^^ lifetime 'x already in scope @@ -227,7 +227,7 @@ LL | run_once!(continue 'x); | ----------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:38:9 + --> $DIR/hygienic-labels-in-let.rs:39:9 | LL | 'x: loop { $e } | -- first declared here @@ -239,7 +239,7 @@ LL | run_once!(continue 'x); | ----------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:38:9 + --> $DIR/hygienic-labels-in-let.rs:39:9 | LL | 'x: for _ in 0..1 { $e } | ^^ lifetime 'x already in scope @@ -251,7 +251,7 @@ LL | run_once!(continue 'x); | ----------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:38:9 + --> $DIR/hygienic-labels-in-let.rs:39:9 | LL | 'x: loop { $e } | -- first declared here @@ -263,7 +263,7 @@ LL | run_once!(continue 'x); | ----------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:38:9 + --> $DIR/hygienic-labels-in-let.rs:39:9 | LL | 'x: for _ in 0..1 { $e } | ^^ lifetime 'x already in scope @@ -275,7 +275,7 @@ LL | run_once!(continue 'x); | ----------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:38:9 + --> $DIR/hygienic-labels-in-let.rs:39:9 | LL | 'x: while 1 + 1 == 2 { $e } | -- first declared here @@ -287,7 +287,7 @@ LL | run_once!(continue 'x); | ----------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels-in-let.rs:38:9 + --> $DIR/hygienic-labels-in-let.rs:39:9 | LL | 'x: for _ in 0..1 { $e } | ^^ lifetime 'x already in scope diff --git a/src/test/ui/hygiene/hygienic-labels.rs b/src/test/ui/hygiene/hygienic-labels.rs index 8eafb4c8d215a..c9f494b68b4a8 100644 --- a/src/test/ui/hygiene/hygienic-labels.rs +++ b/src/test/ui/hygiene/hygienic-labels.rs @@ -1,5 +1,6 @@ // run-pass #![allow(unreachable_code)] +#![allow(unused_labels)] // Test that labels injected by macros do not break hygiene. // Issue #24278: The label/lifetime shadowing checker from #24162 diff --git a/src/test/ui/hygiene/hygienic-labels.stderr b/src/test/ui/hygiene/hygienic-labels.stderr index 285e9037e977d..0833825940a85 100644 --- a/src/test/ui/hygiene/hygienic-labels.stderr +++ b/src/test/ui/hygiene/hygienic-labels.stderr @@ -1,5 +1,5 @@ warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:12:9 + --> $DIR/hygienic-labels.rs:13:9 | LL | 'x: loop { $e } | ^^ lifetime 'x already in scope @@ -11,7 +11,7 @@ LL | loop_x!(break 'x); | ------------------ in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:53:5 + --> $DIR/hygienic-labels.rs:54:5 | LL | 'x: for _ in 0..1 { | -- first declared here @@ -20,7 +20,7 @@ LL | 'x: loop { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:53:5 + --> $DIR/hygienic-labels.rs:54:5 | LL | 'x: loop { $e } | -- first declared here @@ -29,7 +29,7 @@ LL | 'x: loop { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:12:9 + --> $DIR/hygienic-labels.rs:13:9 | LL | 'x: loop { $e } | ^^ lifetime 'x already in scope @@ -41,7 +41,7 @@ LL | loop_x!(break 'x); | ------------------ in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:12:9 + --> $DIR/hygienic-labels.rs:13:9 | LL | 'x: loop { $e } | ^^ @@ -53,7 +53,7 @@ LL | loop_x!(break 'x); | ------------------ in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:12:9 + --> $DIR/hygienic-labels.rs:13:9 | LL | 'x: loop { $e } | ^^ lifetime 'x already in scope @@ -65,7 +65,7 @@ LL | loop_x!(break 'x); | ------------------ in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:62:5 + --> $DIR/hygienic-labels.rs:63:5 | LL | 'x: for _ in 0..1 { | -- first declared here @@ -74,7 +74,7 @@ LL | 'x: while 1 + 1 == 2 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:62:5 + --> $DIR/hygienic-labels.rs:63:5 | LL | 'x: loop { $e } | -- first declared here @@ -83,7 +83,7 @@ LL | 'x: while 1 + 1 == 2 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:62:5 + --> $DIR/hygienic-labels.rs:63:5 | LL | 'x: loop { | -- first declared here @@ -92,7 +92,7 @@ LL | 'x: while 1 + 1 == 2 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:62:5 + --> $DIR/hygienic-labels.rs:63:5 | LL | 'x: loop { $e } | -- first declared here @@ -101,7 +101,7 @@ LL | 'x: while 1 + 1 == 2 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:37:9 + --> $DIR/hygienic-labels.rs:38:9 | LL | 'x: while 1 + 1 == 2 { $e } | ^^ lifetime 'x already in scope @@ -113,7 +113,7 @@ LL | while_x!(break 'x); | ------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:37:9 + --> $DIR/hygienic-labels.rs:38:9 | LL | 'x: loop { $e } | -- first declared here @@ -125,7 +125,7 @@ LL | while_x!(break 'x); | ------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:37:9 + --> $DIR/hygienic-labels.rs:38:9 | LL | 'x: while 1 + 1 == 2 { $e } | ^^ lifetime 'x already in scope @@ -137,7 +137,7 @@ LL | while_x!(break 'x); | ------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:37:9 + --> $DIR/hygienic-labels.rs:38:9 | LL | 'x: loop { $e } | -- first declared here @@ -149,7 +149,7 @@ LL | while_x!(break 'x); | ------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:37:9 + --> $DIR/hygienic-labels.rs:38:9 | LL | 'x: while 1 + 1 == 2 { $e } | ^^ lifetime 'x already in scope @@ -161,7 +161,7 @@ LL | while_x!(break 'x); | ------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:72:5 + --> $DIR/hygienic-labels.rs:73:5 | LL | 'x: for _ in 0..1 { | -- first declared here @@ -170,7 +170,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:72:5 + --> $DIR/hygienic-labels.rs:73:5 | LL | 'x: loop { $e } | -- first declared here @@ -179,7 +179,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:72:5 + --> $DIR/hygienic-labels.rs:73:5 | LL | 'x: loop { | -- first declared here @@ -188,7 +188,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:72:5 + --> $DIR/hygienic-labels.rs:73:5 | LL | 'x: loop { $e } | -- first declared here @@ -197,7 +197,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:72:5 + --> $DIR/hygienic-labels.rs:73:5 | LL | 'x: while 1 + 1 == 2 { | -- first declared here @@ -206,7 +206,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:72:5 + --> $DIR/hygienic-labels.rs:73:5 | LL | 'x: while 1 + 1 == 2 { $e } | -- first declared here @@ -215,7 +215,7 @@ LL | 'x: for _ in 0..1 { | ^^ lifetime 'x already in scope warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:23:9 + --> $DIR/hygienic-labels.rs:24:9 | LL | 'x: for _ in 0..1 { $e } | ^^ lifetime 'x already in scope @@ -227,7 +227,7 @@ LL | run_once!(continue 'x); | ----------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:23:9 + --> $DIR/hygienic-labels.rs:24:9 | LL | 'x: loop { $e } | -- first declared here @@ -239,7 +239,7 @@ LL | run_once!(continue 'x); | ----------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:23:9 + --> $DIR/hygienic-labels.rs:24:9 | LL | 'x: for _ in 0..1 { $e } | ^^ lifetime 'x already in scope @@ -251,7 +251,7 @@ LL | run_once!(continue 'x); | ----------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:23:9 + --> $DIR/hygienic-labels.rs:24:9 | LL | 'x: loop { $e } | -- first declared here @@ -263,7 +263,7 @@ LL | run_once!(continue 'x); | ----------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:23:9 + --> $DIR/hygienic-labels.rs:24:9 | LL | 'x: for _ in 0..1 { $e } | ^^ lifetime 'x already in scope @@ -275,7 +275,7 @@ LL | run_once!(continue 'x); | ----------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:23:9 + --> $DIR/hygienic-labels.rs:24:9 | LL | 'x: for _ in 0..1 { $e } | ^^ lifetime 'x already in scope @@ -287,7 +287,7 @@ LL | run_once!(continue 'x); | ----------------------- in this macro invocation warning: label name `'x` shadows a label name that is already in scope - --> $DIR/hygienic-labels.rs:23:9 + --> $DIR/hygienic-labels.rs:24:9 | LL | 'x: for _ in 0..1 { $e } | ^^ lifetime 'x already in scope diff --git a/src/test/ui/issues/issue-2216.rs b/src/test/ui/issues/issue-2216.rs index fa712edcd1b75..ad54107423d6c 100644 --- a/src/test/ui/issues/issue-2216.rs +++ b/src/test/ui/issues/issue-2216.rs @@ -5,7 +5,7 @@ pub fn main() { 'foo: loop { 'bar: loop { - 'quux: loop { + loop { if 1 == 2 { break 'foo; } diff --git a/src/test/ui/macros/macro-lifetime-used-with-labels.rs b/src/test/ui/macros/macro-lifetime-used-with-labels.rs index 86a3e9f44c38f..2e9da6f9dc88c 100644 --- a/src/test/ui/macros/macro-lifetime-used-with-labels.rs +++ b/src/test/ui/macros/macro-lifetime-used-with-labels.rs @@ -1,6 +1,6 @@ // run-pass #![allow(stable_features)] - +#![allow(unused_labels)] #![allow(unreachable_code)] macro_rules! x { From 34a45a5309dad66025df506a388fbdf1da9afa40 Mon Sep 17 00:00:00 2001 From: Bart Massey Date: Tue, 12 Nov 2019 03:21:10 -0800 Subject: [PATCH 2/2] Changed unused_labels lint default from allow to warn Closes #66324. --- src/librustc/lint/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index f8a592d22c19c..8c556a09e1ebe 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -327,7 +327,7 @@ declare_lint! { declare_lint! { pub UNUSED_LABELS, - Allow, + Warn, "detects labels that are never used" }