diff options
| author | Ralf Jung <post@ralfj.de> | 2018-11-28 09:22:02 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2018-12-03 13:02:02 +0100 |
| commit | 005df5fe03ba2f9cdb7ed58d7cfb2c194184cc28 (patch) | |
| tree | 6c2e4b857f7397c4d6c20fd1909c1839b8c16c52 /src/librustc | |
| parent | d2c19e0bcc2c11e83187dcfc48f9fa110ecf2318 (diff) | |
| download | rust-005df5fe03ba2f9cdb7ed58d7cfb2c194184cc28.tar.gz rust-005df5fe03ba2f9cdb7ed58d7cfb2c194184cc28.zip | |
provide a way to replace the tag in a Scalar/MemPlace
Diffstat (limited to 'src/librustc')
| -rw-r--r-- | src/librustc/mir/interpret/value.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index 4bcba9d5467..500bd47dfbe 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -139,6 +139,14 @@ impl<'tcx, Tag> Scalar<Tag> { } #[inline] + pub fn with_tag(self, new_tag: Tag) -> Self { + match self { + Scalar::Ptr(ptr) => Scalar::Ptr(Pointer { tag: new_tag, ..ptr }), + Scalar::Bits { bits, size } => Scalar::Bits { bits, size }, + } + } + + #[inline] pub fn ptr_null(cx: &impl HasDataLayout) -> Self { Scalar::Bits { bits: 0, |
