Rollup merge of #128815 - Nadrieril:is_stolen, r=jieyouxu,lcnr

Add `Steal::is_stolen()`

Writers of rustc drivers (such as myself) often encounter stealing issues. It is currently impossible to gracefully handle them. This PR adds a `Steal::is_stolen()` function for that purpose.
This commit is contained in:
Matthias Krüger 2024-08-09 18:24:56 +02:00 committed by GitHub
commit 55329cce76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -51,6 +51,15 @@ impl<T> Steal<T> {
let value = value_ref.take();
value.expect("attempt to steal from stolen value")
}
/// Writers of rustc drivers often encounter stealing issues. This function makes it possible to
/// handle these errors gracefully.
///
/// This should not be used within rustc as it leaks information not tracked
/// by the query system, breaking incremental compilation.
pub fn is_stolen(&self) -> bool {
self.value.borrow().is_none()
}
}
impl<CTX, T: HashStable<CTX>> HashStable<CTX> for Steal<T> {