diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-08-09 18:24:56 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-09 18:24:56 +0200 |
| commit | 55329cce76bfca7ca8cb007a5f520e479b782709 (patch) | |
| tree | 3032e611d26c9de869b15a0aa713f162625b37d3 /compiler/rustc_data_structures/src | |
| parent | 899eb03926be23f2e5d2ffcaa1d6f9ac40af7f13 (diff) | |
| parent | c966370b1959707be06dd2cbfb1436233fa595a3 (diff) | |
| download | rust-55329cce76bfca7ca8cb007a5f520e479b782709.tar.gz rust-55329cce76bfca7ca8cb007a5f520e479b782709.zip | |
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.
Diffstat (limited to 'compiler/rustc_data_structures/src')
| -rw-r--r-- | compiler/rustc_data_structures/src/steal.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/steal.rs b/compiler/rustc_data_structures/src/steal.rs index 9a0fd52677d..0f2c0eee27d 100644 --- a/compiler/rustc_data_structures/src/steal.rs +++ b/compiler/rustc_data_structures/src/steal.rs @@ -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> { |
