2023-09-25 16:57:22 -05:00
|
|
|
warning: label name `'a` shadows a label name that is already in scope
|
|
|
|
--> $DIR/loop-break-value.rs:136:17
|
|
|
|
|
|
|
|
|
LL | 'a: loop {
|
|
|
|
| -- first declared here
|
|
|
|
LL | break;
|
|
|
|
LL | let _ = 'a: loop {
|
|
|
|
| ^^ label `'a` already in scope
|
|
|
|
|
|
|
|
warning: label name `'a` shadows a label name that is already in scope
|
|
|
|
--> $DIR/loop-break-value.rs:148:17
|
|
|
|
|
|
|
|
|
LL | 'a: loop {
|
|
|
|
| -- first declared here
|
|
|
|
LL | break;
|
|
|
|
LL | let _ = 'a: loop {
|
|
|
|
| ^^ label `'a` already in scope
|
|
|
|
|
2020-12-14 06:14:17 -06:00
|
|
|
error[E0425]: cannot find value `LOOP` in this scope
|
|
|
|
--> $DIR/loop-break-value.rs:95:15
|
|
|
|
|
|
2021-01-19 19:51:48 -06:00
|
|
|
LL | 'LOOP: for _ in 0 .. 9 {
|
|
|
|
| ----- a label with a similar name exists
|
2020-12-14 06:14:17 -06:00
|
|
|
LL | break LOOP;
|
|
|
|
| ^^^^
|
|
|
|
| |
|
|
|
|
| not found in this scope
|
2021-01-19 19:51:48 -06:00
|
|
|
| help: use the similarly named label: `'LOOP`
|
2020-12-14 06:14:17 -06:00
|
|
|
|
2019-06-21 18:30:24 -05:00
|
|
|
warning: denote infinite loops with `loop { ... }`
|
2019-12-11 08:51:28 -06:00
|
|
|
--> $DIR/loop-break-value.rs:26:5
|
2019-06-21 18:30:24 -05:00
|
|
|
|
|
|
|
|
LL | 'while_loop: while true {
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use `loop`
|
|
|
|
|
|
2019-07-16 15:17:38 -05:00
|
|
|
= note: `#[warn(while_true)]` on by default
|
2019-06-21 18:30:24 -05:00
|
|
|
|
2018-08-08 07:28:26 -05:00
|
|
|
error[E0571]: `break` with value from a `while` loop
|
2019-12-11 08:51:28 -06:00
|
|
|
--> $DIR/loop-break-value.rs:28:9
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
LL | 'while_loop: while true {
|
|
|
|
| ----------------------- you can't `break` with a value in a `while` loop
|
|
|
|
LL | break;
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | break ();
|
2018-08-08 07:28:26 -05:00
|
|
|
| ^^^^^^^^ can only break with a value inside `loop` or breakable block
|
2019-10-24 00:20:58 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
help: use `break` on its own without a value inside this `while` loop
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | break;
|
2021-06-21 21:07:19 -05:00
|
|
|
| ~~~~~
|
2021-01-20 19:25:27 -06:00
|
|
|
help: alternatively, you might have meant to use the available loop label
|
|
|
|
|
|
|
|
|
LL | break 'while_loop;
|
2021-06-21 21:07:19 -05:00
|
|
|
| ~~~~~~~~~~~
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0571]: `break` with value from a `while` loop
|
2019-12-11 08:51:28 -06:00
|
|
|
--> $DIR/loop-break-value.rs:30:13
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
LL | 'while_loop: while true {
|
|
|
|
| ----------------------- you can't `break` with a value in a `while` loop
|
|
|
|
...
|
2018-08-08 07:28:26 -05:00
|
|
|
LL | break 'while_loop 123;
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block
|
2019-10-24 00:20:58 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
help: use `break` on its own without a value inside this `while` loop
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2021-01-21 20:13:05 -06:00
|
|
|
LL | break 'while_loop;
|
2021-06-21 21:07:19 -05:00
|
|
|
| ~~~~~~~~~~~~~~~~~
|
2018-08-08 07:28:26 -05:00
|
|
|
|
2019-11-17 23:11:42 -06:00
|
|
|
error[E0571]: `break` with value from a `while` loop
|
2019-12-11 10:46:56 -06:00
|
|
|
--> $DIR/loop-break-value.rs:38:12
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
LL | while let Some(_) = Some(()) {
|
|
|
|
| ---------------------------- you can't `break` with a value in a `while` loop
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | if break () {
|
2018-08-08 07:28:26 -05:00
|
|
|
| ^^^^^^^^ can only break with a value inside `loop` or breakable block
|
2019-10-24 00:20:58 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
help: use `break` on its own without a value inside this `while` loop
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | if break {
|
2021-06-21 21:07:19 -05:00
|
|
|
| ~~~~~
|
2018-08-08 07:28:26 -05:00
|
|
|
|
2019-11-17 23:11:42 -06:00
|
|
|
error[E0571]: `break` with value from a `while` loop
|
2019-12-11 10:46:56 -06:00
|
|
|
--> $DIR/loop-break-value.rs:43:9
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
LL | while let Some(_) = Some(()) {
|
|
|
|
| ---------------------------- you can't `break` with a value in a `while` loop
|
2018-08-08 07:28:26 -05:00
|
|
|
LL | break None;
|
|
|
|
| ^^^^^^^^^^ can only break with a value inside `loop` or breakable block
|
2019-10-24 00:20:58 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
help: use `break` on its own without a value inside this `while` loop
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
|
LL | break;
|
2021-06-21 21:07:19 -05:00
|
|
|
| ~~~~~
|
2018-08-08 07:28:26 -05:00
|
|
|
|
2019-11-17 23:11:42 -06:00
|
|
|
error[E0571]: `break` with value from a `while` loop
|
2019-12-11 10:46:56 -06:00
|
|
|
--> $DIR/loop-break-value.rs:49:13
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
LL | 'while_let_loop: while let Some(_) = Some(()) {
|
|
|
|
| --------------------------------------------- you can't `break` with a value in a `while` loop
|
|
|
|
LL | loop {
|
2018-08-08 07:28:26 -05:00
|
|
|
LL | break 'while_let_loop "nope";
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block
|
2019-10-24 00:20:58 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
help: use `break` on its own without a value inside this `while` loop
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2021-01-21 20:13:05 -06:00
|
|
|
LL | break 'while_let_loop;
|
2021-06-21 21:07:19 -05:00
|
|
|
| ~~~~~~~~~~~~~~~~~~~~~
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0571]: `break` with value from a `for` loop
|
2019-12-11 08:51:28 -06:00
|
|
|
--> $DIR/loop-break-value.rs:56:9
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
LL | for _ in &[1,2,3] {
|
|
|
|
| ----------------- you can't `break` with a value in a `for` loop
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | break ();
|
2018-08-08 07:28:26 -05:00
|
|
|
| ^^^^^^^^ can only break with a value inside `loop` or breakable block
|
2019-10-24 00:20:58 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
help: use `break` on its own without a value inside this `for` loop
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | break;
|
2021-06-21 21:07:19 -05:00
|
|
|
| ~~~~~
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0571]: `break` with value from a `for` loop
|
2019-12-11 08:51:28 -06:00
|
|
|
--> $DIR/loop-break-value.rs:57:9
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
LL | for _ in &[1,2,3] {
|
|
|
|
| ----------------- you can't `break` with a value in a `for` loop
|
|
|
|
LL | break ();
|
2018-08-08 07:28:26 -05:00
|
|
|
LL | break [()];
|
|
|
|
| ^^^^^^^^^^ can only break with a value inside `loop` or breakable block
|
2019-10-24 00:20:58 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
help: use `break` on its own without a value inside this `for` loop
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
|
LL | break;
|
2021-06-21 21:07:19 -05:00
|
|
|
| ~~~~~
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0571]: `break` with value from a `for` loop
|
2019-12-11 08:51:28 -06:00
|
|
|
--> $DIR/loop-break-value.rs:64:13
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
LL | 'for_loop: for _ in &[1,2,3] {
|
|
|
|
| ---------------------------- you can't `break` with a value in a `for` loop
|
|
|
|
...
|
2018-08-08 07:28:26 -05:00
|
|
|
LL | break 'for_loop Some(17);
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^ can only break with a value inside `loop` or breakable block
|
2019-10-24 00:20:58 -05:00
|
|
|
|
|
2021-01-20 19:25:27 -06:00
|
|
|
help: use `break` on its own without a value inside this `for` loop
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2021-01-21 20:13:05 -06:00
|
|
|
LL | break 'for_loop;
|
2021-06-21 21:07:19 -05:00
|
|
|
| ~~~~~~~~~~~~~~~
|
2020-12-14 06:14:17 -06:00
|
|
|
|
2018-08-08 07:28:26 -05:00
|
|
|
error[E0308]: mismatched types
|
2019-12-11 08:51:28 -06:00
|
|
|
--> $DIR/loop-break-value.rs:4:31
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
|
LL | let val: ! = loop { break break; };
|
2023-09-22 17:20:00 -05:00
|
|
|
| --- ---- ^^^^^ expected `!`, found `()`
|
|
|
|
| | |
|
|
|
|
| | this loop is expected to be of type `!`
|
|
|
|
| expected because of this assignment
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2019-11-14 16:08:08 -06:00
|
|
|
= note: expected type `!`
|
|
|
|
found unit type `()`
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2019-12-11 08:51:28 -06:00
|
|
|
--> $DIR/loop-break-value.rs:11:19
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2023-09-22 17:17:12 -05:00
|
|
|
LL | break "asdf";
|
|
|
|
| ------------ expected because of this `break`
|
|
|
|
LL | } else {
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | break 123;
|
2019-11-15 11:37:01 -06:00
|
|
|
| ^^^ expected `&str`, found integer
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2019-12-11 08:51:28 -06:00
|
|
|
--> $DIR/loop-break-value.rs:16:15
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2023-09-22 13:42:22 -05:00
|
|
|
LL | let _: i32 = loop {
|
|
|
|
| - ---- this loop is expected to be of type `i32`
|
|
|
|
| |
|
|
|
|
| expected because of this assignment
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | break "asdf";
|
2019-11-15 11:37:01 -06:00
|
|
|
| ^^^^^^ expected `i32`, found `&str`
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2019-12-11 08:51:28 -06:00
|
|
|
--> $DIR/loop-break-value.rs:21:31
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2023-09-25 16:57:22 -05:00
|
|
|
LL | let _: i32 = 'outer_loop: loop {
|
|
|
|
| - ---- this loop is expected to be of type `i32`
|
|
|
|
| |
|
|
|
|
| expected because of this assignment
|
|
|
|
LL | loop {
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | break 'outer_loop "nope";
|
2019-11-15 11:37:01 -06:00
|
|
|
| ^^^^^^ expected `i32`, found `&str`
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2019-12-11 08:51:28 -06:00
|
|
|
--> $DIR/loop-break-value.rs:73:26
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2023-09-25 16:57:22 -05:00
|
|
|
LL | break;
|
|
|
|
| ----- expected because of this `break`
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | break 'c 123;
|
2019-11-15 11:37:01 -06:00
|
|
|
| ^^^ expected `()`, found integer
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2019-12-11 08:51:28 -06:00
|
|
|
--> $DIR/loop-break-value.rs:80:15
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | break (break, break);
|
2023-09-22 17:17:12 -05:00
|
|
|
| ^-----^^-----^
|
|
|
|
| || |
|
|
|
|
| || expected because of this `break`
|
|
|
|
| |expected because of this `break`
|
|
|
|
| expected `()`, found `(!, !)`
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2019-11-14 16:08:08 -06:00
|
|
|
= note: expected unit type `()`
|
|
|
|
found tuple `(!, !)`
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2019-12-11 08:51:28 -06:00
|
|
|
--> $DIR/loop-break-value.rs:85:15
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2023-09-22 17:17:12 -05:00
|
|
|
LL | break;
|
|
|
|
| ----- expected because of this `break`
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | break 2;
|
2019-11-15 11:37:01 -06:00
|
|
|
| ^ expected `()`, found integer
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2019-12-11 08:51:28 -06:00
|
|
|
--> $DIR/loop-break-value.rs:90:9
|
2018-08-08 07:28:26 -05:00
|
|
|
|
|
2023-09-25 13:21:52 -05:00
|
|
|
LL | break 2;
|
|
|
|
| ------- expected because of this `break`
|
2019-03-09 06:03:44 -06:00
|
|
|
LL | break;
|
2023-09-25 17:10:08 -05:00
|
|
|
| ^^^^^ expected integer, found `()`
|
|
|
|
|
|
|
|
|
help: give it a value of the expected type
|
|
|
|
|
|
|
|
|
LL | break value;
|
|
|
|
| +++++
|
2018-08-08 07:28:26 -05:00
|
|
|
|
2023-09-22 13:42:22 -05:00
|
|
|
error[E0308]: mismatched types
|
2023-09-25 13:21:52 -05:00
|
|
|
--> $DIR/loop-break-value.rs:108:9
|
|
|
|
|
|
|
|
|
LL | break 'a 1;
|
|
|
|
| ---------- expected because of this `break`
|
|
|
|
...
|
|
|
|
LL | break;
|
2023-09-25 17:10:08 -05:00
|
|
|
| ^^^^^ expected integer, found `()`
|
|
|
|
|
|
|
|
|
help: give it a value of the expected type
|
|
|
|
|
|
|
|
|
LL | break value;
|
|
|
|
| +++++
|
2023-09-25 13:21:52 -05:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2023-09-25 16:57:22 -05:00
|
|
|
--> $DIR/loop-break-value.rs:120:9
|
2023-09-25 13:21:52 -05:00
|
|
|
|
|
|
|
|
LL | break 'a 1;
|
|
|
|
| ---------- expected because of this `break`
|
|
|
|
...
|
|
|
|
LL | break 'a;
|
2023-09-25 17:10:08 -05:00
|
|
|
| ^^^^^^^^ expected integer, found `()`
|
|
|
|
|
|
|
|
|
help: give it a value of the expected type
|
|
|
|
|
|
|
|
|
LL | break 'a value;
|
|
|
|
| +++++
|
2023-09-25 13:21:52 -05:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
2023-09-25 16:57:22 -05:00
|
|
|
--> $DIR/loop-break-value.rs:131:15
|
|
|
|
|
|
|
|
|
LL | break;
|
|
|
|
| ----- expected because of this `break`
|
|
|
|
...
|
|
|
|
LL | break 2;
|
|
|
|
| ^ expected `()`, found integer
|
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
|
|
|
--> $DIR/loop-break-value.rs:140:17
|
|
|
|
|
|
|
|
|
LL | break 2;
|
|
|
|
| ------- expected because of this `break`
|
|
|
|
LL | loop {
|
|
|
|
LL | break 'a;
|
2023-09-25 17:10:08 -05:00
|
|
|
| ^^^^^^^^ expected integer, found `()`
|
|
|
|
|
|
|
|
|
help: give it a value of the expected type
|
|
|
|
|
|
|
|
|
LL | break 'a value;
|
|
|
|
| +++++
|
2023-09-25 16:57:22 -05:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
|
|
|
--> $DIR/loop-break-value.rs:143:15
|
|
|
|
|
|
|
|
|
LL | break;
|
|
|
|
| ----- expected because of this `break`
|
|
|
|
...
|
|
|
|
LL | break 2;
|
|
|
|
| ^ expected `()`, found integer
|
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
|
|
|
--> $DIR/loop-break-value.rs:152:17
|
|
|
|
|
|
|
|
|
LL | break 'a 2;
|
|
|
|
| ---------- expected because of this `break`
|
|
|
|
LL | loop {
|
|
|
|
LL | break 'a;
|
2023-09-25 17:10:08 -05:00
|
|
|
| ^^^^^^^^ expected integer, found `()`
|
|
|
|
|
|
|
|
|
help: give it a value of the expected type
|
|
|
|
|
|
|
|
|
LL | break 'a value;
|
|
|
|
| +++++
|
2023-09-25 16:57:22 -05:00
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
|
|
|
--> $DIR/loop-break-value.rs:155:15
|
|
|
|
|
|
|
|
|
LL | break;
|
|
|
|
| ----- expected because of this `break`
|
|
|
|
...
|
|
|
|
LL | break 2;
|
|
|
|
| ^ expected `()`, found integer
|
|
|
|
|
|
|
|
error[E0308]: mismatched types
|
|
|
|
--> $DIR/loop-break-value.rs:159:15
|
2023-09-22 13:42:22 -05:00
|
|
|
|
|
|
|
|
LL | fn main() {
|
2023-09-30 14:29:41 -05:00
|
|
|
| - expected `()` because of this return type
|
2023-09-22 13:42:22 -05:00
|
|
|
...
|
|
|
|
LL | loop { // point at the return type
|
|
|
|
| ---- this loop is expected to be of type `()`
|
|
|
|
LL | break 2;
|
|
|
|
| ^ expected `()`, found integer
|
|
|
|
|
2023-09-25 16:57:22 -05:00
|
|
|
error: aborting due to 25 previous errors; 3 warnings emitted
|
2018-08-08 07:28:26 -05:00
|
|
|
|
2020-12-14 06:14:17 -06:00
|
|
|
Some errors have detailed explanations: E0308, E0425, E0571.
|
2018-08-08 07:28:26 -05:00
|
|
|
For more information about an error, try `rustc --explain E0308`.
|