Skip to content

Commit cd40aba

Browse files
committed
remove subtyping
1 parent c52b876 commit cd40aba

File tree

35 files changed

+24
-228
lines changed

35 files changed

+24
-228
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2993,7 +2993,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
29932993
}
29942994
ProjectionElem::ConstantIndex { .. }
29952995
| ProjectionElem::Subslice { .. }
2996-
| ProjectionElem::Subtype(_)
29972996
| ProjectionElem::Index(_) => kind,
29982997
},
29992998
place_ty.projection_ty(tcx, elem),

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
243243
ProjectionElem::Downcast(..) if opt.including_downcast => return None,
244244
ProjectionElem::Downcast(..) => (),
245245
ProjectionElem::OpaqueCast(..) => (),
246-
ProjectionElem::Subtype(..) => (),
247246
ProjectionElem::Field(field, _ty) => {
248247
// FIXME(project-rfc_2229#36): print capture precisely here.
249248
if let Some(field) = self.is_upvar_field_projection(PlaceRef {
@@ -324,9 +323,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
324323
PlaceRef { local, projection: proj_base }.ty(self.body, self.infcx.tcx)
325324
}
326325
ProjectionElem::Downcast(..) => place.ty(self.body, self.infcx.tcx),
327-
ProjectionElem::Subtype(ty) | ProjectionElem::OpaqueCast(ty) => {
328-
PlaceTy::from_ty(*ty)
329-
}
326+
ProjectionElem::OpaqueCast(ty) => PlaceTy::from_ty(*ty),
330327
ProjectionElem::Field(_, field_type) => PlaceTy::from_ty(*field_type),
331328
},
332329
};

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
157157
[
158158
..,
159159
ProjectionElem::Index(_)
160-
| ProjectionElem::Subtype(_)
161160
| ProjectionElem::ConstantIndex { .. }
162161
| ProjectionElem::OpaqueCast { .. }
163162
| ProjectionElem::Subslice { .. }

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,9 +1695,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
16951695
// `Downcast` : only changes information about a `Place` without moving.
16961696
// `Subtype` : only transmutes the type, so no moves.
16971697
// So it's safe to skip these.
1698-
ProjectionElem::OpaqueCast(_)
1699-
| ProjectionElem::Subtype(_)
1700-
| ProjectionElem::Downcast(_, _) => (),
1698+
ProjectionElem::OpaqueCast(_) | ProjectionElem::Downcast(_, _) => (),
17011699
}
17021700

17031701
place_ty = place_ty.projection_ty(tcx, elem);
@@ -1921,7 +1919,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
19211919
for (place_base, elem) in place.iter_projections().rev() {
19221920
match elem {
19231921
ProjectionElem::Index(_/*operand*/) |
1924-
ProjectionElem::Subtype(_) |
19251922
ProjectionElem::OpaqueCast(_) |
19261923
ProjectionElem::ConstantIndex { .. } |
19271924
// assigning to P[i] requires P to be valid.
@@ -2312,7 +2309,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
23122309
| ProjectionElem::Index(..)
23132310
| ProjectionElem::ConstantIndex { .. }
23142311
| ProjectionElem::Subslice { .. }
2315-
| ProjectionElem::Subtype(..)
23162312
| ProjectionElem::OpaqueCast { .. }
23172313
| ProjectionElem::Downcast(..) => {
23182314
let upvar_field_projection = self.is_upvar_field_projection(place);

compiler/rustc_borrowck/src/places_conflict.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ fn place_components_conflict<'tcx>(
249249
| (ProjectionElem::ConstantIndex { .. }, _, _)
250250
| (ProjectionElem::Subslice { .. }, _, _)
251251
| (ProjectionElem::OpaqueCast { .. }, _, _)
252-
| (ProjectionElem::Subtype(_), _, _)
253252
| (ProjectionElem::Downcast { .. }, _, _) => {
254253
// Recursive case. This can still be disjoint on a
255254
// further iteration if this a shallow access and
@@ -509,7 +508,6 @@ fn place_projection_conflict<'tcx>(
509508
| ProjectionElem::Field(..)
510509
| ProjectionElem::Index(..)
511510
| ProjectionElem::ConstantIndex { .. }
512-
| ProjectionElem::Subtype(_)
513511
| ProjectionElem::OpaqueCast { .. }
514512
| ProjectionElem::Subslice { .. }
515513
| ProjectionElem::Downcast(..),

compiler/rustc_borrowck/src/prefixes.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> {
8989
cursor = cursor_base;
9090
continue 'cursor;
9191
}
92-
ProjectionElem::Subtype(..) => {
93-
panic!("Subtype projection is not allowed before borrow check")
94-
}
9592
ProjectionElem::Deref => {
9693
// (handled below)
9794
}

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -719,9 +719,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
719719
}
720720
PlaceTy::from_ty(fty)
721721
}
722-
ProjectionElem::Subtype(_) => {
723-
bug!("ProjectionElem::Subtype shouldn't exist in borrowck")
724-
}
725722
ProjectionElem::OpaqueCast(ty) => {
726723
let ty = self.sanitize_type(place, ty);
727724
let ty = self.cx.normalize(ty, location);
@@ -2592,9 +2589,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25922589
| ProjectionElem::Subslice { .. } => {
25932590
// other field access
25942591
}
2595-
ProjectionElem::Subtype(_) => {
2596-
bug!("ProjectionElem::Subtype shouldn't exist in borrowck")
2597-
}
25982592
}
25992593
}
26002594
}

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,6 @@ pub(crate) fn codegen_place<'tcx>(
864864
cplace = cplace.place_deref(fx);
865865
}
866866
PlaceElem::OpaqueCast(ty) => bug!("encountered OpaqueCast({ty}) in codegen"),
867-
PlaceElem::Subtype(ty) => cplace = cplace.place_transmute_type(fx, fx.monomorphize(ty)),
868867
PlaceElem::Field(field, _ty) => {
869868
cplace = cplace.place_field(fx, field);
870869
}

compiler/rustc_codegen_cranelift/src/value_and_place.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -693,16 +693,6 @@ impl<'tcx> CPlace<'tcx> {
693693
}
694694
}
695695

696-
/// Used for `ProjectionElem::Subtype`, `ty` has to be monomorphized before
697-
/// passed on.
698-
pub(crate) fn place_transmute_type(
699-
self,
700-
fx: &mut FunctionCx<'_, '_, 'tcx>,
701-
ty: Ty<'tcx>,
702-
) -> CPlace<'tcx> {
703-
CPlace { inner: self.inner, layout: fx.layout_of(ty) }
704-
}
705-
706696
pub(crate) fn place_field(
707697
self,
708698
fx: &mut FunctionCx<'_, '_, 'tcx>,

compiler/rustc_codegen_ssa/src/mir/place.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
466466
mir::ProjectionElem::OpaqueCast(ty) => {
467467
bug!("encountered OpaqueCast({ty}) in codegen")
468468
}
469-
mir::ProjectionElem::Subtype(ty) => cg_base.project_type(bx, self.monomorphize(ty)),
470469
mir::ProjectionElem::Index(index) => {
471470
let index = &mir::Operand::Copy(mir::Place::from(index));
472471
let index = self.codegen_operand(bx, index);

0 commit comments

Comments
 (0)