diff options
| author | bors <bors@rust-lang.org> | 2021-01-22 16:04:36 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-22 16:04:36 +0000 |
| commit | b814b639836aa76b5c6deaa585367150bb2debf4 (patch) | |
| tree | ff77c2ba8ee58410a01d8606ef83071711e78195 /src/test | |
| parent | f2de221b0063261140a336c448bf1421170c9a74 (diff) | |
| parent | 9c2a5776b205aebec2685966fc24f59dde7fe76a (diff) | |
| download | rust-b814b639836aa76b5c6deaa585367150bb2debf4.tar.gz rust-b814b639836aa76b5c6deaa585367150bb2debf4.zip | |
Auto merge of #81271 - m-ou-se:rollup-xv7gq3w, r=m-ou-se
Rollup of 10 pull requests Successful merges: - #80573 (Deny rustc::internal lints for rustdoc and clippy) - #81173 (Expand docs on Iterator::intersperse) - #81194 (Stabilize std::panic::panic_any.) - #81202 (Don't prefix 0x for each segments in `dbg!(Ipv6)`) - #81225 (Make 'docs' nullable in rustdoc-json output) - #81227 (Remove doctree::StructType) - #81233 (Document why not use concat! in dbg! macro) - #81236 (Gracefully handle loop labels missing leading `'` in different positions) - #81241 (Turn alloc's force_expr macro into a regular macro_rules.) - #81242 (Enforce statically that `MIN_NON_ZERO_CAP` is calculated at compile time) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/issues/issue-1962.fixed | 4 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-1962.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-1962.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-27042.stderr | 2 | ||||
| -rw-r--r-- | src/test/ui/label/label_misspelled.rs | 50 | ||||
| -rw-r--r-- | src/test/ui/label/label_misspelled.stderr | 211 | ||||
| -rw-r--r-- | src/test/ui/label/label_misspelled_2.rs | 16 | ||||
| -rw-r--r-- | src/test/ui/label/label_misspelled_2.stderr | 37 | ||||
| -rw-r--r-- | src/test/ui/loops/loop-break-value-no-repeat.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/loops/loop-break-value.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/loops/loop-break-value.stderr | 70 |
11 files changed, 338 insertions, 65 deletions
diff --git a/src/test/ui/issues/issue-1962.fixed b/src/test/ui/issues/issue-1962.fixed index b810a90ef37..897fd172b29 100644 --- a/src/test/ui/issues/issue-1962.fixed +++ b/src/test/ui/issues/issue-1962.fixed @@ -3,8 +3,8 @@ fn main() { let mut i = 0; - loop { //~ ERROR denote infinite loops with `loop + 'a: loop { //~ ERROR denote infinite loops with `loop i += 1; - if i == 5 { break; } + if i == 5 { break 'a; } } } diff --git a/src/test/ui/issues/issue-1962.rs b/src/test/ui/issues/issue-1962.rs index 00d2bbd2850..71e87410087 100644 --- a/src/test/ui/issues/issue-1962.rs +++ b/src/test/ui/issues/issue-1962.rs @@ -3,8 +3,8 @@ fn main() { let mut i = 0; - while true { //~ ERROR denote infinite loops with `loop + 'a: while true { //~ ERROR denote infinite loops with `loop i += 1; - if i == 5 { break; } + if i == 5 { break 'a; } } } diff --git a/src/test/ui/issues/issue-1962.stderr b/src/test/ui/issues/issue-1962.stderr index 17142912696..4c32a4cf3dd 100644 --- a/src/test/ui/issues/issue-1962.stderr +++ b/src/test/ui/issues/issue-1962.stderr @@ -1,8 +1,8 @@ error: denote infinite loops with `loop { ... }` --> $DIR/issue-1962.rs:6:5 | -LL | while true { - | ^^^^^^^^^^ help: use `loop` +LL | 'a: while true { + | ^^^^^^^^^^^^^^ help: use `loop` | = note: requested on the command line with `-D while-true` diff --git a/src/test/ui/issues/issue-27042.stderr b/src/test/ui/issues/issue-27042.stderr index 7dee1a6a5f0..59ef28481d0 100644 --- a/src/test/ui/issues/issue-27042.stderr +++ b/src/test/ui/issues/issue-27042.stderr @@ -4,7 +4,7 @@ warning: denote infinite loops with `loop { ... }` LL | / 'b: LL | | LL | | while true { break }; // but here we cite the whole loop - | |____________________________^ help: use `loop` + | |__________________^ help: use `loop` | = note: `#[warn(while_true)]` on by default diff --git a/src/test/ui/label/label_misspelled.rs b/src/test/ui/label/label_misspelled.rs index ebfd5642c9f..e3180b06ecb 100644 --- a/src/test/ui/label/label_misspelled.rs +++ b/src/test/ui/label/label_misspelled.rs @@ -1,18 +1,62 @@ +#![warn(unused_labels)] + fn main() { + 'while_loop: while true { //~ WARN denote infinite loops with + //~^ WARN unused label + while_loop; + //~^ ERROR cannot find value `while_loop` in this scope + }; + 'while_let: while let Some(_) = Some(()) { + //~^ WARN unused label + while_let; + //~^ ERROR cannot find value `while_let` in this scope + } + 'for_loop: for _ in 0..3 { + //~^ WARN unused label + for_loop; + //~^ ERROR cannot find value `for_loop` in this scope + }; 'LOOP: loop { + //~^ WARN unused label LOOP; //~^ ERROR cannot find value `LOOP` in this scope }; +} + +fn foo() { + 'LOOP: loop { + break LOOP; + //~^ ERROR cannot find value `LOOP` in this scope + }; 'while_loop: while true { //~ WARN denote infinite loops with - while_loop; + break while_loop; //~^ ERROR cannot find value `while_loop` in this scope }; 'while_let: while let Some(_) = Some(()) { - while_let; + break while_let; //~^ ERROR cannot find value `while_let` in this scope } 'for_loop: for _ in 0..3 { - for_loop; + break for_loop; //~^ ERROR cannot find value `for_loop` in this scope }; } + +fn bar() { + let foo = (); + 'while_loop: while true { //~ WARN denote infinite loops with + //~^ WARN unused label + break foo; + //~^ ERROR `break` with value from a `while` loop + }; + 'while_let: while let Some(_) = Some(()) { + //~^ WARN unused label + break foo; + //~^ ERROR `break` with value from a `while` loop + } + 'for_loop: for _ in 0..3 { + //~^ WARN unused label + break foo; + //~^ ERROR `break` with value from a `for` loop + }; +} diff --git a/src/test/ui/label/label_misspelled.stderr b/src/test/ui/label/label_misspelled.stderr index 1368ca4126c..b09695787a4 100644 --- a/src/test/ui/label/label_misspelled.stderr +++ b/src/test/ui/label/label_misspelled.stderr @@ -1,47 +1,206 @@ -error[E0425]: cannot find value `LOOP` in this scope - --> $DIR/label_misspelled.rs:3:9 - | -LL | LOOP; - | ^^^^ - | | - | not found in this scope - | help: a label with a similar name exists: `'LOOP` - error[E0425]: cannot find value `while_loop` in this scope - --> $DIR/label_misspelled.rs:7:9 + --> $DIR/label_misspelled.rs:6:9 | +LL | 'while_loop: while true { + | ----------- a label with a similar name exists +LL | LL | while_loop; - | ^^^^^^^^^^ - | | - | not found in this scope - | help: a label with a similar name exists: `'while_loop` + | ^^^^^^^^^^ not found in this scope error[E0425]: cannot find value `while_let` in this scope --> $DIR/label_misspelled.rs:11:9 | +LL | 'while_let: while let Some(_) = Some(()) { + | ---------- a label with a similar name exists +LL | LL | while_let; - | ^^^^^^^^^ - | | - | not found in this scope - | help: a label with a similar name exists: `'while_let` + | ^^^^^^^^^ not found in this scope error[E0425]: cannot find value `for_loop` in this scope - --> $DIR/label_misspelled.rs:15:9 + --> $DIR/label_misspelled.rs:16:9 | +LL | 'for_loop: for _ in 0..3 { + | --------- a label with a similar name exists +LL | LL | for_loop; - | ^^^^^^^^ - | | - | not found in this scope - | help: a label with a similar name exists: `'for_loop` + | ^^^^^^^^ not found in this scope + +error[E0425]: cannot find value `LOOP` in this scope + --> $DIR/label_misspelled.rs:21:9 + | +LL | 'LOOP: loop { + | ----- a label with a similar name exists +LL | +LL | LOOP; + | ^^^^ not found in this scope + +error[E0425]: cannot find value `LOOP` in this scope + --> $DIR/label_misspelled.rs:28:15 + | +LL | 'LOOP: loop { + | ----- a label with a similar name exists +LL | break LOOP; + | ^^^^ + | | + | not found in this scope + | help: use the similarly named label: `'LOOP` + +error[E0425]: cannot find value `while_loop` in this scope + --> $DIR/label_misspelled.rs:32:15 + | +LL | 'while_loop: while true { + | ----------- a label with a similar name exists +LL | break while_loop; + | ^^^^^^^^^^ + | | + | not found in this scope + | help: use the similarly named label: `'while_loop` + +error[E0425]: cannot find value `while_let` in this scope + --> $DIR/label_misspelled.rs:36:15 + | +LL | 'while_let: while let Some(_) = Some(()) { + | ---------- a label with a similar name exists +LL | break while_let; + | ^^^^^^^^^ + | | + | not found in this scope + | help: use the similarly named label: `'while_let` + +error[E0425]: cannot find value `for_loop` in this scope + --> $DIR/label_misspelled.rs:40:15 + | +LL | 'for_loop: for _ in 0..3 { + | --------- a label with a similar name exists +LL | break for_loop; + | ^^^^^^^^ + | | + | not found in this scope + | help: use the similarly named label: `'for_loop` + +warning: unused label + --> $DIR/label_misspelled.rs:4:5 + | +LL | 'while_loop: while true { + | ^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/label_misspelled.rs:1:9 + | +LL | #![warn(unused_labels)] + | ^^^^^^^^^^^^^ warning: denote infinite loops with `loop { ... }` - --> $DIR/label_misspelled.rs:6:5 + --> $DIR/label_misspelled.rs:4:5 | LL | 'while_loop: while true { | ^^^^^^^^^^^^^^^^^^^^^^^ help: use `loop` | = note: `#[warn(while_true)]` on by default -error: aborting due to 4 previous errors; 1 warning emitted +warning: unused label + --> $DIR/label_misspelled.rs:9:5 + | +LL | 'while_let: while let Some(_) = Some(()) { + | ^^^^^^^^^^ + +warning: unused label + --> $DIR/label_misspelled.rs:14:5 + | +LL | 'for_loop: for _ in 0..3 { + | ^^^^^^^^^ + +warning: unused label + --> $DIR/label_misspelled.rs:19:5 + | +LL | 'LOOP: loop { + | ^^^^^ + +warning: denote infinite loops with `loop { ... }` + --> $DIR/label_misspelled.rs:31:5 + | +LL | 'while_loop: while true { + | ^^^^^^^^^^^^^^^^^^^^^^^ help: use `loop` + +warning: unused label + --> $DIR/label_misspelled.rs:47:5 + | +LL | 'while_loop: while true { + | ^^^^^^^^^^^ + +warning: denote infinite loops with `loop { ... }` + --> $DIR/label_misspelled.rs:47:5 + | +LL | 'while_loop: while true { + | ^^^^^^^^^^^^^^^^^^^^^^^ help: use `loop` + +warning: unused label + --> $DIR/label_misspelled.rs:52:5 + | +LL | 'while_let: while let Some(_) = Some(()) { + | ^^^^^^^^^^ + +warning: unused label + --> $DIR/label_misspelled.rs:57:5 + | +LL | 'for_loop: for _ in 0..3 { + | ^^^^^^^^^ + +error[E0571]: `break` with value from a `while` loop + --> $DIR/label_misspelled.rs:49:9 + | +LL | 'while_loop: while true { + | ----------------------- you can't `break` with a value in a `while` loop +LL | +LL | break foo; + | ^^^^^^^^^ can only break with a value inside `loop` or breakable block + | +help: use `break` on its own without a value inside this `while` loop + | +LL | break; + | ^^^^^ +help: alternatively, you might have meant to use the available loop label + | +LL | break 'while_loop; + | ^^^^^^^^^^^ + +error[E0571]: `break` with value from a `while` loop + --> $DIR/label_misspelled.rs:54:9 + | +LL | 'while_let: while let Some(_) = Some(()) { + | ---------------------------------------- you can't `break` with a value in a `while` loop +LL | +LL | break foo; + | ^^^^^^^^^ can only break with a value inside `loop` or breakable block + | +help: use `break` on its own without a value inside this `while` loop + | +LL | break; + | ^^^^^ +help: alternatively, you might have meant to use the available loop label + | +LL | break 'while_let; + | ^^^^^^^^^^ + +error[E0571]: `break` with value from a `for` loop + --> $DIR/label_misspelled.rs:59:9 + | +LL | 'for_loop: for _ in 0..3 { + | ------------------------ you can't `break` with a value in a `for` loop +LL | +LL | break foo; + | ^^^^^^^^^ can only break with a value inside `loop` or breakable block + | +help: use `break` on its own without a value inside this `for` loop + | +LL | break; + | ^^^^^ +help: alternatively, you might have meant to use the available loop label + | +LL | break 'for_loop; + | ^^^^^^^^^ + +error: aborting due to 11 previous errors; 10 warnings emitted -For more information about this error, try `rustc --explain E0425`. +Some errors have detailed explanations: E0425, E0571. +For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui/label/label_misspelled_2.rs b/src/test/ui/label/label_misspelled_2.rs new file mode 100644 index 00000000000..55bbe6b30a5 --- /dev/null +++ b/src/test/ui/label/label_misspelled_2.rs @@ -0,0 +1,16 @@ +#![warn(unused_labels)] + +fn main() { + 'a: for _ in 0..1 { + break 'a; + } + 'b: for _ in 0..1 { + break b; //~ ERROR cannot find value `b` in this scope + } + c: for _ in 0..1 { //~ ERROR malformed loop label + break 'c; + } + d: for _ in 0..1 { //~ ERROR malformed loop label + break d; //~ ERROR cannot find value `d` in this scope + } +} diff --git a/src/test/ui/label/label_misspelled_2.stderr b/src/test/ui/label/label_misspelled_2.stderr new file mode 100644 index 00000000000..960646d9894 --- /dev/null +++ b/src/test/ui/label/label_misspelled_2.stderr @@ -0,0 +1,37 @@ +error: malformed loop label + --> $DIR/label_misspelled_2.rs:10:5 + | +LL | c: for _ in 0..1 { + | ^ help: use the correct loop label format: `'c` + +error: malformed loop label + --> $DIR/label_misspelled_2.rs:13:5 + | +LL | d: for _ in 0..1 { + | ^ help: use the correct loop label format: `'d` + +error[E0425]: cannot find value `b` in this scope + --> $DIR/label_misspelled_2.rs:8:15 + | +LL | 'b: for _ in 0..1 { + | -- a label with a similar name exists +LL | break b; + | ^ + | | + | not found in this scope + | help: use the similarly named label: `'b` + +error[E0425]: cannot find value `d` in this scope + --> $DIR/label_misspelled_2.rs:14:15 + | +LL | d: for _ in 0..1 { + | - a label with a similar name exists +LL | break d; + | ^ + | | + | not found in this scope + | help: use the similarly named label: `'d` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/loops/loop-break-value-no-repeat.stderr b/src/test/ui/loops/loop-break-value-no-repeat.stderr index ff93e9220e9..1c0d39a6e5a 100644 --- a/src/test/ui/loops/loop-break-value-no-repeat.stderr +++ b/src/test/ui/loops/loop-break-value-no-repeat.stderr @@ -1,10 +1,12 @@ error[E0571]: `break` with value from a `for` loop --> $DIR/loop-break-value-no-repeat.rs:12:9 | +LL | for _ in &[1,2,3] { + | ----------------- you can't `break` with a value in a `for` loop LL | break 22 | ^^^^^^^^ can only break with a value inside `loop` or breakable block | -help: instead, use `break` on its own without a value inside this `for` loop +help: use `break` on its own without a value inside this `for` loop | LL | break | ^^^^^ diff --git a/src/test/ui/loops/loop-break-value.rs b/src/test/ui/loops/loop-break-value.rs index 8a080cfdf49..51c9a36a039 100644 --- a/src/test/ui/loops/loop-break-value.rs +++ b/src/test/ui/loops/loop-break-value.rs @@ -94,6 +94,5 @@ fn main() { 'LOOP: for _ in 0 .. 9 { break LOOP; //~^ ERROR cannot find value `LOOP` in this scope - //~| ERROR `break` with value from a `for` loop } } diff --git a/src/test/ui/loops/loop-break-value.stderr b/src/test/ui/loops/loop-break-value.stderr index 0237435c8b4..adb099f9b17 100644 --- a/src/test/ui/loops/loop-break-value.stderr +++ b/src/test/ui/loops/loop-break-value.stderr @@ -1,11 +1,13 @@ error[E0425]: cannot find value `LOOP` in this scope --> $DIR/loop-break-value.rs:95:15 | +LL | 'LOOP: for _ in 0 .. 9 { + | ----- a label with a similar name exists LL | break LOOP; | ^^^^ | | | not found in this scope - | help: a label with a similar name exists: `'LOOP` + | help: use the similarly named label: `'LOOP` warning: denote infinite loops with `loop { ... }` --> $DIR/loop-break-value.rs:26:5 @@ -18,32 +20,44 @@ LL | 'while_loop: while true { error[E0571]: `break` with value from a `while` loop --> $DIR/loop-break-value.rs:28:9 | +LL | 'while_loop: while true { + | ----------------------- you can't `break` with a value in a `while` loop +LL | break; LL | break (); | ^^^^^^^^ can only break with a value inside `loop` or breakable block | -help: instead, use `break` on its own without a value inside this `while` loop +help: use `break` on its own without a value inside this `while` loop | LL | break; | ^^^^^ +help: alternatively, you might have meant to use the available loop label + | +LL | break 'while_loop; + | ^^^^^^^^^^^ error[E0571]: `break` with value from a `while` loop --> $DIR/loop-break-value.rs:30:13 | +LL | 'while_loop: while true { + | ----------------------- you can't `break` with a value in a `while` loop +... LL | break 'while_loop 123; | ^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block | -help: instead, use `break` on its own without a value inside this `while` loop +help: use `break` on its own without a value inside this `while` loop | -LL | break; - | ^^^^^ +LL | break 'while_loop; + | ^^^^^^^^^^^^^^^^^ error[E0571]: `break` with value from a `while` loop --> $DIR/loop-break-value.rs:38:12 | +LL | while let Some(_) = Some(()) { + | ---------------------------- you can't `break` with a value in a `while` loop LL | if break () { | ^^^^^^^^ can only break with a value inside `loop` or breakable block | -help: instead, use `break` on its own without a value inside this `while` loop +help: use `break` on its own without a value inside this `while` loop | LL | if break { | ^^^^^ @@ -51,10 +65,12 @@ LL | if break { error[E0571]: `break` with value from a `while` loop --> $DIR/loop-break-value.rs:43:9 | +LL | while let Some(_) = Some(()) { + | ---------------------------- you can't `break` with a value in a `while` loop LL | break None; | ^^^^^^^^^^ can only break with a value inside `loop` or breakable block | -help: instead, use `break` on its own without a value inside this `while` loop +help: use `break` on its own without a value inside this `while` loop | LL | break; | ^^^^^ @@ -62,21 +78,26 @@ LL | break; error[E0571]: `break` with value from a `while` loop --> $DIR/loop-break-value.rs:49:13 | +LL | 'while_let_loop: while let Some(_) = Some(()) { + | --------------------------------------------- you can't `break` with a value in a `while` loop +LL | loop { LL | break 'while_let_loop "nope"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block | -help: instead, use `break` on its own without a value inside this `while` loop +help: use `break` on its own without a value inside this `while` loop | -LL | break; - | ^^^^^ +LL | break 'while_let_loop; + | ^^^^^^^^^^^^^^^^^^^^^ error[E0571]: `break` with value from a `for` loop --> $DIR/loop-break-value.rs:56:9 | +LL | for _ in &[1,2,3] { + | ----------------- you can't `break` with a value in a `for` loop LL | break (); | ^^^^^^^^ can only break with a value inside `loop` or breakable block | -help: instead, use `break` on its own without a value inside this `for` loop +help: use `break` on its own without a value inside this `for` loop | LL | break; | ^^^^^ @@ -84,10 +105,13 @@ LL | break; error[E0571]: `break` with value from a `for` loop --> $DIR/loop-break-value.rs:57:9 | +LL | for _ in &[1,2,3] { + | ----------------- you can't `break` with a value in a `for` loop +LL | break (); LL | break [()]; | ^^^^^^^^^^ can only break with a value inside `loop` or breakable block | -help: instead, use `break` on its own without a value inside this `for` loop +help: use `break` on its own without a value inside this `for` loop | LL | break; | ^^^^^ @@ -95,24 +119,16 @@ LL | break; error[E0571]: `break` with value from a `for` loop --> $DIR/loop-break-value.rs:64:13 | +LL | 'for_loop: for _ in &[1,2,3] { + | ---------------------------- you can't `break` with a value in a `for` loop +... LL | break 'for_loop Some(17); | ^^^^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block | -help: instead, use `break` on its own without a value inside this `for` loop - | -LL | break; - | ^^^^^ - -error[E0571]: `break` with value from a `for` loop - --> $DIR/loop-break-value.rs:95:9 - | -LL | break LOOP; - | ^^^^^^^^^^ can only break with a value inside `loop` or breakable block +help: use `break` on its own without a value inside this `for` loop | -help: instead, use `break` on its own without a value inside this `for` loop - | -LL | break; - | ^^^^^ +LL | break 'for_loop; + | ^^^^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/loop-break-value.rs:4:31 @@ -171,7 +187,7 @@ LL | break; | expected integer, found `()` | help: give it a value of the expected type: `break value` -error: aborting due to 18 previous errors; 1 warning emitted +error: aborting due to 17 previous errors; 1 warning emitted Some errors have detailed explanations: E0308, E0425, E0571. For more information about an error, try `rustc --explain E0308`. |
