Skip to content

Commit 56f830e

Browse files
authored
Rollup merge of #66325 - BartMassey:master, r=joshtriplett
Change unused_labels from allow to warn Fixes #66324, making the unused_labels lint warn instead of allow by default. I'm told @rust-lang/lang will need to review this, and perhaps will want to do a crater run.
2 parents de17464 + 34a45a5 commit 56f830e

File tree

13 files changed

+68
-65
lines changed

13 files changed

+68
-65
lines changed

src/librustc/lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ declare_lint! {
329329

330330
declare_lint! {
331331
pub UNUSED_LABELS,
332-
Allow,
332+
Warn,
333333
"detects labels that are never used"
334334
}
335335

src/librustc/ty/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2486,7 +2486,7 @@ where
24862486
'descend_newtypes: while !fat_pointer_layout.ty.is_unsafe_ptr()
24872487
&& !fat_pointer_layout.ty.is_region_ptr()
24882488
{
2489-
'iter_fields: for i in 0..fat_pointer_layout.fields.count() {
2489+
for i in 0..fat_pointer_layout.fields.count() {
24902490
let field_layout = fat_pointer_layout.field(cx, i);
24912491

24922492
if !field_layout.is_zst() {

src/librustc_codegen_ssa/mir/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
718718
'descend_newtypes: while !op.layout.ty.is_unsafe_ptr()
719719
&& !op.layout.ty.is_region_ptr()
720720
{
721-
'iter_fields: for i in 0..op.layout.fields.count() {
721+
for i in 0..op.layout.fields.count() {
722722
let field = op.extract_field(&mut bx, i);
723723
if !field.layout.is_zst() {
724724
// we found the one non-zero-sized field that is allowed

src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
249249
// Reverse DFS. But for drops, we do it a bit differently.
250250
// The stack only ever stores *terminators of blocks*. Within
251251
// a block, we walk back the statements in an inner loop.
252-
'next_block: while let Some(term_point) = self.stack.pop() {
252+
while let Some(term_point) = self.stack.pop() {
253253
self.compute_drop_live_points_for_block(mpi, term_point);
254254
}
255255
}

src/libstd/keyword_docs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ mod as_keyword { }
5757
/// 'outer: for i in 1..=5 {
5858
/// println!("outer iteration (i): {}", i);
5959
///
60-
/// 'inner: for j in 1..=200 {
60+
/// '_inner: for j in 1..=200 {
6161
/// println!(" inner iteration (j): {}", j);
6262
/// if j >= 3 {
6363
/// // breaks from inner loop, let's outer loop continue.
@@ -178,7 +178,7 @@ mod const_keyword { }
178178
///```rust
179179
/// // Print Odd numbers under 30 with unit <= 5
180180
/// 'tens: for ten in 0..3 {
181-
/// 'units: for unit in 0..=9 {
181+
/// '_units: for unit in 0..=9 {
182182
/// if unit % 2 == 0 {
183183
/// continue;
184184
/// }

src/test/ui/for-loop-while/label_break_value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn label_break_mixed(v: u32) -> u32 {
7777
}
7878
// Labeled breaking an outer loop still works
7979
'd: loop {
80-
'e: {
80+
{
8181
if v == r {
8282
break 'b;
8383
}

src/test/ui/for-loop-while/loop-label-shadowing.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
fn main() {
77
let mut foo = Vec::new();
8+
#[allow(unused_labels)]
89
'foo: for i in &[1, 2, 3] {
910
foo.push(*i);
1011
}

src/test/ui/hygiene/hygienic-labels-in-let.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// run-pass
22
#![allow(unreachable_code)]
3+
#![allow(unused_labels)]
34

45
// Test that labels injected by macros do not break hygiene. This
56
// checks cases where the macros invocations are under the rhs of a

src/test/ui/hygiene/hygienic-labels-in-let.stderr

+28-28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: label name `'x` shadows a label name that is already in scope
2-
--> $DIR/hygienic-labels-in-let.rs:15:9
2+
--> $DIR/hygienic-labels-in-let.rs:16:9
33
|
44
LL | 'x: loop { $e }
55
| ^^ lifetime 'x already in scope
@@ -11,7 +11,7 @@ LL | loop_x!(break 'x);
1111
| ------------------ in this macro invocation
1212

1313
warning: label name `'x` shadows a label name that is already in scope
14-
--> $DIR/hygienic-labels-in-let.rs:63:9
14+
--> $DIR/hygienic-labels-in-let.rs:64:9
1515
|
1616
LL | 'x: loop {
1717
| -- first declared here
@@ -20,7 +20,7 @@ LL | 'x: for _ in 0..1 {
2020
| ^^ lifetime 'x already in scope
2121

2222
warning: label name `'x` shadows a label name that is already in scope
23-
--> $DIR/hygienic-labels-in-let.rs:63:9
23+
--> $DIR/hygienic-labels-in-let.rs:64:9
2424
|
2525
LL | 'x: loop { $e }
2626
| -- first declared here
@@ -29,7 +29,7 @@ LL | 'x: for _ in 0..1 {
2929
| ^^ lifetime 'x already in scope
3030

3131
warning: label name `'x` shadows a label name that is already in scope
32-
--> $DIR/hygienic-labels-in-let.rs:15:9
32+
--> $DIR/hygienic-labels-in-let.rs:16:9
3333
|
3434
LL | 'x: loop { $e }
3535
| ^^ lifetime 'x already in scope
@@ -41,7 +41,7 @@ LL | loop_x!(break 'x);
4141
| ------------------ in this macro invocation
4242

4343
warning: label name `'x` shadows a label name that is already in scope
44-
--> $DIR/hygienic-labels-in-let.rs:15:9
44+
--> $DIR/hygienic-labels-in-let.rs:16:9
4545
|
4646
LL | 'x: loop { $e }
4747
| ^^
@@ -53,7 +53,7 @@ LL | loop_x!(break 'x);
5353
| ------------------ in this macro invocation
5454

5555
warning: label name `'x` shadows a label name that is already in scope
56-
--> $DIR/hygienic-labels-in-let.rs:15:9
56+
--> $DIR/hygienic-labels-in-let.rs:16:9
5757
|
5858
LL | 'x: loop { $e }
5959
| ^^ lifetime 'x already in scope
@@ -65,7 +65,7 @@ LL | loop_x!(break 'x);
6565
| ------------------ in this macro invocation
6666

6767
warning: label name `'x` shadows a label name that is already in scope
68-
--> $DIR/hygienic-labels-in-let.rs:75:9
68+
--> $DIR/hygienic-labels-in-let.rs:76:9
6969
|
7070
LL | 'x: loop {
7171
| -- first declared here
@@ -74,7 +74,7 @@ LL | 'x: for _ in 0..1 {
7474
| ^^ lifetime 'x already in scope
7575

7676
warning: label name `'x` shadows a label name that is already in scope
77-
--> $DIR/hygienic-labels-in-let.rs:75:9
77+
--> $DIR/hygienic-labels-in-let.rs:76:9
7878
|
7979
LL | 'x: loop { $e }
8080
| -- first declared here
@@ -83,7 +83,7 @@ LL | 'x: for _ in 0..1 {
8383
| ^^ lifetime 'x already in scope
8484

8585
warning: label name `'x` shadows a label name that is already in scope
86-
--> $DIR/hygienic-labels-in-let.rs:75:9
86+
--> $DIR/hygienic-labels-in-let.rs:76:9
8787
|
8888
LL | 'x: for _ in 0..1 {
8989
| -- first declared here
@@ -92,7 +92,7 @@ LL | 'x: for _ in 0..1 {
9292
| ^^ lifetime 'x already in scope
9393

9494
warning: label name `'x` shadows a label name that is already in scope
95-
--> $DIR/hygienic-labels-in-let.rs:75:9
95+
--> $DIR/hygienic-labels-in-let.rs:76:9
9696
|
9797
LL | 'x: loop { $e }
9898
| -- first declared here
@@ -101,7 +101,7 @@ LL | 'x: for _ in 0..1 {
101101
| ^^ lifetime 'x already in scope
102102

103103
warning: label name `'x` shadows a label name that is already in scope
104-
--> $DIR/hygienic-labels-in-let.rs:26:9
104+
--> $DIR/hygienic-labels-in-let.rs:27:9
105105
|
106106
LL | 'x: while 1 + 1 == 2 { $e }
107107
| ^^ lifetime 'x already in scope
@@ -113,7 +113,7 @@ LL | while_true!(break 'x);
113113
| ---------------------- in this macro invocation
114114

115115
warning: label name `'x` shadows a label name that is already in scope
116-
--> $DIR/hygienic-labels-in-let.rs:26:9
116+
--> $DIR/hygienic-labels-in-let.rs:27:9
117117
|
118118
LL | 'x: loop { $e }
119119
| -- first declared here
@@ -125,7 +125,7 @@ LL | while_true!(break 'x);
125125
| ---------------------- in this macro invocation
126126

127127
warning: label name `'x` shadows a label name that is already in scope
128-
--> $DIR/hygienic-labels-in-let.rs:26:9
128+
--> $DIR/hygienic-labels-in-let.rs:27:9
129129
|
130130
LL | 'x: while 1 + 1 == 2 { $e }
131131
| ^^ lifetime 'x already in scope
@@ -137,7 +137,7 @@ LL | while_true!(break 'x);
137137
| ---------------------- in this macro invocation
138138

139139
warning: label name `'x` shadows a label name that is already in scope
140-
--> $DIR/hygienic-labels-in-let.rs:26:9
140+
--> $DIR/hygienic-labels-in-let.rs:27:9
141141
|
142142
LL | 'x: loop { $e }
143143
| -- first declared here
@@ -149,7 +149,7 @@ LL | while_true!(break 'x);
149149
| ---------------------- in this macro invocation
150150

151151
warning: label name `'x` shadows a label name that is already in scope
152-
--> $DIR/hygienic-labels-in-let.rs:26:9
152+
--> $DIR/hygienic-labels-in-let.rs:27:9
153153
|
154154
LL | 'x: while 1 + 1 == 2 { $e }
155155
| ^^ lifetime 'x already in scope
@@ -161,7 +161,7 @@ LL | while_true!(break 'x);
161161
| ---------------------- in this macro invocation
162162

163163
warning: label name `'x` shadows a label name that is already in scope
164-
--> $DIR/hygienic-labels-in-let.rs:89:9
164+
--> $DIR/hygienic-labels-in-let.rs:90:9
165165
|
166166
LL | 'x: loop {
167167
| -- first declared here
@@ -170,7 +170,7 @@ LL | 'x: for _ in 0..1 {
170170
| ^^ lifetime 'x already in scope
171171

172172
warning: label name `'x` shadows a label name that is already in scope
173-
--> $DIR/hygienic-labels-in-let.rs:89:9
173+
--> $DIR/hygienic-labels-in-let.rs:90:9
174174
|
175175
LL | 'x: loop { $e }
176176
| -- first declared here
@@ -179,7 +179,7 @@ LL | 'x: for _ in 0..1 {
179179
| ^^ lifetime 'x already in scope
180180

181181
warning: label name `'x` shadows a label name that is already in scope
182-
--> $DIR/hygienic-labels-in-let.rs:89:9
182+
--> $DIR/hygienic-labels-in-let.rs:90:9
183183
|
184184
LL | 'x: for _ in 0..1 {
185185
| -- first declared here
@@ -188,7 +188,7 @@ LL | 'x: for _ in 0..1 {
188188
| ^^ lifetime 'x already in scope
189189

190190
warning: label name `'x` shadows a label name that is already in scope
191-
--> $DIR/hygienic-labels-in-let.rs:89:9
191+
--> $DIR/hygienic-labels-in-let.rs:90:9
192192
|
193193
LL | 'x: loop { $e }
194194
| -- first declared here
@@ -197,7 +197,7 @@ LL | 'x: for _ in 0..1 {
197197
| ^^ lifetime 'x already in scope
198198

199199
warning: label name `'x` shadows a label name that is already in scope
200-
--> $DIR/hygienic-labels-in-let.rs:89:9
200+
--> $DIR/hygienic-labels-in-let.rs:90:9
201201
|
202202
LL | 'x: for _ in 0..1 {
203203
| -- first declared here
@@ -206,7 +206,7 @@ LL | 'x: for _ in 0..1 {
206206
| ^^ lifetime 'x already in scope
207207

208208
warning: label name `'x` shadows a label name that is already in scope
209-
--> $DIR/hygienic-labels-in-let.rs:89:9
209+
--> $DIR/hygienic-labels-in-let.rs:90:9
210210
|
211211
LL | 'x: while 1 + 1 == 2 { $e }
212212
| -- first declared here
@@ -215,7 +215,7 @@ LL | 'x: for _ in 0..1 {
215215
| ^^ lifetime 'x already in scope
216216

217217
warning: label name `'x` shadows a label name that is already in scope
218-
--> $DIR/hygienic-labels-in-let.rs:38:9
218+
--> $DIR/hygienic-labels-in-let.rs:39:9
219219
|
220220
LL | 'x: for _ in 0..1 { $e }
221221
| ^^ lifetime 'x already in scope
@@ -227,7 +227,7 @@ LL | run_once!(continue 'x);
227227
| ----------------------- in this macro invocation
228228

229229
warning: label name `'x` shadows a label name that is already in scope
230-
--> $DIR/hygienic-labels-in-let.rs:38:9
230+
--> $DIR/hygienic-labels-in-let.rs:39:9
231231
|
232232
LL | 'x: loop { $e }
233233
| -- first declared here
@@ -239,7 +239,7 @@ LL | run_once!(continue 'x);
239239
| ----------------------- in this macro invocation
240240

241241
warning: label name `'x` shadows a label name that is already in scope
242-
--> $DIR/hygienic-labels-in-let.rs:38:9
242+
--> $DIR/hygienic-labels-in-let.rs:39:9
243243
|
244244
LL | 'x: for _ in 0..1 { $e }
245245
| ^^ lifetime 'x already in scope
@@ -251,7 +251,7 @@ LL | run_once!(continue 'x);
251251
| ----------------------- in this macro invocation
252252

253253
warning: label name `'x` shadows a label name that is already in scope
254-
--> $DIR/hygienic-labels-in-let.rs:38:9
254+
--> $DIR/hygienic-labels-in-let.rs:39:9
255255
|
256256
LL | 'x: loop { $e }
257257
| -- first declared here
@@ -263,7 +263,7 @@ LL | run_once!(continue 'x);
263263
| ----------------------- in this macro invocation
264264

265265
warning: label name `'x` shadows a label name that is already in scope
266-
--> $DIR/hygienic-labels-in-let.rs:38:9
266+
--> $DIR/hygienic-labels-in-let.rs:39:9
267267
|
268268
LL | 'x: for _ in 0..1 { $e }
269269
| ^^ lifetime 'x already in scope
@@ -275,7 +275,7 @@ LL | run_once!(continue 'x);
275275
| ----------------------- in this macro invocation
276276

277277
warning: label name `'x` shadows a label name that is already in scope
278-
--> $DIR/hygienic-labels-in-let.rs:38:9
278+
--> $DIR/hygienic-labels-in-let.rs:39:9
279279
|
280280
LL | 'x: while 1 + 1 == 2 { $e }
281281
| -- first declared here
@@ -287,7 +287,7 @@ LL | run_once!(continue 'x);
287287
| ----------------------- in this macro invocation
288288

289289
warning: label name `'x` shadows a label name that is already in scope
290-
--> $DIR/hygienic-labels-in-let.rs:38:9
290+
--> $DIR/hygienic-labels-in-let.rs:39:9
291291
|
292292
LL | 'x: for _ in 0..1 { $e }
293293
| ^^ lifetime 'x already in scope

src/test/ui/hygiene/hygienic-labels.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// run-pass
22
#![allow(unreachable_code)]
3+
#![allow(unused_labels)]
34
// Test that labels injected by macros do not break hygiene.
45

56
// Issue #24278: The label/lifetime shadowing checker from #24162

0 commit comments

Comments
 (0)