diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-06-22 07:03:59 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-22 07:03:59 +0900 |
| commit | e3ae9f5b20557ab8f03035198d76f87797932c2f (patch) | |
| tree | 5c13708d972661523c8903bc122d43555b44163a /compiler/rustc_middle/src/mir | |
| parent | fdeecb2314794934892dbb9334c3aad8bbbbfde2 (diff) | |
| parent | 1c1a60f0a3dc36f13ba0c642e9bb4a78e2142f74 (diff) | |
| download | rust-e3ae9f5b20557ab8f03035198d76f87797932c2f.tar.gz rust-e3ae9f5b20557ab8f03035198d76f87797932c2f.zip | |
Rollup merge of #98099 - RalfJung:convert_tag_add_extra, r=oli-obk
interpret: convert_tag_add_extra: allow tagger to raise errors Needed for https://github.com/rust-lang/miri/issues/2234 r? `@oli-obk`
Diffstat (limited to 'compiler/rustc_middle/src/mir')
| -rw-r--r-- | compiler/rustc_middle/src/mir/interpret/allocation.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/rustc_middle/src/mir/interpret/allocation.rs b/compiler/rustc_middle/src/mir/interpret/allocation.rs index 11a35109fde..10c4ea63a68 100644 --- a/compiler/rustc_middle/src/mir/interpret/allocation.rs +++ b/compiler/rustc_middle/src/mir/interpret/allocation.rs @@ -244,12 +244,12 @@ impl<Tag> Allocation<Tag> { impl Allocation { /// Convert Tag and add Extra fields - pub fn convert_tag_add_extra<Tag, Extra>( + pub fn convert_tag_add_extra<Tag, Extra, Err>( self, cx: &impl HasDataLayout, extra: Extra, - mut tagger: impl FnMut(Pointer<AllocId>) -> Pointer<Tag>, - ) -> Allocation<Tag, Extra> { + mut tagger: impl FnMut(Pointer<AllocId>) -> Result<Pointer<Tag>, Err>, + ) -> Result<Allocation<Tag, Extra>, Err> { // Compute new pointer tags, which also adjusts the bytes. let mut bytes = self.bytes; let mut new_relocations = Vec::with_capacity(self.relocations.0.len()); @@ -260,19 +260,19 @@ impl Allocation { let ptr_bytes = &mut bytes[idx..idx + ptr_size]; let bits = read_target_uint(endian, ptr_bytes).unwrap(); let (ptr_tag, ptr_offset) = - tagger(Pointer::new(alloc_id, Size::from_bytes(bits))).into_parts(); + tagger(Pointer::new(alloc_id, Size::from_bytes(bits)))?.into_parts(); write_target_uint(endian, ptr_bytes, ptr_offset.bytes().into()).unwrap(); new_relocations.push((offset, ptr_tag)); } // Create allocation. - Allocation { + Ok(Allocation { bytes, relocations: Relocations::from_presorted(new_relocations), init_mask: self.init_mask, align: self.align, mutability: self.mutability, extra, - } + }) } } |
