Skip to content

Commit af6ac1f

Browse files
committed
Refactor string constant printing to prep for byte string printing
1 parent 264c149 commit af6ac1f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/librustc/ty/print/pretty.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,18 +1570,18 @@ define_print_and_forward_display! {
15701570
ConstValue::Slice(place, len),
15711571
ty::Ref(_, &ty::TyS { sty: ty::Str, .. }, _),
15721572
) => {
1573-
let s = match (place, len) {
1573+
match (place, len) {
15741574
(_, 0) => "",
15751575
(Scalar::Ptr(ptr), len) => {
15761576
let alloc = cx.tcx().alloc_map.lock().unwrap_memory(ptr.alloc_id);
15771577
assert_eq!(len as usize as u64, len);
15781578
let slice =
15791579
&alloc.bytes[(ptr.offset.bytes() as usize)..][..(len as usize)];
1580-
::std::str::from_utf8(slice).expect("non utf8 str from miri")
1580+
let s = ::std::str::from_utf8(slice).expect("non utf8 str from miri");
1581+
p!(write("{:?}", s))
15811582
},
15821583
_ => bug!("invalid slice: {:#?}", self),
15831584
};
1584-
p!(write("{:?}", s))
15851585
},
15861586
_ => p!(write("{:?} : ", self.val), print(self.ty)),
15871587
}

0 commit comments

Comments
 (0)