Skip to content

Commit 2e8f8d5

Browse files
committed
Sync from rust 1d23d06800271f651fad07bf22bf5e298138972e
2 parents a20a4c2 + 0eae3a2 commit 2e8f8d5

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

src/abi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
471471
true
472472
} else {
473473
instance.is_some_and(|inst| {
474-
fx.tcx.codegen_fn_attrs(inst.def_id()).flags.contains(CodegenFnAttrFlags::COLD)
474+
fx.tcx.codegen_instance_attrs(inst.def).flags.contains(CodegenFnAttrFlags::COLD)
475475
})
476476
};
477477
if is_cold {

src/base.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -853,13 +853,6 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
853853
fx.bcx.ins().nop();
854854
}
855855
}
856-
Rvalue::ShallowInitBox(ref operand, content_ty) => {
857-
let content_ty = fx.monomorphize(content_ty);
858-
let box_layout = fx.layout_of(Ty::new_box(fx.tcx, content_ty));
859-
let operand = codegen_operand(fx, operand);
860-
let operand = operand.load_scalar(fx);
861-
lval.write_cvalue(fx, CValue::by_val(operand, box_layout));
862-
}
863856
Rvalue::NullaryOp(ref null_op, ty) => {
864857
assert!(lval.layout().ty.is_sized(fx.tcx, fx.typing_env()));
865858
let layout = fx.layout_of(fx.monomorphize(ty));
@@ -948,6 +941,7 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
948941
lval.write_cvalue_transmute(fx, operand);
949942
}
950943
Rvalue::CopyForDeref(_) => bug!("`CopyForDeref` in codegen"),
944+
Rvalue::ShallowInitBox(..) => bug!("`ShallowInitBox` in codegen"),
951945
}
952946
}
953947
StatementKind::StorageLive(_)

src/unsize.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ pub(crate) fn coerce_unsized_into<'tcx>(
131131
dst.write_cvalue(fx, CValue::by_val_pair(base, info, dst.layout()));
132132
};
133133
match (&src_ty.kind(), &dst_ty.kind()) {
134+
(ty::Pat(a, _), ty::Pat(b, _)) => {
135+
let src = src.cast_pat_ty_to_base(fx.layout_of(*a));
136+
let dst = dst.place_transmute_type(fx, *b);
137+
return coerce_unsized_into(fx, src, dst);
138+
}
134139
(&ty::Ref(..), &ty::Ref(..))
135140
| (&ty::Ref(..), &ty::RawPtr(..))
136141
| (&ty::RawPtr(..), &ty::RawPtr(..)) => coerce_ptr(),

src/value_and_place.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@ impl<'tcx> CValue<'tcx> {
342342
assert_eq!(self.layout().backend_repr, layout.backend_repr);
343343
CValue(self.0, layout)
344344
}
345+
346+
pub(crate) fn cast_pat_ty_to_base(self, layout: TyAndLayout<'tcx>) -> Self {
347+
let ty::Pat(base, _) = *self.layout().ty.kind() else {
348+
panic!("not a pattern type: {:#?}", self.layout())
349+
};
350+
assert_eq!(layout.ty, base);
351+
CValue(self.0, layout)
352+
}
345353
}
346354

347355
/// A place where you can write a value to or read a value from

0 commit comments

Comments
 (0)