dep/src/lib.rs
#![warn(long_running_const_eval)]
pub async fn has_const() {
const CONST: () = {
let mut i = 0;
while i < 10_000_000 {
i += 1;
}
};
CONST
}
src/lib.rs
#![warn(long_running_const_eval)]
pub async fn call() {
dep::has_const().await;
}
I expected rust to evaluate the const only once.
Instead, the long_running_const_eval fires when compiling the dep crate, 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:
rustc 1.93.0-nightly (d5419f1e9 2025-10-30)
binary: rustc
commit-hash: d5419f1e97b90741d51841f800d3c697c662567d
commit-date: 2025-10-30
host: x86_64-pc-windows-msvc
release: 1.93.0-nightly
LLVM version: 21.1.3
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: