1
Fork 0
This commit is contained in:
bjorn3 2022-02-22 19:55:24 +01:00
commit 33cf8fafd8
3 changed files with 26 additions and 21 deletions

View file

@ -117,7 +117,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
.unzip(); .unzip();
let return_layout = self.layout_of(return_ty); let return_layout = self.layout_of(return_ty);
let return_tys = if let ty::Tuple(tup) = return_ty.kind() { let return_tys = if let ty::Tuple(tup) = return_ty.kind() {
tup.types().map(|ty| AbiParam::new(self.clif_type(ty).unwrap())).collect() tup.iter().map(|ty| AbiParam::new(self.clif_type(ty).unwrap())).collect()
} else { } else {
vec![AbiParam::new(self.clif_type(return_ty).unwrap())] vec![AbiParam::new(self.clif_type(return_ty).unwrap())]
}; };
@ -199,7 +199,7 @@ pub(crate) fn codegen_fn_prelude<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, start_
}; };
let mut params = Vec::new(); let mut params = Vec::new();
for (i, _arg_ty) in tupled_arg_tys.types().enumerate() { for (i, _arg_ty) in tupled_arg_tys.iter().enumerate() {
let arg_abi = arg_abis_iter.next().unwrap(); let arg_abi = arg_abis_iter.next().unwrap();
let param = let param =
cvalue_for_param(fx, Some(local), Some(i), arg_abi, &mut block_params_iter); cvalue_for_param(fx, Some(local), Some(i), arg_abi, &mut block_params_iter);

View file

@ -90,10 +90,9 @@ fn clif_pair_type_from_ty<'tcx>(
ty: Ty<'tcx>, ty: Ty<'tcx>,
) -> Option<(types::Type, types::Type)> { ) -> Option<(types::Type, types::Type)> {
Some(match ty.kind() { Some(match ty.kind() {
ty::Tuple(substs) if substs.len() == 2 => { ty::Tuple(types) if types.len() == 2 => {
let mut types = substs.types(); let a = clif_type_from_ty(tcx, types[0])?;
let a = clif_type_from_ty(tcx, types.next().unwrap())?; let b = clif_type_from_ty(tcx, types[1])?;
let b = clif_type_from_ty(tcx, types.next().unwrap())?;
if a.is_vector() || b.is_vector() { if a.is_vector() || b.is_vector() {
return None; return None;
} }

View file

@ -654,29 +654,35 @@ fn codegen_regular_intrinsic_call<'tcx>(
assert_inhabited | assert_zero_valid | assert_uninit_valid, () { assert_inhabited | assert_zero_valid | assert_uninit_valid, () {
let layout = fx.layout_of(substs.type_at(0)); let layout = fx.layout_of(substs.type_at(0));
if layout.abi.is_uninhabited() { if layout.abi.is_uninhabited() {
with_no_trimmed_paths(|| crate::base::codegen_panic( with_no_trimmed_paths!({
fx, crate::base::codegen_panic(
&format!("attempted to instantiate uninhabited type `{}`", layout.ty), fx,
span, &format!("attempted to instantiate uninhabited type `{}`", layout.ty),
)); span,
)
});
return; return;
} }
if intrinsic == sym::assert_zero_valid && !layout.might_permit_raw_init(fx, /*zero:*/ true) { if intrinsic == sym::assert_zero_valid && !layout.might_permit_raw_init(fx, /*zero:*/ true) {
with_no_trimmed_paths(|| crate::base::codegen_panic( with_no_trimmed_paths!({
fx, crate::base::codegen_panic(
&format!("attempted to zero-initialize type `{}`, which is invalid", layout.ty), fx,
span, &format!("attempted to zero-initialize type `{}`, which is invalid", layout.ty),
)); span,
);
});
return; return;
} }
if intrinsic == sym::assert_uninit_valid && !layout.might_permit_raw_init(fx, /*zero:*/ false) { if intrinsic == sym::assert_uninit_valid && !layout.might_permit_raw_init(fx, /*zero:*/ false) {
with_no_trimmed_paths(|| crate::base::codegen_panic( with_no_trimmed_paths!({
fx, crate::base::codegen_panic(
&format!("attempted to leave type `{}` uninitialized, which is invalid", layout.ty), fx,
span, &format!("attempted to leave type `{}` uninitialized, which is invalid", layout.ty),
)); span,
)
});
return; return;
} }
}; };