-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Open
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-coercionsArea: implicit and explicit `expr as Type` coercionsArea: implicit and explicit `expr as Type` coercionsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I tried this code:
fn consume_reference<T: ?Sized>(_: &T) {}
async fn foo() {
consume_reference::<i32>(&Box::new(7_i32)); // OK.
consume_reference::<i32>(&async { Box::new(7_i32) }.await); // Error.
consume_reference::<[i32]>(&vec![7_i32]); // OK.
consume_reference::<[i32]>(&async { vec![7_i32] }.await); // OK.
}I expected to see this happen: The code compiles.
Instead, this happened: This line does not compile while the others lines do:
consume_reference::<i32>(&async { Box::new(7_i32) }.await);The same thing also happened to awaiting futures::lock::Mutex::lock function:
fn consume_reference(_: &mut i32) {}
async fn foo() {
let mutex = futures::lock::Mutex::new(7_i32);
consume_reference(&mut mutex.lock().await);
}Meta
rustc --version --verbose:
rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-pc-windows-msvc
release: 1.51.0
LLVM version: 11.0.1
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-coercionsArea: implicit and explicit `expr as Type` coercionsArea: implicit and explicit `expr as Type` coercionsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Status
On deck