From bdf4b1e81153cc39ff115bde9b04db93c64c1446 Mon Sep 17 00:00:00 2001 From: Jaic1 <506933131@qq.com> Date: Wed, 18 Sep 2024 09:48:22 +0800 Subject: [PATCH] always use a ref ty to do transformation --- compiler/rustc_symbol_mangling/src/v0.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index 7a83cb805eb7c..1e8d7697fb7d4 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -596,13 +596,9 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> { // Handle `str` as partial support for unsized constants ty::Str => { let tcx = self.tcx(); - let ref_ty = if matches!(ct_ty.kind(), ty::Str) { - // HACK(jaic1): hide the `str` type behind a reference - // for the following transformation from valtree to raw bytes - Ty::new_imm_ref(tcx, tcx.lifetimes.re_static, ct_ty) - } else { - ct_ty - }; + // 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(|| { bug!("expected to get raw bytes from valtree {:?} for type {:}", valtree, ct_ty) });