diff options
| author | bors <bors@rust-lang.org> | 2024-08-12 08:25:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-08-12 08:25:26 +0000 |
| commit | a25ec22901e387d076eac487608a172d3b37390e (patch) | |
| tree | f05489e27b891f15338149d09cd053f1eecc08a1 /compiler/rustc_data_structures/src | |
| parent | 3456432db1cb33322702b8a2585d5ffe13c4fd43 (diff) | |
| parent | 14f9284ebecc4d7a6e68bf782720563a5e317888 (diff) | |
| download | rust-a25ec22901e387d076eac487608a172d3b37390e.tar.gz rust-a25ec22901e387d076eac487608a172d3b37390e.zip | |
Auto merge of #3801 - RalfJung:rustup, r=RalfJung
Rustup
Diffstat (limited to 'compiler/rustc_data_structures/src')
| -rw-r--r-- | compiler/rustc_data_structures/src/steal.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_data_structures/src/transitive_relation.rs | 6 |
2 files changed, 12 insertions, 3 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> { diff --git a/compiler/rustc_data_structures/src/transitive_relation.rs b/compiler/rustc_data_structures/src/transitive_relation.rs index 26b00e0af3a..e81ebb9a4be 100644 --- a/compiler/rustc_data_structures/src/transitive_relation.rs +++ b/compiler/rustc_data_structures/src/transitive_relation.rs @@ -203,9 +203,9 @@ impl<T: Eq + Hash + Copy> TransitiveRelation<T> { /// exists). See `postdom_upper_bound` for details. pub fn mutual_immediate_postdominator(&self, mut mubs: Vec<T>) -> Option<T> { loop { - match mubs.len() { - 0 => return None, - 1 => return Some(mubs[0]), + match mubs[..] { + [] => return None, + [mub] => return Some(mub), _ => { let m = mubs.pop().unwrap(); let n = mubs.pop().unwrap(); |
