@@ -369,7 +369,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
369369 autoderef_index = match place. projection . iter ( ) . rposition ( |elem| {
370370 !matches ! (
371371 elem,
372- ProjectionElem :: Deref | ProjectionElem :: Downcast ( .. )
372+ ProjectionElem :: Deref | ProjectionElem :: Downcast { .. }
373373 )
374374 } ) {
375375 Some ( index) => Some ( index + 1 ) ,
@@ -382,8 +382,8 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
382382 }
383383 }
384384 ProjectionElem :: PhantomDeref => ( ) ,
385- ProjectionElem :: Downcast ( .. ) if opt. including_downcast => return None ,
386- ProjectionElem :: Downcast ( .. ) => ( ) ,
385+ ProjectionElem :: Downcast { .. } if opt. including_downcast => return None ,
386+ ProjectionElem :: Downcast { .. } => ( ) ,
387387 ProjectionElem :: OpaqueCast ( ..) => ( ) ,
388388 ProjectionElem :: UnwrapUnsafeBinder ( _) => ( ) ,
389389 ProjectionElem :: Field ( field, _ty) => {
@@ -425,15 +425,13 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
425425 }
426426
427427 fn describe_name ( & self , place : PlaceRef < ' tcx > ) -> Option < Symbol > {
428- for elem in place. projection . into_iter ( ) {
429- match elem {
430- ProjectionElem :: Downcast ( Some ( name) , _) => {
431- return Some ( * name) ;
432- }
433- _ => { }
428+ place. projection . into_iter ( ) . find_map ( |elem| {
429+ if let ProjectionElem :: Downcast { name : Some ( name) , .. } = elem {
430+ Some ( * name)
431+ } else {
432+ None
434433 }
435- }
436- None
434+ } )
437435 }
438436
439437 /// Appends end-user visible description of the `local` place to `buf`. If `local` doesn't have
@@ -465,7 +463,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
465463 | ProjectionElem :: Subslice { .. } => {
466464 PlaceRef { local, projection : proj_base } . ty ( self . body , self . infcx . tcx )
467465 }
468- ProjectionElem :: Downcast ( .. ) => place. ty ( self . body , self . infcx . tcx ) ,
466+ ProjectionElem :: Downcast { .. } => place. ty ( self . body , self . infcx . tcx ) ,
469467 ProjectionElem :: OpaqueCast ( ty) | ProjectionElem :: UnwrapUnsafeBinder ( ty) => {
470468 PlaceTy :: from_ty ( * ty)
471469 }
@@ -1055,12 +1053,15 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
10551053 }
10561054 }
10571055
1058- let normal_ret =
1059- if moved_place. projection . iter ( ) . any ( |p| matches ! ( p, ProjectionElem :: Downcast ( ..) ) ) {
1060- PatUse ( stmt. source_info . span )
1061- } else {
1062- OtherUse ( stmt. source_info . span )
1063- } ;
1056+ let normal_ret = if moved_place
1057+ . projection
1058+ . iter ( )
1059+ . any ( |p| matches ! ( p, ProjectionElem :: Downcast { .. } ) )
1060+ {
1061+ PatUse ( stmt. source_info . span )
1062+ } else {
1063+ OtherUse ( stmt. source_info . span )
1064+ } ;
10641065
10651066 // We are trying to find MIR of the form:
10661067 // ```
0 commit comments