-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly mark loop as diverging if it has no breaks
- Loading branch information
1 parent
595316b
commit 74754b8
Showing
4 changed files
with
67 additions
and
21 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,15 @@ | ||
//@ edition:2018 | ||
|
||
#![deny(unreachable_code)] | ||
|
||
async fn foo() { | ||
endless().await; | ||
println!("this is unreachable!"); | ||
//~^ ERROR unreachable statement | ||
} | ||
|
||
async fn endless() -> ! { | ||
loop {} | ||
} | ||
|
||
fn main() { } |
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,17 @@ | ||
error: unreachable statement | ||
--> $DIR/unreachable-lint-2.rs:7:5 | ||
| | ||
LL | endless().await; | ||
| ----- any code following this expression is unreachable | ||
LL | println!("this is unreachable!"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/unreachable-lint-2.rs:3:9 | ||
| | ||
LL | #![deny(unreachable_code)] | ||
| ^^^^^^^^^^^^^^^^ | ||
= note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 1 previous error | ||
|