@@ -1728,13 +1728,8 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
17281728 }
17291729
17301730 let normalized_ident = ident. normalize_to_macros_2_0 ( ) ;
1731- let mut outer_res = None ;
1732- for rib in lifetime_rib_iter {
1733- if let Some ( ( & outer, _) ) = rib. bindings . get_key_value ( & normalized_ident) {
1734- outer_res = Some ( outer) ;
1735- break ;
1736- }
1737- }
1731+ let outer_res = lifetime_rib_iter
1732+ . find_map ( |rib| rib. bindings . get_key_value ( & normalized_ident) . map ( |( & outer, _) | outer) ) ;
17381733
17391734 self . emit_undeclared_lifetime_error ( lifetime, outer_res) ;
17401735 self . record_lifetime_res ( lifetime. id , LifetimeRes :: Error , LifetimeElisionCandidate :: Named ) ;
@@ -1801,23 +1796,21 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
18011796 }
18021797 LifetimeRibKind :: AnonymousReportError => {
18031798 if elided {
1804- let mut suggestion = None ;
1805- for rib in self . lifetime_ribs [ i..] . iter ( ) . rev ( ) {
1799+ let suggestion = self . lifetime_ribs [ i..] . iter ( ) . rev ( ) . find_map ( |rib| {
18061800 if let LifetimeRibKind :: Generics {
18071801 span,
18081802 kind : LifetimeBinderKind :: PolyTrait | LifetimeBinderKind :: WhereBound ,
18091803 ..
1810- } = & rib. kind
1804+ } = rib. kind
18111805 {
1812- suggestion =
1813- Some ( errors :: ElidedAnonymousLivetimeReportErrorSuggestion {
1814- lo : span. shrink_to_lo ( ) ,
1815- hi : lifetime . ident . span . shrink_to_hi ( ) ,
1816- } ) ;
1817- break ;
1806+ Some ( errors :: ElidedAnonymousLivetimeReportErrorSuggestion {
1807+ lo : span . shrink_to_lo ( ) ,
1808+ hi : lifetime . ident . span . shrink_to_hi ( ) ,
1809+ } )
1810+ } else {
1811+ None
18181812 }
1819- }
1820-
1813+ } ) ;
18211814 // are we trying to use an anonymous lifetime
18221815 // on a non GAT associated trait type?
18231816 if !self . in_func_body
@@ -2486,14 +2479,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
24862479 /// Determine whether or not a label from the `rib_index`th label rib is reachable.
24872480 fn is_label_valid_from_rib ( & self , rib_index : usize ) -> bool {
24882481 let ribs = & self . label_ribs [ rib_index + 1 ..] ;
2489-
2490- for rib in ribs {
2491- if rib. kind . is_label_barrier ( ) {
2492- return false ;
2493- }
2494- }
2495-
2496- true
2482+ ribs. iter ( ) . all ( |rib| !rib. kind . is_label_barrier ( ) )
24972483 }
24982484
24992485 fn resolve_adt ( & mut self , item : & ' ast Item , generics : & ' ast Generics ) {
0 commit comments