Skip to content

Commit de7cefa

Browse files
committed
Sync from rust b5c8c329a7b4f6a12ae72ae41cb834989228221e
2 parents 5bf5153 + f58bd0e commit de7cefa

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ fn codegen_stmt<'tcx>(
857857
fn codegen_array_len<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, place: CPlace<'tcx>) -> Value {
858858
match *place.layout().ty.kind() {
859859
ty::Array(_elem_ty, len) => {
860-
let len = fx.monomorphize(len).eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64;
860+
let len = fx.monomorphize(len).eval_target_usize(fx.tcx, ParamEnv::reveal_all()) as i64;
861861
fx.bcx.ins().iconst(fx.pointer_type, len)
862862
}
863863
ty::Slice(_elem_ty) => {

src/driver/aot.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -248,17 +248,13 @@ fn reuse_workproduct_for_cgu(
248248
dwarf_object: None,
249249
bytecode: None,
250250
},
251-
module_global_asm: if has_global_asm {
252-
Some(CompiledModule {
253-
name: cgu.name().to_string(),
254-
kind: ModuleKind::Regular,
255-
object: Some(obj_out_global_asm),
256-
dwarf_object: None,
257-
bytecode: None,
258-
})
259-
} else {
260-
None
261-
},
251+
module_global_asm: has_global_asm.then(|| CompiledModule {
252+
name: cgu.name().to_string(),
253+
kind: ModuleKind::Regular,
254+
object: Some(obj_out_global_asm),
255+
dwarf_object: None,
256+
bytecode: None,
257+
}),
262258
existing_work_product: Some((cgu.work_product_id(), work_product)),
263259
})
264260
}

src/intrinsics/mod.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -644,10 +644,14 @@ fn codegen_regular_intrinsic_call<'tcx>(
644644
let layout = fx.layout_of(ty);
645645
let do_panic = match intrinsic {
646646
sym::assert_inhabited => layout.abi.is_uninhabited(),
647-
sym::assert_zero_valid => !fx.tcx.permits_zero_init(fx.param_env().and(layout)),
648-
sym::assert_mem_uninitialized_valid => {
649-
!fx.tcx.permits_uninit_init(fx.param_env().and(layout))
650-
}
647+
sym::assert_zero_valid => !fx
648+
.tcx
649+
.permits_zero_init(fx.param_env().and(layout))
650+
.expect("expected to have layout during codegen"),
651+
sym::assert_mem_uninitialized_valid => !fx
652+
.tcx
653+
.permits_uninit_init(fx.param_env().and(layout))
654+
.expect("expected to have layout during codegen"),
651655
_ => unreachable!(),
652656
};
653657
if do_panic {

src/intrinsics/simd.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
141141
let idx_ty = fx.monomorphize(idx.ty(fx.mir, fx.tcx));
142142
match idx_ty.kind() {
143143
ty::Array(ty, len) if matches!(ty.kind(), ty::Uint(ty::UintTy::U32)) => len
144-
.try_eval_usize(fx.tcx, ty::ParamEnv::reveal_all())
144+
.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
145145
.unwrap_or_else(|| {
146146
span_bug!(span, "could not evaluate shuffle index array length")
147147
})
@@ -735,7 +735,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
735735
ty::Uint(i) if i.bit_width() == Some(expected_int_bits) => {}
736736
ty::Array(elem, len)
737737
if matches!(elem.kind(), ty::Uint(ty::UintTy::U8))
738-
&& len.try_eval_usize(fx.tcx, ty::ParamEnv::reveal_all())
738+
&& len.try_eval_target_usize(fx.tcx, ty::ParamEnv::reveal_all())
739739
== Some(expected_bytes) => {}
740740
_ => {
741741
fx.tcx.sess.span_fatal(

src/unsize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(crate) fn unsized_info<'tcx>(
2424
(&ty::Array(_, len), &ty::Slice(_)) => fx
2525
.bcx
2626
.ins()
27-
.iconst(fx.pointer_type, len.eval_usize(fx.tcx, ParamEnv::reveal_all()) as i64),
27+
.iconst(fx.pointer_type, len.eval_target_usize(fx.tcx, ParamEnv::reveal_all()) as i64),
2828
(
2929
&ty::Dynamic(ref data_a, _, src_dyn_kind),
3030
&ty::Dynamic(ref data_b, _, target_dyn_kind),

src/value_and_place.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,8 @@ impl<'tcx> CPlace<'tcx> {
567567
CPlaceInner::Var(_local, var) => {
568568
if let ty::Array(element, len) = dst_layout.ty.kind() {
569569
// Can only happen for vector types
570-
let len =
571-
u32::try_from(len.eval_usize(fx.tcx, ParamEnv::reveal_all())).unwrap();
570+
let len = u32::try_from(len.eval_target_usize(fx.tcx, ParamEnv::reveal_all()))
571+
.unwrap();
572572
let vector_ty = fx.clif_type(*element).unwrap().by(len).unwrap();
573573

574574
let data = match from.0 {

0 commit comments

Comments
 (0)