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

Commit 7834ffb

Browse files
committed
this ICE 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. add a regression test Update tests/ui/sanitize/issue-114275-cfi-const-expr-in-arry-len.rs Co-authored-by: Michael Goulet <[email protected]> Update tests/ui/sanitize/issue-114275-cfi-const-expr-in-arry-len.rs Co-authored-by: Michael Goulet <[email protected]> fix test compiling for targets with -crt-static and failing this was causign rust-lang#114686 to fail
1 parent 27a43f0 commit 7834ffb

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)