Change:
<!-- Thank you for finding an Internal Compiler Error! If possible, try to provide a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for how to create smaller examples. --<!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details<!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
Regression in nightly-2023-05-04 Regression in Regression in
I tracked this down to the fact that implicitly sets : I can reproduce with just on its own, without . Conversely, if I modify the wrapper function to pretend that coverage is always off, then the problem still occurs. So I believe this is actually an incompatibility between and v0 symbol mangling.
claim
With , the original code causing the ICE should be updated as:
Also the label for this issue should be replaced with . Cc

Discussion:
let _ = write!(self.out, "{bits:x}_"); } <ins> // Handle `str` as partial support for unsized constants ty::Str => { let tcx = self.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(|| { 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"); // "e" for str as a basic type self.push("e"); // FIXME(eddyb) use a specialized hex-encoding loop. for byte in s.bytes() { let _ = write!(self.out, "{byte:02x}"); } self.push("_"); } </ins> // FIXME(valtrees): Remove the special case for `str` // here and fully support unsized constants. <del> ty::Ref(_, inner_ty, mutbl) => { </del> <ins> ty::Ref(_, _, mutbl) => { </ins> self.push(match mutbl { hir::Mutability::Not => "R", hir::Mutability::Mut => "Q", }); <del> match inner_ty.kind() { ty::Str if mutbl.is_not() => { let slice = valtree.try_to_raw_bytes(self.tcx(), ct_ty).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"); self.push("e"); // FIXME(eddyb) use a specialized hex-encoding loop. for byte in s.bytes() { let _ = write!(self.out, "{byte:02x}"); } self.push("_"); } _ => { let pointee_ty = ct_ty .builtin_deref(true) .expect("tried to dereference on non-ptr type"); let dereferenced_const = ty::Const::new_value(self.tcx, valtree, pointee_ty); dereferenced_const.print(self)?; } } </del> <ins> let pointee_ty = ct_ty.builtin_deref(true).expect("tried to dereference on non-ptr type"); let dereferenced_const = ty::Const::new_value(self.tcx, valtree, pointee_ty); dereferenced_const.print(self)?; </ins> } ty::Array(..) | ty::Tuple(..) | ty::Adt(..) | ty::Slice(_) => {

<ins> //@ check-pass //@ compile-flags: -Csymbol-mangling-version=v0 #![allow(incomplete_features)] #![feature(unsized_const_params)] // Regression test for #116303 #[derive(PartialEq, Eq)] struct MyStr(str); impl std::marker::UnsizedConstParamTy for MyStr {} fn function_with_my_str<const S: &'static MyStr>() -> &'static MyStr { S } impl MyStr { const fn new(s: &'static str) -> &'static MyStr { unsafe { std::mem::transmute(s) } } } pub fn main() { let f = function_with_my_str::<{ MyStr::new("hello") }>(); } </ins>