diff options
| author | bors <bors@rust-lang.org> | 2024-09-21 07:00:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-21 07:00:52 +0000 |
| commit | 74fd001cdae0321144a20133f2216ea8a97da476 (patch) | |
| tree | 8c25cac318c638e5aed9fb64678176a23741bac5 /compiler/rustc_codegen_cranelift/src/base.rs | |
| parent | c0838c8ebec23fb87855bb6de3a287981cb1df98 (diff) | |
| parent | 5770ba86860a7594189e69c5d34a730ca46344bd (diff) | |
| download | rust-74fd001cdae0321144a20133f2216ea8a97da476.tar.gz rust-74fd001cdae0321144a20133f2216ea8a97da476.zip | |
Auto merge of #130649 - matthiaskrgr:rollup-57zc7lz, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #129718 (add guarantee about remove_dir and remove_file error kinds) - #130598 (Add recursion limit to FFI safety lint) - #130642 (Pass the current cargo to `run-make` tests) - #130644 (Only expect valtree consts in codegen) - #130645 (Normalize consts in writeback when GCE is enabled) - #130646 (compiler: factor out `OVERFLOWING_LITERALS` impl) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/base.rs')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/base.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index 4af4b39cc5b..8839829e2f5 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -785,8 +785,10 @@ fn codegen_stmt<'tcx>( } Rvalue::Repeat(ref operand, times) => { let operand = codegen_operand(fx, operand); - let times = - fx.monomorphize(times).eval_target_usize(fx.tcx, ParamEnv::reveal_all()); + let times = fx + .monomorphize(times) + .try_to_target_usize(fx.tcx) + .expect("expected monomorphic const in codegen"); if operand.layout().size.bytes() == 0 { // Do nothing for ZST's } else if fx.clif_type(operand.layout().ty) == Some(types::I8) { @@ -944,7 +946,10 @@ fn codegen_stmt<'tcx>( fn codegen_array_len<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, place: CPlace<'tcx>) -> Value { match *place.layout().ty.kind() { ty::Array(_elem_ty, len) => { - let len = fx.monomorphize(len).eval_target_usize(fx.tcx, ParamEnv::reveal_all()) as i64; + let len = fx + .monomorphize(len) + .try_to_target_usize(fx.tcx) + .expect("expected monomorphic const in codegen") as i64; fx.bcx.ins().iconst(fx.pointer_type, len) } ty::Slice(_elem_ty) => place.to_ptr_unsized().1, |
