-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Open
Labels
A-async-closures`async || {}``async || {}`A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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:
use std::cell::RefCell;
thread_local! {
static REQUESTS_CHECKER: RefCell<()> = RefCell::new(());
}
async fn a() {}
async fn b() {
REQUESTS_CHECKER.with_borrow_mut(async |c|
a().await
).await
}
fn main() {}
I expected to see this happen: the code to compile.
Instead, this happened:
mismatched types
expected `async` closure body `{async closure body@canister/src/lib.rs:27:9: 35:16}`
found `async` closure body `{async closure body@canister/src/lib.rs:27:9: 35:16}`
no two async blocks, even if identical, have the same type
consider pinning your async block and casting it to a trait object
This is not two async blocks, it is one.
Meta
rustc --version --verbose
:
rustc 1.90.0 (1159e78c4 2025-09-14)
Backtrace
<backtrace>
Real code: this.
Metadata
Metadata
Assignees
Labels
A-async-closures`async || {}``async || {}`A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.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.