-
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.
Rollup merge of #108901 - LYF1999:yf/108897, r=lcnr
fix: evaluate with wrong obligation stack fix #108897 r? `@lcnr`
- Loading branch information
Showing
3 changed files
with
47 additions
and
2 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,21 @@ | ||
// edition:2021 | ||
|
||
// issue 108897 | ||
trait Handler {} | ||
impl<F, Fut> Handler for F | ||
where | ||
Fut: Send, | ||
F: FnOnce() -> Fut, | ||
{} | ||
|
||
fn require_handler<H: Handler>(h: H) {} | ||
|
||
async fn handler() { | ||
let a = &1 as *const i32; | ||
async {}.await; | ||
} | ||
|
||
fn main() { | ||
require_handler(handler) | ||
//~^ ERROR future cannot be sent between threads safely | ||
} |
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,24 @@ | ||
error: future cannot be sent between threads safely | ||
--> $DIR/unsend-future.rs:19:21 | ||
| | ||
LL | require_handler(handler) | ||
| ^^^^^^^ future returned by `handler` is not `Send` | ||
| | ||
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `*const i32` | ||
note: future is not `Send` as this value is used across an await | ||
--> $DIR/unsend-future.rs:15:13 | ||
| | ||
LL | let a = &1 as *const i32; | ||
| - has type `*const i32` which is not `Send` | ||
LL | async {}.await; | ||
| ^^^^^^ await occurs here, with `a` maybe used later | ||
LL | } | ||
| - `a` is later dropped here | ||
note: required by a bound in `require_handler` | ||
--> $DIR/unsend-future.rs:11:23 | ||
| | ||
LL | fn require_handler<H: Handler>(h: H) {} | ||
| ^^^^^^^ required by this bound in `require_handler` | ||
|
||
error: aborting due to previous error | ||
|