@@ -204,7 +204,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
204204 let tcx = self . tcx ( ) ;
205205
206206 let r = if let Some ( rl) = tcx. named_region ( lifetime. hir_id ) {
207- self . ast_region_to_region_inner ( rl)
207+ Self :: ast_region_to_region_inner ( tcx , rl)
208208 } else {
209209 self . re_infer ( def, lifetime. span ) . unwrap_or_else ( || {
210210 debug ! ( ?lifetime, "unelided lifetime in signature" ) ;
@@ -226,9 +226,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
226226 r
227227 }
228228
229- #[ tracing:: instrument( level = "debug" , skip( self ) ) ]
230- fn ast_region_to_region_inner ( & self , lifetime : rl:: Region ) -> ty:: Region < ' tcx > {
231- let tcx = self . tcx ( ) ;
229+ #[ tracing:: instrument( level = "debug" , skip( tcx) ) ]
230+ pub fn ast_region_to_region_inner ( tcx : TyCtxt < ' tcx > , lifetime : rl:: Region ) -> ty:: Region < ' tcx > {
232231 let lifetime_name = |def_id| tcx. hir ( ) . name ( tcx. hir ( ) . local_def_id_to_hir_id ( def_id) ) ;
233232
234233 let r = match lifetime {
@@ -1547,33 +1546,33 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
15471546 // Use explicitly-specified region bound.
15481547 let region_bound = if !lifetime. is_elided ( ) {
15491548 self . ast_region_to_region ( lifetime, None )
1549+ } else if let Some ( region) =
1550+ self . compute_object_lifetime_bound ( span, existential_predicates)
1551+ {
1552+ region
1553+ } else if let Some ( rl) = tcx. named_region ( lifetime. hir_id ) {
1554+ Self :: ast_region_to_region_inner ( self . tcx ( ) , rl)
1555+ } else if let Some ( & region) =
1556+ tcx. object_lifetime_map ( lifetime. hir_id . owner ) . get ( & lifetime. hir_id . local_id )
1557+ {
1558+ region
15501559 } else {
1551- self . compute_object_lifetime_bound ( span, existential_predicates) . unwrap_or_else ( || {
1552- if let Some ( rl) = tcx. named_region ( lifetime. hir_id ) {
1553- self . ast_region_to_region_inner ( rl)
1554- } else if let Some ( & rl) =
1555- tcx. object_lifetime_map ( lifetime. hir_id . owner ) . get ( & lifetime. hir_id . local_id )
1556- {
1557- self . ast_region_to_region_inner ( rl)
1558- } else {
1559- self . re_infer ( None , span) . unwrap_or_else ( || {
1560- let mut err = struct_span_err ! (
1561- tcx. sess,
1562- span,
1563- E0228 ,
1564- "the lifetime bound for this object type cannot be deduced \
1560+ self . re_infer ( None , span) . unwrap_or_else ( || {
1561+ let mut err = struct_span_err ! (
1562+ tcx. sess,
1563+ span,
1564+ E0228 ,
1565+ "the lifetime bound for this object type cannot be deduced \
15651566 from context; please supply an explicit bound"
1566- ) ;
1567- if borrowed {
1568- // We will have already emitted an error E0106 complaining about a
1569- // missing named lifetime in `&dyn Trait`, so we elide this one.
1570- err. delay_as_bug ( ) ;
1571- } else {
1572- err. emit ( ) ;
1573- }
1574- tcx. lifetimes . re_static
1575- } )
1567+ ) ;
1568+ if borrowed {
1569+ // We will have already emitted an error E0106 complaining about a
1570+ // missing named lifetime in `&dyn Trait`, so we elide this one.
1571+ err. delay_as_bug ( ) ;
1572+ } else {
1573+ err. emit ( ) ;
15761574 }
1575+ tcx. lifetimes . re_static
15771576 } )
15781577 } ;
15791578 debug ! ( "region_bound: {:?}" , region_bound) ;
0 commit comments