-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
typeck: silence unreachable code from await
This commit silences the unreachable code lint when it originates from within a await desugaring. Signed-off-by: David Wood <[email protected]>
- Loading branch information
Showing
4 changed files
with
43 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// edition:2018 | ||
#![deny(unreachable_code)] | ||
|
||
async fn foo() { | ||
return; bar().await; | ||
//~^ ERROR unreachable statement | ||
} | ||
|
||
async fn bar() { | ||
} | ||
|
||
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,16 @@ | ||
error: unreachable statement | ||
--> $DIR/unreachable-lint-1.rs:5:13 | ||
| | ||
LL | return; bar().await; | ||
| ------ ^^^^^^^^^^^^ unreachable statement | ||
| | | ||
| any code following this expression is unreachable | ||
| | ||
note: lint level defined here | ||
--> $DIR/unreachable-lint-1.rs:2:9 | ||
| | ||
LL | #![deny(unreachable_code)] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
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,13 @@ | ||
// check-pass | ||
// edition:2018 | ||
#![deny(unreachable_code)] | ||
|
||
async fn foo() { | ||
endless().await; | ||
} | ||
|
||
async fn endless() -> ! { | ||
loop {} | ||
} | ||
|
||
fn main() { } |