1
Fork 0

unify dyn* coercions with other pointer coercions

This commit is contained in:
Lukas Markeffsky 2024-09-15 16:47:42 +02:00
parent 67bb749c2e
commit 46ecb23198
23 changed files with 70 additions and 55 deletions

View file

@ -70,11 +70,11 @@ impl<'tcx> Visitor<'tcx> for MentionedItemsVisitor<'_, 'tcx> {
match *rvalue {
// We need to detect unsizing casts that required vtables.
mir::Rvalue::Cast(
mir::CastKind::PointerCoercion(PointerCoercion::Unsize),
mir::CastKind::PointerCoercion(PointerCoercion::Unsize)
| mir::CastKind::PointerCoercion(PointerCoercion::DynStar),
ref operand,
target_ty,
)
| mir::Rvalue::Cast(mir::CastKind::DynStar, ref operand, target_ty) => {
) => {
// This isn't monomorphized yet so we can't tell what the actual types are -- just
// add everything that may involve a vtable.
let source_ty = operand.ty(self.body, self.tcx);

View file

@ -1128,9 +1128,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
Rvalue::Cast(kind, operand, target_type) => {
let op_ty = operand.ty(self.body, self.tcx);
match kind {
CastKind::DynStar => {
// FIXME(dyn-star): make sure nothing needs to be done here.
}
// FIXME: Add Checks for these
CastKind::PointerWithExposedProvenance | CastKind::PointerExposeProvenance => {}
CastKind::PointerCoercion(PointerCoercion::ReifyFnPointer) => {
@ -1208,6 +1205,9 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
// This is used for all `CoerceUnsized` types,
// not just pointers/references, so is hard to check.
}
CastKind::PointerCoercion(PointerCoercion::DynStar) => {
// FIXME(dyn-star): make sure nothing needs to be done here.
}
CastKind::IntToInt | CastKind::IntToFloat => {
let input_valid = op_ty.is_integral() || op_ty.is_char() || op_ty.is_bool();
let target_valid = target_type.is_numeric() || target_type.is_char();