From af6ac1fa14b8a753261c19f2afbc62cabdd894d2 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Thu, 11 Apr 2019 11:12:47 +0200 Subject: [PATCH] Refactor string constant printing to prep for byte string printing --- src/librustc/ty/print/pretty.rs | 6 +++--- 1 file 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)), }