forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#84516 - torhovland:issue-84114, r=estebank
Add suggestion to "use break" when attempting to implicit-break a loop Fixes rust-lang#84114
- Loading branch information
Showing
4 changed files
with
121 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
fn main() { | ||
let a: i8 = loop { | ||
1 //~ ERROR mismatched types | ||
}; | ||
|
||
let b: i8 = loop { | ||
break 1; | ||
}; | ||
} | ||
|
||
fn foo() -> i8 { | ||
let a: i8 = loop { | ||
1 //~ ERROR mismatched types | ||
}; | ||
|
||
let b: i8 = loop { | ||
break 1; | ||
}; | ||
|
||
loop { | ||
1 //~ ERROR mismatched types | ||
} | ||
|
||
loop { | ||
return 1; | ||
} | ||
|
||
loop { | ||
1 //~ ERROR mismatched types | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/loop-no-implicit-break.rs:3:9 | ||
| | ||
LL | 1 | ||
| ^ expected `()`, found integer | ||
| | ||
help: you might have meant to break the loop with this value | ||
| | ||
LL | break 1; | ||
| ^^^^^ ^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/loop-no-implicit-break.rs:13:9 | ||
| | ||
LL | 1 | ||
| ^ expected `()`, found integer | ||
| | ||
help: you might have meant to break the loop with this value | ||
| | ||
LL | break 1; | ||
| ^^^^^ ^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/loop-no-implicit-break.rs:21:9 | ||
| | ||
LL | 1 | ||
| ^ expected `()`, found integer | ||
| | ||
help: you might have meant to return this value | ||
| | ||
LL | return 1; | ||
| ^^^^^^ ^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/loop-no-implicit-break.rs:29:9 | ||
| | ||
LL | 1 | ||
| ^ expected `()`, found integer | ||
| | ||
help: you might have meant to return this value | ||
| | ||
LL | return 1; | ||
| ^^^^^^ ^ | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |