diff options
| author | bors <bors@rust-lang.org> | 2020-01-25 13:14:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-01-25 13:14:59 +0000 |
| commit | 3bf71b3d5c07afc0908881a0868080ed399ca6ca (patch) | |
| tree | d695fe0ee4f3e4d80b2c7b287d5f0546781cdecb | |
| parent | 80a65bcaf2f2b8a5c659b21b32b42bc300338a0e (diff) | |
| parent | 9a2d5e87d69cf2583db5c6dffaf82d43004a35e0 (diff) | |
| download | rust-3bf71b3d5c07afc0908881a0868080ed399ca6ca.tar.gz rust-3bf71b3d5c07afc0908881a0868080ed399ca6ca.zip | |
Auto merge of #68516 - oli-obk:spaces, r=eddyb
Render const pointers in MIR more compactly Split out from #67133 to make that PR simpler cc @RalfJung r? @eddyb
| -rw-r--r-- | src/librustc/mir/interpret/mod.rs | 8 | ||||
| -rw-r--r-- | src/librustc/mir/interpret/pointer.rs | 4 | ||||
| -rw-r--r-- | src/test/mir-opt/const-promotion-extern-static.rs | 4 | ||||
| -rw-r--r-- | src/test/mir-opt/const_prop/read_immutable_static.rs | 4 |
4 files changed, 13 insertions, 7 deletions
diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index e554b280ef7..54e196f4b33 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -166,9 +166,15 @@ pub enum LitToConstError { Reported, } -#[derive(Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd, Debug)] +#[derive(Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct AllocId(pub u64); +impl fmt::Debug for AllocId { + fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(fmt, "alloc{}", self.0) + } +} + impl rustc_serialize::UseSpecializedEncodable for AllocId {} impl rustc_serialize::UseSpecializedDecodable for AllocId {} diff --git a/src/librustc/mir/interpret/pointer.rs b/src/librustc/mir/interpret/pointer.rs index 9b0399e22c5..a4974fb541b 100644 --- a/src/librustc/mir/interpret/pointer.rs +++ b/src/librustc/mir/interpret/pointer.rs @@ -133,13 +133,13 @@ static_assert_size!(Pointer, 16); impl<Tag: fmt::Debug, Id: fmt::Debug> fmt::Debug for Pointer<Tag, Id> { default fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:?}.{:#x}[{:?}]", self.alloc_id, self.offset.bytes(), self.tag) + write!(f, "{:?}+{:x}[{:?}]", self.alloc_id, self.offset.bytes(), self.tag) } } // Specialization for no tag impl<Id: fmt::Debug> fmt::Debug for Pointer<(), Id> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:?}.{:#x}", self.alloc_id, self.offset.bytes()) + write!(f, "{:?}+{:x}", self.alloc_id, self.offset.bytes()) } } diff --git a/src/test/mir-opt/const-promotion-extern-static.rs b/src/test/mir-opt/const-promotion-extern-static.rs index 3abc90e42e8..f6f7d091091 100644 --- a/src/test/mir-opt/const-promotion-extern-static.rs +++ b/src/test/mir-opt/const-promotion-extern-static.rs @@ -14,7 +14,7 @@ fn main() {} // START rustc.FOO.PromoteTemps.before.mir // bb0: { // ... -// _5 = const Scalar(AllocId(1).0x0) : &i32; +// _5 = const Scalar(alloc1+0) : &i32; // _4 = &(*_5); // _3 = [move _4]; // _2 = &_3; @@ -31,7 +31,7 @@ fn main() {} // START rustc.BAR.PromoteTemps.before.mir // bb0: { // ... -// _5 = const Scalar(AllocId(0).0x0) : &i32; +// _5 = const Scalar(alloc0+0) : &i32; // _4 = &(*_5); // _3 = [move _4]; // _2 = &_3; diff --git a/src/test/mir-opt/const_prop/read_immutable_static.rs b/src/test/mir-opt/const_prop/read_immutable_static.rs index d9e0eb623af..693ef783985 100644 --- a/src/test/mir-opt/const_prop/read_immutable_static.rs +++ b/src/test/mir-opt/const_prop/read_immutable_static.rs @@ -10,10 +10,10 @@ fn main() { // START rustc.main.ConstProp.before.mir // bb0: { // ... -// _3 = const Scalar(AllocId(0).0x0) : &u8; +// _3 = const Scalar(alloc0+0) : &u8; // _2 = (*_3); // ... -// _5 = const Scalar(AllocId(0).0x0) : &u8; +// _5 = const Scalar(alloc0+0) : &u8; // _4 = (*_5); // _1 = Add(move _2, move _4); // ... |
