Skip to content

Commit de6d914

Browse files
committed
remove Subtype projections
1 parent 70e814b commit de6d914

File tree

33 files changed

+37
-229
lines changed

33 files changed

+37
-229
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3971,7 +3971,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
39713971
}
39723972
ProjectionElem::ConstantIndex { .. }
39733973
| ProjectionElem::Subslice { .. }
3974-
| ProjectionElem::Subtype(_)
39753974
| ProjectionElem::Index(_) => kind,
39763975
},
39773976
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<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, '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<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, '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
@@ -164,7 +164,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
164164
[
165165
..,
166166
ProjectionElem::Index(_)
167-
| ProjectionElem::Subtype(_)
168167
| ProjectionElem::ConstantIndex { .. }
169168
| ProjectionElem::OpaqueCast { .. }
170169
| ProjectionElem::Subslice { .. }

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,11 +1712,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
17121712
},
17131713
// `OpaqueCast`: only transmutes the type, so no moves there.
17141714
// `Downcast` : only changes information about a `Place` without moving.
1715-
// `Subtype` : only transmutes the type, so no moves.
17161715
// So it's safe to skip these.
1717-
ProjectionElem::OpaqueCast(_)
1718-
| ProjectionElem::Subtype(_)
1719-
| ProjectionElem::Downcast(_, _) => (),
1716+
ProjectionElem::OpaqueCast(_) | ProjectionElem::Downcast(_, _) => (),
17201717
}
17211718

17221719
place_ty = place_ty.projection_ty(tcx, elem);
@@ -1940,7 +1937,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
19401937
for (place_base, elem) in place.iter_projections().rev() {
19411938
match elem {
19421939
ProjectionElem::Index(_/*operand*/) |
1943-
ProjectionElem::Subtype(_) |
19441940
ProjectionElem::OpaqueCast(_) |
19451941
ProjectionElem::ConstantIndex { .. } |
19461942
// assigning to P[i] requires P to be valid.
@@ -2332,7 +2328,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
23322328
| ProjectionElem::Index(..)
23332329
| ProjectionElem::ConstantIndex { .. }
23342330
| ProjectionElem::Subslice { .. }
2335-
| ProjectionElem::Subtype(..)
23362331
| ProjectionElem::OpaqueCast { .. }
23372332
| ProjectionElem::Downcast(..) => {
23382333
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
@@ -73,9 +73,6 @@ impl<'tcx> Iterator for Prefixes<'tcx> {
7373
| ProjectionElem::Index(_) => {
7474
cursor = cursor_base;
7575
}
76-
ProjectionElem::Subtype(..) => {
77-
panic!("Subtype projection is not allowed before borrow check")
78-
}
7976
ProjectionElem::Deref => {
8077
match self.kind {
8178
PrefixSet::Shallow => {

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -698,9 +698,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
698698
}
699699
PlaceTy::from_ty(fty)
700700
}
701-
ProjectionElem::Subtype(_) => {
702-
bug!("ProjectionElem::Subtype shouldn't exist in borrowck")
703-
}
704701
ProjectionElem::OpaqueCast(ty) => {
705702
let ty = self.sanitize_type(place, ty);
706703
let ty = self.cx.normalize(ty, location);
@@ -2700,9 +2697,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
27002697
| ProjectionElem::Subslice { .. } => {
27012698
// other field access
27022699
}
2703-
ProjectionElem::Subtype(_) => {
2704-
bug!("ProjectionElem::Subtype shouldn't exist in borrowck")
2705-
}
27062700
}
27072701
}
27082702
}

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,6 @@ pub(crate) fn codegen_place<'tcx>(
981981
cplace = cplace.place_deref(fx);
982982
}
983983
PlaceElem::OpaqueCast(ty) => bug!("encountered OpaqueCast({ty}) in codegen"),
984-
PlaceElem::Subtype(ty) => cplace = cplace.place_transmute_type(fx, fx.monomorphize(ty)),
985984
PlaceElem::Field(field, _ty) => {
986985
cplace = cplace.place_field(fx, field);
987986
}

compiler/rustc_codegen_cranelift/src/value_and_place.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -708,16 +708,6 @@ impl<'tcx> CPlace<'tcx> {
708708
}
709709
}
710710

711-
/// Used for `ProjectionElem::Subtype`, `ty` has to be monomorphized before
712-
/// passed on.
713-
pub(crate) fn place_transmute_type(
714-
self,
715-
fx: &mut FunctionCx<'_, '_, 'tcx>,
716-
ty: Ty<'tcx>,
717-
) -> CPlace<'tcx> {
718-
CPlace { inner: self.inner, layout: fx.layout_of(ty) }
719-
}
720-
721711
pub(crate) fn place_field(
722712
self,
723713
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
@@ -495,7 +495,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
495495
mir::ProjectionElem::OpaqueCast(ty) => {
496496
bug!("encountered OpaqueCast({ty}) in codegen")
497497
}
498-
mir::ProjectionElem::Subtype(ty) => cg_base.project_type(bx, self.monomorphize(ty)),
499498
mir::ProjectionElem::Index(index) => {
500499
let index = &mir::Operand::Copy(mir::Place::from(index));
501500
let index = self.codegen_operand(bx, index);

0 commit comments

Comments
 (0)