Skip to content

Commit de3cc71

Browse files
committed
sort visit_projection_elem by definition order
1 parent 9725c4b commit de3cc71

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
@@ -654,20 +654,6 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
654654
location: Location,
655655
) {
656656
match elem {
657-
ProjectionElem::OpaqueCast(ty)
658-
if self.body.phase >= MirPhase::Runtime(RuntimePhase::Initial) =>
659-
{
660-
self.fail(
661-
location,
662-
format!("explicit opaque type cast to `{ty}` after `PostAnalysisNormalize`"),
663-
)
664-
}
665-
ProjectionElem::Index(index) => {
666-
let index_ty = self.body.local_decls[index].ty;
667-
if index_ty != self.tcx.types.usize {
668-
self.fail(location, format!("bad index ({index_ty} != usize)"))
669-
}
670-
}
671657
ProjectionElem::Deref
672658
if self.body.phase >= MirPhase::Runtime(RuntimePhase::PostCleanup) =>
673659
{
@@ -814,6 +800,20 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
814800
}
815801
}
816802
}
803+
ProjectionElem::Index(index) => {
804+
let index_ty = self.body.local_decls[index].ty;
805+
if index_ty != self.tcx.types.usize {
806+
self.fail(location, format!("bad index ({index_ty} != usize)"))
807+
}
808+
}
809+
ProjectionElem::OpaqueCast(ty)
810+
if self.body.phase >= MirPhase::Runtime(RuntimePhase::Initial) =>
811+
{
812+
self.fail(
813+
location,
814+
format!("explicit opaque type cast to `{ty}` after `PostAnalysisNormalize`"),
815+
)
816+
}
817817
ProjectionElem::UnwrapUnsafeBinder(unwrapped_ty) => {
818818
let binder_ty = place_ref.ty(&self.body.local_decls, self.tcx);
819819
let ty::UnsafeBinder(binder_ty) = *binder_ty.ty.kind() else {

0 commit comments

Comments
 (0)