Skip to content
/ rust Public
forked from rust-lang/rust

Commit 4d7a80d

Browse files
committed
Auto merge of rust-lang#114672 - lenawanel:master, r=compiler-errors
make `typeid::typeid_itanium_cxx_abi::transform_ty` evaluate length in array types the ICE in rust-lang#114275 was caused by `transform_ty` in compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs encountering an unevaluated const, while expecting it to already be evaluated.
2 parents 7d8386f + 7834ffb commit 4d7a80d

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -824,11 +824,8 @@ fn transform_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, options: TransformTyOptio
824824
}
825825

826826
ty::Array(ty0, len) => {
827-
let len = len
828-
.try_to_scalar()
829-
.unwrap()
830-
.to_u64()
831-
.unwrap_or_else(|_| panic!("failed to convert length to u64"));
827+
let len = len.eval_target_usize(tcx, ty::ParamEnv::reveal_all());
828+
832829
ty = Ty::new_array(tcx, transform_ty(tcx, *ty0, options), len);
833830
}
834831

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Regression test for issue 114275 `typeid::typeid_itanium_cxx_abi::transform_ty`
2+
// was expecting array type lengths to be evaluated, this was causing an ICE.
3+
//
4+
// build-pass
5+
// compile-flags: -Ccodegen-units=1 -Clto -Zsanitizer=cfi -Ctarget-feature=-crt-static
6+
// needs-sanitizer-cfi
7+
8+
#![crate_type = "lib"]
9+
10+
#[repr(transparent)]
11+
pub struct Array([u8; 1 * 1]);
12+
13+
pub extern "C" fn array() -> Array {
14+
loop {}
15+
}

0 commit comments

Comments
 (0)