@@ -17,6 +17,7 @@ use rustc_target::abi::VariantIdx;
1717
1818use rustc_index:: vec:: Idx ;
1919
20+ use std:: assert_matches:: assert_matches;
2021use std:: iter;
2122
2223/// The "outermost" place that holds this value.
@@ -232,22 +233,20 @@ fn strip_prefix<'tcx>(
232233 projections : Vec < PlaceElem < ' tcx > > ,
233234 prefix_projections : & [ HirProjection < ' tcx > ] ,
234235) -> impl Iterator < Item = PlaceElem < ' tcx > > {
235- let mut iter = projections. into_iter ( ) ;
236- let mut next = || match iter . next ( ) ? {
236+ let mut iter = projections
237+ . into_iter ( )
237238 // Filter out opaque casts, they are unnecessary in the prefix.
238- ProjectionElem :: OpaqueCast ( ..) => iter. next ( ) ,
239- other => Some ( other) ,
240- } ;
239+ . filter ( |elem| !matches ! ( elem, ProjectionElem :: OpaqueCast ( ..) ) ) ;
241240 for projection in prefix_projections {
242241 match projection. kind {
243242 HirProjectionKind :: Deref => {
244- assert ! ( matches! ( next( ) , Some ( ProjectionElem :: Deref ) ) ) ;
243+ assert_matches ! ( iter . next( ) , Some ( ProjectionElem :: Deref ) ) ;
245244 }
246245 HirProjectionKind :: Field ( ..) => {
247246 if base_ty. is_enum ( ) {
248- assert ! ( matches! ( next( ) , Some ( ProjectionElem :: Downcast ( ..) ) ) ) ;
247+ assert_matches ! ( iter . next( ) , Some ( ProjectionElem :: Downcast ( ..) ) ) ;
249248 }
250- assert ! ( matches! ( next( ) , Some ( ProjectionElem :: Field ( ..) ) ) ) ;
249+ assert_matches ! ( iter . next( ) , Some ( ProjectionElem :: Field ( ..) ) ) ;
251250 }
252251 HirProjectionKind :: Index | HirProjectionKind :: Subslice => {
253252 bug ! ( "unexpected projection kind: {:?}" , projection) ;
0 commit comments