-
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.
Rollup merge of #97721 - compiler-errors:issue-97704, r=jackh726
Do `suggest_await_before_try` with infer variables in self, and clean up binders Fixes #97704 Also cleans up binders in this fn, since everything is a `Poly*` and we really shouldn't have stray escaping late-bound regions everywhere. That's why the function changed so much. This isn't necessary, so I can revert if necessary.
- Loading branch information
Showing
4 changed files
with
71 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// edition:2021 | ||
// run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
use std::future::Future; | ||
|
||
async fn foo() -> Result<(), i32> { | ||
func(async { Ok::<_, i32>(()) }).await?; | ||
//~^ ERROR the `?` operator can only be applied to values that implement `Try` | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn func<T>(fut: impl Future<Output = T>) -> T { | ||
fut.await | ||
} | ||
|
||
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,19 @@ | ||
// edition:2021 | ||
// run-rustfix | ||
|
||
#![allow(unused)] | ||
|
||
use std::future::Future; | ||
|
||
async fn foo() -> Result<(), i32> { | ||
func(async { Ok::<_, i32>(()) })?; | ||
//~^ ERROR the `?` operator can only be applied to values that implement `Try` | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn func<T>(fut: impl Future<Output = T>) -> T { | ||
fut.await | ||
} | ||
|
||
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,15 @@ | ||
error[E0277]: the `?` operator can only be applied to values that implement `Try` | ||
--> $DIR/issue-97704.rs:9:5 | ||
| | ||
LL | func(async { Ok::<_, i32>(()) })?; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `?` operator cannot be applied to type `impl Future<Output = Result<(), i32>>` | ||
| | ||
= help: the trait `Try` is not implemented for `impl Future<Output = Result<(), i32>>` | ||
help: consider `await`ing on the `Future` | ||
| | ||
LL | func(async { Ok::<_, i32>(()) }).await?; | ||
| ++++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |