Rollup merge of #72775 - JohnTitor:await-sugg, r=estebank

Return early to avoid ICE

Fixes #72766
This commit is contained in:
Yuki Okushi 2020-06-02 13:07:12 +09:00 committed by GitHub
commit 8a68fc6ff4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 7 deletions

View file

@ -0,0 +1,20 @@
// edition:2018
// compile-flags: -Cincremental=tmp/issue-72766
pub struct SadGirl;
impl SadGirl {
pub async fn call(&self) -> Result<(), ()> {
Ok(())
}
}
async fn async_main() -> Result<(), ()> {
// should be `.call().await?`
SadGirl {}.call()?; //~ ERROR: the `?` operator can only be applied to values
Ok(())
}
fn main() {
let _ = async_main();
}

View file

@ -0,0 +1,15 @@
error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
--> $DIR/issue-72766.rs:14:5
|
LL | SadGirl {}.call()?;
| ^^^^^^^^^^^^^^^^^^
| |
| the `?` operator cannot be applied to type `impl std::future::Future`
| help: consider using `.await` here: `SadGirl {}.call().await?`
|
= help: the trait `std::ops::Try` is not implemented for `impl std::future::Future`
= note: required by `std::ops::Try::into_result`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.