diff options
| author | ouz-a <ouz.agz@gmail.com> | 2023-08-16 08:43:30 +0300 |
|---|---|---|
| committer | ouz-a <ouz.agz@gmail.com> | 2023-10-02 23:37:49 +0300 |
| commit | 3148e6a9933b17b28ed6c7b8d8bd6c8e49fe4a50 (patch) | |
| tree | 15b25c07516fd4df1199c59c59464fdf0dea0b89 /compiler/rustc_middle/src | |
| parent | 177091258c039398d30137b52e1c575a98aa7597 (diff) | |
subtyping_projections
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/mir/syntax.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/tcx.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/visit.rs | 5 |
3 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index 55f895f73b4..128999a5fd1 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -1075,6 +1075,8 @@ pub enum ProjectionElem<V, T> { /// Like an explicit cast from an opaque type to a concrete type, but without /// requiring an intermediate variable. OpaqueCast(T), + + Subtype(T), } /// Alias for projections as they appear in places, where the base is a place diff --git a/compiler/rustc_middle/src/mir/tcx.rs b/compiler/rustc_middle/src/mir/tcx.rs index 01c04f63890..f534f0f5f3c 100644 --- a/compiler/rustc_middle/src/mir/tcx.rs +++ b/compiler/rustc_middle/src/mir/tcx.rs @@ -111,6 +111,7 @@ impl<'tcx> PlaceTy<'tcx> { } ProjectionElem::Field(f, fty) => PlaceTy::from_ty(handle_field(&self, f, fty)), ProjectionElem::OpaqueCast(ty) => PlaceTy::from_ty(handle_opaque_cast(&self, ty)), + ProjectionElem::Subtype(_) => PlaceTy::from_ty(self.ty), }; debug!("projection_ty self: {:?} elem: {:?} yields: {:?}", self, elem, answer); answer diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index 51ec6da1ac8..800c3f44da1 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -1110,6 +1110,7 @@ macro_rules! visit_place_fns { if ty != new_ty { Some(PlaceElem::OpaqueCast(new_ty)) } else { None } } PlaceElem::Deref + | PlaceElem::Subtype { .. } | PlaceElem::ConstantIndex { .. } | PlaceElem::Subslice { .. } | PlaceElem::Downcast(..) => None, @@ -1175,7 +1176,9 @@ macro_rules! visit_place_fns { location: Location, ) { match elem { - ProjectionElem::OpaqueCast(ty) | ProjectionElem::Field(_, ty) => { + ProjectionElem::OpaqueCast(ty) + | ProjectionElem::Subtype(ty) + | ProjectionElem::Field(_, ty) => { self.visit_ty(ty, TyContext::Location(location)); } ProjectionElem::Index(local) => { |
