Strict version hash is sensitive to presence of standard library source code on host
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I am reporting a likely unintended side effect of https://github.com/rust-lang/rust/pull/142594 that should get compiler team scrutiny.
Since Rust 1.89.0 or nightly-2025-06-23 (https://github.com/rust-lang/rust/pull/142594), compiling the same source code will produce a different output artifact depending on whether or not standard library sources are present during compilation.
For example, with this src/lib.rs file:
pub fn repro() {
unimplemented!("...")
}
$ rustup component remove rust-src --toolchain=nightly-2025-06-22
$ rustc +nightly-2025-06-22 src/lib.rs --crate-name=repro --crate-type=lib --edition=2024 --emit=metadata && rustc +nightly-2025-06-22 -Zls=root librepro.rmeta | rg '^hash'
hash f498d9b8b442661b3b48683256f3913a stable_crate_id StableCrateId(6398988076306807592)
$ rustup component add rust-src --toolchain=nightly-2025-06-22
$ rustc +nightly-2025-06-22 src/lib.rs --crate-name=repro --crate-type=lib --edition=2024 --emit=metadata && rustc +nightly-2025-06-22 -Zls=root librepro.rmeta | rg '^hash'
hash f498d9b8b442661b3b48683256f3913a stable_crate_id StableCrateId(6398988076306807592)
$ rustup component remove rust-src --toolchain=nightly-2025-06-23
$ rustc +nightly-2025-06-23 src/lib.rs --crate-name=repro --crate-type=lib --edition=2024 --emit=metadata && rustc +nightly-2025-06-23 -Zls=root librepro.rmeta | rg '^hash'
hash 1e9121fe4158816afef1f8c53f33dabd stable_crate_id StableCrateId(18041666587592679647)
$ rustup component add rust-src --toolchain=nightly-2025-06-23
$ rustc +nightly-2025-06-23 src/lib.rs --crate-name=repro --crate-type=lib --edition=2024 --emit=metadata && rustc +nightly-2025-06-23 -Zls=root librepro.rmeta | rg '^hash'
hash 3bfa9667f7c341fe78b80185c86717eb stable_crate_id StableCrateId(18041666587592679647)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with PR 142594 and reproduce the difference using the issue's src/lib.rs example and the nightly-2025-06-22/23 rustc commands. Compare the -Zls=root stable_crate_id output with and without the rust-src component. Done means the same source produces the same strict version hash regardless of standard library sources being present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100