diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2025-04-19 00:25:08 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2025-04-19 01:13:18 +0000 |
| commit | d0d3021bf830e585e6bb5df43eb4ae90a54ddf31 (patch) | |
| tree | b9ca38cbc06de250d60dae58fd547519ff679178 /compiler/rustc_mir_transform/src | |
| parent | 191df20fcad9331d3a948aa8e8556775ec3fe69d (diff) | |
| download | rust-d0d3021bf830e585e6bb5df43eb4ae90a54ddf31.tar.gz rust-d0d3021bf830e585e6bb5df43eb4ae90a54ddf31.zip | |
Introduce Arena::try_alloc_from_iter.
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/jump_threading.rs | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs index 8b4b214a3d4..54ac1262664 100644 --- a/compiler/rustc_mir_transform/src/jump_threading.rs +++ b/compiler/rustc_mir_transform/src/jump_threading.rs @@ -181,16 +181,8 @@ impl<'a> ConditionSet<'a> { arena: &'a DroplessArena, f: impl Fn(Condition) -> Option<Condition>, ) -> Option<ConditionSet<'a>> { - let mut all_ok = true; - let set = arena.alloc_from_iter(self.iter().map_while(|c| { - if let Some(c) = f(c) { - Some(c) - } else { - all_ok = false; - None - } - })); - all_ok.then_some(ConditionSet(set)) + let set = arena.try_alloc_from_iter(self.iter().map(|c| f(c).ok_or(()))).ok()?; + Some(ConditionSet(set)) } } |
