ProjectionElem::Subtype -> CastKind::Subtype
This commit is contained in:
parent
7ac0330c6d
commit
aa5a21450a
32 changed files with 47 additions and 112 deletions
|
|
@ -836,14 +836,6 @@ pub enum ProjectionElem {
|
|||
/// Like an explicit cast from an opaque type to a concrete type, but without
|
||||
/// requiring an intermediate variable.
|
||||
OpaqueCast(Ty),
|
||||
|
||||
/// A `Subtype(T)` projection is applied to any `StatementKind::Assign` where
|
||||
/// type of lvalue doesn't match the type of rvalue, the primary goal is making subtyping
|
||||
/// explicit during optimizations and codegen.
|
||||
///
|
||||
/// This projection doesn't impact the runtime behavior of the program except for potentially changing
|
||||
/// some type metadata of the interpreter or codegen backend.
|
||||
Subtype(Ty),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
|
||||
|
|
@ -1028,6 +1020,7 @@ pub enum CastKind {
|
|||
PtrToPtr,
|
||||
FnPtrToPtr,
|
||||
Transmute,
|
||||
Subtype,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Hash, Serialize)]
|
||||
|
|
@ -1089,7 +1082,7 @@ impl ProjectionElem {
|
|||
Self::subslice_ty(ty, *from, *to, *from_end)
|
||||
}
|
||||
ProjectionElem::Downcast(_) => Ok(ty),
|
||||
ProjectionElem::OpaqueCast(ty) | ProjectionElem::Subtype(ty) => Ok(*ty),
|
||||
ProjectionElem::OpaqueCast(ty) => Ok(*ty),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -471,7 +471,6 @@ macro_rules! visit_place_fns {
|
|||
ProjectionElem::Subslice { from: _, to: _, from_end: _ } => {}
|
||||
ProjectionElem::Downcast(_idx) => {}
|
||||
ProjectionElem::OpaqueCast(ty) => self.visit_ty(ty, location),
|
||||
ProjectionElem::Subtype(ty) => self.visit_ty(ty, location),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -512,7 +511,6 @@ macro_rules! visit_place_fns {
|
|||
ProjectionElem::Subslice { from: _, to: _, from_end: _ } => {}
|
||||
ProjectionElem::Downcast(_idx) => {}
|
||||
ProjectionElem::OpaqueCast(ty) => self.visit_ty(ty, location),
|
||||
ProjectionElem::Subtype(ty) => self.visit_ty(ty, location),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -703,9 +703,6 @@ impl RustcInternal for ProjectionElem {
|
|||
ProjectionElem::OpaqueCast(ty) => {
|
||||
rustc_middle::mir::PlaceElem::OpaqueCast(ty.internal(tables, tcx))
|
||||
}
|
||||
ProjectionElem::Subtype(ty) => {
|
||||
rustc_middle::mir::PlaceElem::Subtype(ty.internal(tables, tcx))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -356,6 +356,7 @@ impl<'tcx> Stable<'tcx> for mir::CastKind {
|
|||
PtrToPtr => crate::mir::CastKind::PtrToPtr,
|
||||
FnPtrToPtr => crate::mir::CastKind::FnPtrToPtr,
|
||||
Transmute => crate::mir::CastKind::Transmute,
|
||||
Subtype => crate::mir::CastKind::Subtype,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -453,7 +454,6 @@ impl<'tcx> Stable<'tcx> for mir::PlaceElem<'tcx> {
|
|||
// found at https://github.com/rust-lang/rust/pull/117517#issuecomment-1811683486
|
||||
Downcast(_, idx) => crate::mir::ProjectionElem::Downcast(idx.stable(tables, cx)),
|
||||
OpaqueCast(ty) => crate::mir::ProjectionElem::OpaqueCast(ty.stable(tables, cx)),
|
||||
Subtype(ty) => crate::mir::ProjectionElem::Subtype(ty.stable(tables, cx)),
|
||||
UnwrapUnsafeBinder(..) => todo!("FIXME(unsafe_binders):"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue