-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it more clear when complaining about async fn's return types
- Loading branch information
Showing
12 changed files
with
331 additions
and
133 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
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,38 @@ | ||
// Test for for diagnostic improvement issue #76547 | ||
// edition:2018 | ||
|
||
use std::{ | ||
future::Future, | ||
task::{Context, Poll} | ||
}; | ||
use std::pin::Pin; | ||
|
||
pub struct ListFut<'a>(&'a mut [&'a mut [u8]]); | ||
impl<'a> Future for ListFut<'a> { | ||
type Output = (); | ||
|
||
fn poll(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Self::Output> { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
async fn fut(bufs: &mut [&mut [u8]]) { | ||
ListFut(bufs).await | ||
//~^ ERROR lifetime mismatch | ||
} | ||
|
||
pub struct ListFut2<'a>(&'a mut [&'a mut [u8]]); | ||
impl<'a> Future for ListFut2<'a> { | ||
type Output = i32; | ||
|
||
fn poll(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Self::Output> { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
async fn fut2(bufs: &mut [&mut [u8]]) -> i32 { | ||
ListFut2(bufs).await | ||
//~^ ERROR lifetime mismatch | ||
} | ||
|
||
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,25 @@ | ||
error[E0623]: lifetime mismatch | ||
--> $DIR/issue-76547.rs:20:13 | ||
| | ||
LL | async fn fut(bufs: &mut [&mut [u8]]) { | ||
| --------- - | ||
| | | | ||
| | this `async fn` implicitly returns an `impl Future<Output = ()>` | ||
| this parameter and the returned future are declared with different lifetimes... | ||
LL | ListFut(bufs).await | ||
| ^^^^ ...but data from `bufs` is held across an await point here | ||
|
||
error[E0623]: lifetime mismatch | ||
--> $DIR/issue-76547.rs:34:14 | ||
| | ||
LL | async fn fut2(bufs: &mut [&mut [u8]]) -> i32 { | ||
| --------- --- | ||
| | | | ||
| | this `async fn` implicitly returns an `impl Future<Output = i32>` | ||
| this parameter and the returned future are declared with different lifetimes... | ||
LL | ListFut2(bufs).await | ||
| ^^^^ ...but data from `bufs` is held across an await point here | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0623`. |
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
Oops, something went wrong.