diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-04-11 11:12:47 +0200 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-05-25 10:07:01 +0200 |
| commit | af6ac1fa14b8a753261c19f2afbc62cabdd894d2 (patch) | |
| tree | 7a0dcce5b9c8cedb13bbfdd1d195beceaf1db8c7 /src | |
| parent | 264c149c8945b714a2922d412dde07b7651a5ea1 (diff) | |
| download | rust-af6ac1fa14b8a753261c19f2afbc62cabdd894d2.tar.gz rust-af6ac1fa14b8a753261c19f2afbc62cabdd894d2.zip | |
Refactor string constant printing to prep for byte string printing
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/ty/print/pretty.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index 7b363ad6ac4..817205af1b3 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -1570,18 +1570,18 @@ define_print_and_forward_display! { ConstValue::Slice(place, len), ty::Ref(_, &ty::TyS { sty: ty::Str, .. }, _), ) => { - let s = match (place, len) { + match (place, len) { (_, 0) => "", (Scalar::Ptr(ptr), len) => { let alloc = cx.tcx().alloc_map.lock().unwrap_memory(ptr.alloc_id); assert_eq!(len as usize as u64, len); let slice = &alloc.bytes[(ptr.offset.bytes() as usize)..][..(len as usize)]; - ::std::str::from_utf8(slice).expect("non utf8 str from miri") + let s = ::std::str::from_utf8(slice).expect("non utf8 str from miri"); + p!(write("{:?}", s)) }, _ => bug!("invalid slice: {:#?}", self), }; - p!(write("{:?}", s)) }, _ => p!(write("{:?} : ", self.val), print(self.ty)), } |
