-
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 #67289 - estebank:unnamed-closure, r=Centril
Do not ICE on unnamed future Fix #67252.
- Loading branch information
Showing
4 changed files
with
57 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// edition:2018 | ||
use std::future::Future; | ||
use std::pin::Pin; | ||
use std::task::{Context, Poll}; | ||
|
||
fn spawn<T: Send>(_: T) {} | ||
|
||
pub struct AFuture; | ||
impl Future for AFuture{ | ||
type Output = (); | ||
|
||
fn poll(mut self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<()> { | ||
unimplemented!() | ||
} | ||
} | ||
|
||
async fn foo() { | ||
spawn(async { //~ ERROR future cannot be sent between threads safely | ||
let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` | ||
AFuture.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,22 @@ | ||
error: future cannot be sent between threads safely | ||
--> $DIR/issue-67252-unnamed-future.rs:18:5 | ||
| | ||
LL | fn spawn<T: Send>(_: T) {} | ||
| ----- ---- required by this bound in `spawn` | ||
... | ||
LL | spawn(async { | ||
| ^^^^^ future is not `Send` | ||
| | ||
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `*mut ()` | ||
note: future is not `Send` as this value is used across an await | ||
--> $DIR/issue-67252-unnamed-future.rs:20:9 | ||
| | ||
LL | let _a = std::ptr::null_mut::<()>(); // `*mut ()` is not `Send` | ||
| -- has type `*mut ()` | ||
LL | AFuture.await; | ||
| ^^^^^^^^^^^^^ await occurs here, with `_a` maybe used later | ||
LL | }); | ||
| - `_a` is later dropped here | ||
|
||
error: aborting due to previous error | ||
|