Skip to content

Commit 3bf71b3

Browse files
committed
Auto merge of rust-lang#68516 - oli-obk:spaces, r=eddyb
Render const pointers in MIR more compactly Split out from rust-lang#67133 to make that PR simpler cc @RalfJung r? @eddyb
2 parents 80a65bc + 9a2d5e8 commit 3bf71b3

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

src/librustc/mir/interpret/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,15 @@ pub enum LitToConstError {
166166
Reported,
167167
}
168168

169-
#[derive(Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd, Debug)]
169+
#[derive(Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)]
170170
pub struct AllocId(pub u64);
171171

172+
impl fmt::Debug for AllocId {
173+
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
174+
write!(fmt, "alloc{}", self.0)
175+
}
176+
}
177+
172178
impl rustc_serialize::UseSpecializedEncodable for AllocId {}
173179
impl rustc_serialize::UseSpecializedDecodable for AllocId {}
174180

src/librustc/mir/interpret/pointer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ static_assert_size!(Pointer, 16);
133133

134134
impl<Tag: fmt::Debug, Id: fmt::Debug> fmt::Debug for Pointer<Tag, Id> {
135135
default fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
136-
write!(f, "{:?}.{:#x}[{:?}]", self.alloc_id, self.offset.bytes(), self.tag)
136+
write!(f, "{:?}+{:x}[{:?}]", self.alloc_id, self.offset.bytes(), self.tag)
137137
}
138138
}
139139
// Specialization for no tag
140140
impl<Id: fmt::Debug> fmt::Debug for Pointer<(), Id> {
141141
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
142-
write!(f, "{:?}.{:#x}", self.alloc_id, self.offset.bytes())
142+
write!(f, "{:?}+{:x}", self.alloc_id, self.offset.bytes())
143143
}
144144
}
145145

src/test/mir-opt/const-promotion-extern-static.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {}
1414
// START rustc.FOO.PromoteTemps.before.mir
1515
// bb0: {
1616
// ...
17-
// _5 = const Scalar(AllocId(1).0x0) : &i32;
17+
// _5 = const Scalar(alloc1+0) : &i32;
1818
// _4 = &(*_5);
1919
// _3 = [move _4];
2020
// _2 = &_3;
@@ -31,7 +31,7 @@ fn main() {}
3131
// START rustc.BAR.PromoteTemps.before.mir
3232
// bb0: {
3333
// ...
34-
// _5 = const Scalar(AllocId(0).0x0) : &i32;
34+
// _5 = const Scalar(alloc0+0) : &i32;
3535
// _4 = &(*_5);
3636
// _3 = [move _4];
3737
// _2 = &_3;

src/test/mir-opt/const_prop/read_immutable_static.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ fn main() {
1010
// START rustc.main.ConstProp.before.mir
1111
// bb0: {
1212
// ...
13-
// _3 = const Scalar(AllocId(0).0x0) : &u8;
13+
// _3 = const Scalar(alloc0+0) : &u8;
1414
// _2 = (*_3);
1515
// ...
16-
// _5 = const Scalar(AllocId(0).0x0) : &u8;
16+
// _5 = const Scalar(alloc0+0) : &u8;
1717
// _4 = (*_5);
1818
// _1 = Add(move _2, move _4);
1919
// ...

0 commit comments

Comments
 (0)