Skip to content

Commit 8f430d6

Browse files
committed
sort visit_projection_elem by definition order
1 parent 3be6803 commit 8f430d6

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

compiler/rustc_mir_transform/src/validate.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -655,20 +655,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
655655
location: Location,
656656
) {
657657
match elem {
658-
ProjectionElem::OpaqueCast(ty)
659-
if self.body.phase >= MirPhase::Runtime(RuntimePhase::Initial) =>
660-
{
661-
self.fail(
662-
location,
663-
format!("explicit opaque type cast to `{ty}` after `PostAnalysisNormalize`"),
664-
)
665-
}
666-
ProjectionElem::Index(index) => {
667-
let index_ty = self.body.local_decls[index].ty;
668-
if index_ty != self.tcx.types.usize {
669-
self.fail(location, format!("bad index ({index_ty} != usize)"))
670-
}
671-
}
672658
ProjectionElem::Deref
673659
if self.body.phase >= MirPhase::Runtime(RuntimePhase::PostCleanup) =>
674660
{
@@ -815,6 +801,20 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
815801
}
816802
}
817803
}
804+
ProjectionElem::Index(index) => {
805+
let index_ty = self.body.local_decls[index].ty;
806+
if index_ty != self.tcx.types.usize {
807+
self.fail(location, format!("bad index ({index_ty} != usize)"))
808+
}
809+
}
810+
ProjectionElem::OpaqueCast(ty)
811+
if self.body.phase >= MirPhase::Runtime(RuntimePhase::Initial) =>
812+
{
813+
self.fail(
814+
location,
815+
format!("explicit opaque type cast to `{ty}` after `PostAnalysisNormalize`"),
816+
)
817+
}
818818
ProjectionElem::UnwrapUnsafeBinder(unwrapped_ty) => {
819819
let binder_ty = place_ref.ty(&self.body.local_decls, self.tcx);
820820
let ty::UnsafeBinder(binder_ty) = *binder_ty.ty.kind() else {

0 commit comments

Comments
 (0)