Rollup merge of #139502 - yaahc:still-mutable-ice, r=bjorn3

fix "still mutable" ice while metrics are enabled

Resolves "still mutable" ICE discovered by `@matthiaskrgr` here: [#t-docs-rs > metrics intitiative @ 💬](510490790)

This was caused by invoking `crate_hash` before the `definitions` struct was frozen here: e643f59f6d/compiler/rustc_interface/src/passes.rs (L951)

resolved by moving metrics dumping to occur after `analysis` freezes the definitions

I'm guessing we didn't discover this in CI because the problem only occurs when you try to calculate the crash hash with incremental compilation enabled when it tries to freeze the definitions here: e643f59f6d/compiler/rustc_middle/src/hir/map.rs (L1172)

my understanding is that this causes us to freeze the definitions too early in compilation, then we subsequently try to mutate them, likely during `analysis`, and this causes the ICE.

r? `@bjorn3`
This commit is contained in:
Matthias Krüger 2025-04-10 17:27:13 +02:00 committed by GitHub
commit 0e9c4fbf23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 120 additions and 5 deletions

View file

@ -88,7 +88,7 @@ impl<T> FreezeLock<T> {
#[inline]
#[track_caller]
pub fn write(&self) -> FreezeWriteGuard<'_, T> {
self.try_write().expect("still mutable")
self.try_write().expect("data should not be frozen if we're still attempting to mutate it")
}
#[inline]