@@ -17,6 +17,7 @@ use rustc_target::abi::VariantIdx;
17
17
18
18
use rustc_index:: vec:: Idx ;
19
19
20
+ use std:: assert_matches:: assert_matches;
20
21
use std:: iter;
21
22
22
23
/// The "outermost" place that holds this value.
@@ -232,22 +233,20 @@ fn strip_prefix<'tcx>(
232
233
projections : Vec < PlaceElem < ' tcx > > ,
233
234
prefix_projections : & [ HirProjection < ' tcx > ] ,
234
235
) -> 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 ( )
237
238
// 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 ( ..) ) ) ;
241
240
for projection in prefix_projections {
242
241
match projection. kind {
243
242
HirProjectionKind :: Deref => {
244
- assert ! ( matches! ( next( ) , Some ( ProjectionElem :: Deref ) ) ) ;
243
+ assert_matches ! ( iter . next( ) , Some ( ProjectionElem :: Deref ) ) ;
245
244
}
246
245
HirProjectionKind :: Field ( ..) => {
247
246
if base_ty. is_enum ( ) {
248
- assert ! ( matches! ( next( ) , Some ( ProjectionElem :: Downcast ( ..) ) ) ) ;
247
+ assert_matches ! ( iter . next( ) , Some ( ProjectionElem :: Downcast ( ..) ) ) ;
249
248
}
250
- assert ! ( matches! ( next( ) , Some ( ProjectionElem :: Field ( ..) ) ) ) ;
249
+ assert_matches ! ( iter . next( ) , Some ( ProjectionElem :: Field ( ..) ) ) ;
251
250
}
252
251
HirProjectionKind :: Index | HirProjectionKind :: Subslice => {
253
252
bug ! ( "unexpected projection kind: {:?}" , projection) ;
0 commit comments