consts in dead monomorphic async fn are never evaluated #140655
Labels
A-async-await
Area: Async & Await
A-const-eval
Area: Constant evaluation, covers all const contexts (static, const fn, ...)
C-bug
Category: This is a bug.
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
Split out from #140600
I tried this code:
I expected to see this happen: both functions raise a const eval error (or at least both functions don't)
Instead, this happened: sync function raises const eval error, but the same function with an
async
keyword doesn't.This is surprising from a perspective of a language user who is not familiar with intricacies of async internals. I didn't expect that making function async would "disable" const checks.
And even though i kinda sorta know some details of async desugaring, it is still surprising that the following "sorta desugared" code does fail to compile (unlike non-desugared version) (I realize that this desugaring is very far from perfect, I'm only dabbling)
Meta
rustc --version --verbose
:I'm not sure if this current behavior is a bug per se or if it's only just a mildly surprising behaviour, but thought it's still worth making an issue either way.
@rustbot label: +T-compiler +T-lang +A-async-await +A-const-eval
The text was updated successfully, but these errors were encountered: