Skip to content

Commit

Permalink
Rollup merge of rust-lang#128815 - Nadrieril:is_stolen, r=jieyouxu,lcnr
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matthiaskrgr authored Aug 9, 2024
2 parents 899eb03 + c966370 commit 40db4e7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions compiler/rustc_data_structures/src/steal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit 40db4e7

Please sign in to comment.