Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 4a742a6

Browse files
committed
Revert "Rollup merge of rust-lang#98582 - oli-obk:unconstrained_opaque_type, r=estebank"
This reverts commit 6f8fb91, reversing changes made to 7210e46.
1 parent 03d488b commit 4a742a6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+205
-396
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,9 +2155,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
21552155
}
21562156
StorageDeadOrDrop::Destructor(_) => kind,
21572157
},
2158-
ProjectionElem::OpaqueCast { .. }
2159-
| ProjectionElem::Field(..)
2160-
| ProjectionElem::Downcast(..) => {
2158+
ProjectionElem::Field(..) | ProjectionElem::Downcast(..) => {
21612159
match place_ty.ty.kind() {
21622160
ty::Adt(def, _) if def.has_dtor(tcx) => {
21632161
// Report the outermost adt with a destructor

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
226226
}
227227
ProjectionElem::Downcast(..) if including_downcast.0 => return None,
228228
ProjectionElem::Downcast(..) => (),
229-
ProjectionElem::OpaqueCast(..) => (),
230229
ProjectionElem::Field(field, _ty) => {
231230
// FIXME(project-rfc_2229#36): print capture precisely here.
232231
if let Some(field) = self.is_upvar_field_projection(PlaceRef {
@@ -287,7 +286,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
287286
PlaceRef { local, projection: proj_base }.ty(self.body, self.infcx.tcx)
288287
}
289288
ProjectionElem::Downcast(..) => place.ty(self.body, self.infcx.tcx),
290-
ProjectionElem::OpaqueCast(ty) => PlaceTy::from_ty(*ty),
291289
ProjectionElem::Field(_, field_type) => PlaceTy::from_ty(*field_type),
292290
},
293291
};

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
169169
..,
170170
ProjectionElem::Index(_)
171171
| ProjectionElem::ConstantIndex { .. }
172-
| ProjectionElem::OpaqueCast { .. }
173172
| ProjectionElem::Subslice { .. }
174173
| ProjectionElem::Downcast(..),
175174
],

compiler/rustc_borrowck/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17881788
for (place_base, elem) in place.iter_projections().rev() {
17891789
match elem {
17901790
ProjectionElem::Index(_/*operand*/) |
1791-
ProjectionElem::OpaqueCast(_) |
17921791
ProjectionElem::ConstantIndex { .. } |
17931792
// assigning to P[i] requires P to be valid.
17941793
ProjectionElem::Downcast(_/*adt_def*/, _/*variant_idx*/) =>
@@ -2180,7 +2179,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
21802179
| ProjectionElem::Index(..)
21812180
| ProjectionElem::ConstantIndex { .. }
21822181
| ProjectionElem::Subslice { .. }
2183-
| ProjectionElem::OpaqueCast { .. }
21842182
| ProjectionElem::Downcast(..) => {
21852183
let upvar_field_projection = self.is_upvar_field_projection(place);
21862184
if let Some(field) = upvar_field_projection {

compiler/rustc_borrowck/src/places_conflict.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ fn place_components_conflict<'tcx>(
255255
| (ProjectionElem::Index { .. }, _, _)
256256
| (ProjectionElem::ConstantIndex { .. }, _, _)
257257
| (ProjectionElem::Subslice { .. }, _, _)
258-
| (ProjectionElem::OpaqueCast { .. }, _, _)
259258
| (ProjectionElem::Downcast { .. }, _, _) => {
260259
// Recursive case. This can still be disjoint on a
261260
// further iteration if this a shallow access and
@@ -323,17 +322,6 @@ fn place_projection_conflict<'tcx>(
323322
debug!("place_element_conflict: DISJOINT-OR-EQ-DEREF");
324323
Overlap::EqualOrDisjoint
325324
}
326-
(ProjectionElem::OpaqueCast(v1), ProjectionElem::OpaqueCast(v2)) => {
327-
if v1 == v2 {
328-
// same type - recur.
329-
debug!("place_element_conflict: DISJOINT-OR-EQ-OPAQUE");
330-
Overlap::EqualOrDisjoint
331-
} else {
332-
// Different types. Disjoint!
333-
debug!("place_element_conflict: DISJOINT-OPAQUE");
334-
Overlap::Disjoint
335-
}
336-
}
337325
(ProjectionElem::Field(f1, _), ProjectionElem::Field(f2, _)) => {
338326
if f1 == f2 {
339327
// same field (e.g., `a.y` vs. `a.y`) - recur.
@@ -537,7 +525,6 @@ fn place_projection_conflict<'tcx>(
537525
| ProjectionElem::Field(..)
538526
| ProjectionElem::Index(..)
539527
| ProjectionElem::ConstantIndex { .. }
540-
| ProjectionElem::OpaqueCast { .. }
541528
| ProjectionElem::Subslice { .. }
542529
| ProjectionElem::Downcast(..),
543530
_,

compiler/rustc_borrowck/src/prefixes.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ impl<'cx, 'tcx> Iterator for Prefixes<'cx, 'tcx> {
8181
}
8282
ProjectionElem::Downcast(..)
8383
| ProjectionElem::Subslice { .. }
84-
| ProjectionElem::OpaqueCast { .. }
8584
| ProjectionElem::ConstantIndex { .. }
8685
| ProjectionElem::Index(_) => {
8786
cursor = cursor_base;

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -790,19 +790,6 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
790790
}
791791
PlaceTy::from_ty(fty)
792792
}
793-
ProjectionElem::OpaqueCast(ty) => {
794-
let ty = self.sanitize_type(place, ty);
795-
let ty = self.cx.normalize(ty, location);
796-
self.cx
797-
.eq_types(
798-
base.ty,
799-
ty,
800-
location.to_locations(),
801-
ConstraintCategory::TypeAnnotation,
802-
)
803-
.unwrap();
804-
PlaceTy::from_ty(ty)
805-
}
806793
}
807794
}
808795

@@ -1208,11 +1195,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
12081195
tcx,
12091196
self.param_env,
12101197
proj,
1211-
|this, field, _| {
1198+
|this, field, ()| {
12121199
let ty = this.field_ty(tcx, field);
12131200
self.normalize(ty, locations)
12141201
},
1215-
|_, _| unreachable!(),
12161202
);
12171203
curr_projected_ty = projected_ty;
12181204
}
@@ -2507,7 +2493,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25072493
}
25082494
ProjectionElem::Field(..)
25092495
| ProjectionElem::Downcast(..)
2510-
| ProjectionElem::OpaqueCast(..)
25112496
| ProjectionElem::Index(..)
25122497
| ProjectionElem::ConstantIndex { .. }
25132498
| ProjectionElem::Subslice { .. } => {

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,6 @@ pub(crate) fn codegen_place<'tcx>(
825825
cplace = cplace.place_deref(fx);
826826
}
827827
}
828-
PlaceElem::OpaqueCast(ty) => cplace = cplace.place_opaque_cast(fx, ty),
829828
PlaceElem::Field(field, _ty) => {
830829
cplace = cplace.place_field(fx, field);
831830
}

compiler/rustc_codegen_cranelift/src/value_and_place.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -615,14 +615,6 @@ impl<'tcx> CPlace<'tcx> {
615615
}
616616
}
617617

618-
pub(crate) fn place_opaque_cast(
619-
self,
620-
fx: &mut FunctionCx<'_, '_, 'tcx>,
621-
ty: Ty<'tcx>,
622-
) -> CPlace<'tcx> {
623-
CPlace { inner: self.inner, layout: fx.layout_of(ty) }
624-
}
625-
626618
pub(crate) fn place_field(
627619
self,
628620
fx: &mut FunctionCx<'_, '_, 'tcx>,

compiler/rustc_codegen_ssa/src/mir/place.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -411,21 +411,6 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
411411
downcast
412412
}
413413

414-
pub fn project_type<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
415-
&self,
416-
bx: &mut Bx,
417-
ty: Ty<'tcx>,
418-
) -> Self {
419-
let mut downcast = *self;
420-
downcast.layout = bx.cx().layout_of(ty);
421-
422-
// Cast to the appropriate type.
423-
let variant_ty = bx.cx().backend_type(downcast.layout);
424-
downcast.llval = bx.pointercast(downcast.llval, bx.cx().type_ptr_to(variant_ty));
425-
426-
downcast
427-
}
428-
429414
pub fn storage_live<Bx: BuilderMethods<'a, 'tcx, Value = V>>(&self, bx: &mut Bx) {
430415
bx.lifetime_start(self.llval, self.layout.size);
431416
}
@@ -474,7 +459,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
474459
mir::ProjectionElem::Field(ref field, _) => {
475460
cg_base.project_field(bx, field.index())
476461
}
477-
mir::ProjectionElem::OpaqueCast(ty) => cg_base.project_type(bx, ty),
478462
mir::ProjectionElem::Index(index) => {
479463
let index = &mir::Operand::Copy(mir::Place::from(index));
480464
let index = self.codegen_operand(bx, index);

0 commit comments

Comments
 (0)