Move try_to_raw_bytes from ty::Valtree to ty::Value

Signed-off-by: FedericoBruzzone <federico.bruzzone.i@gmail.com>
This commit is contained in:
FedericoBruzzone 2025-02-03 18:33:27 +01:00
parent 6e0dfc813c
commit 00c61a81a0
3 changed files with 36 additions and 38 deletions

View file

@ -649,7 +649,8 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
// HACK(jaic1): hide the `str` type behind a reference
// for the following transformation from valtree to raw bytes
let ref_ty = Ty::new_imm_ref(tcx, tcx.lifetimes.re_static, ct_ty);
let slice = valtree.try_to_raw_bytes(tcx, ref_ty).unwrap_or_else(|| {
let cv = ty::Value { ty: ref_ty, valtree };
let slice = cv.try_to_raw_bytes(tcx).unwrap_or_else(|| {
bug!("expected to get raw bytes from valtree {:?} for type {:}", valtree, ct_ty)
});
let s = std::str::from_utf8(slice).expect("non utf8 str from MIR interpreter");