-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
const in async fn is evaluated twice when used across crates. #148335
Copy link
Copy link
Open
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-monomorphizationArea: MonomorphizationArea: MonomorphizationC-bugCategory: This is a bug.Category: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.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.
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-monomorphizationArea: MonomorphizationArea: MonomorphizationC-bugCategory: This is a bug.Category: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.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
Fields
Give feedbackNo fields configured for issues without a type.
dep/src/lib.rs
src/lib.rs
I expected rust to evaluate the const only once.
Instead, the
long_running_const_evalfires when compiling thedepcrate, and also fires again when compiling the dependent crate. This means that the const is evaluated at least twice, wasting compilation time.(For some reason, it fired twice per crate, for a total of 4 times. I don't know why.)
This bug was discovered in #148328, and filed here as a separate issue.
Meta
rustc --version --verbose: