@@ -1264,14 +1264,21 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
12641264 } else if let Some ( body_id) = outermost_body {
12651265 let fn_id = self . tcx . hir ( ) . body_owner ( body_id) ;
12661266 match self . tcx . hir ( ) . get ( fn_id) {
1267- Node :: Item ( hir:: Item { kind : hir:: ItemKind :: Fn ( ..) , .. } )
1267+ Node :: Item ( hir:: Item { owner_id , kind : hir:: ItemKind :: Fn ( ..) , .. } )
12681268 | Node :: TraitItem ( hir:: TraitItem {
1269- kind : hir:: TraitItemKind :: Fn ( ..) , ..
1269+ owner_id,
1270+ kind : hir:: TraitItemKind :: Fn ( ..) ,
1271+ ..
12701272 } )
1271- | Node :: ImplItem ( hir:: ImplItem { kind : hir:: ImplItemKind :: Fn ( ..) , .. } )
1272- | Node :: Expr ( hir:: Expr { kind : hir:: ExprKind :: Closure ( ..) , .. } ) => {
1273- let scope = self . tcx . hir ( ) . local_def_id ( fn_id) ;
1274- def = Region :: Free ( scope. to_def_id ( ) , def. id ( ) . unwrap ( ) ) ;
1273+ | Node :: ImplItem ( hir:: ImplItem {
1274+ owner_id,
1275+ kind : hir:: ImplItemKind :: Fn ( ..) ,
1276+ ..
1277+ } ) => {
1278+ def = Region :: Free ( owner_id. to_def_id ( ) , def. id ( ) . unwrap ( ) ) ;
1279+ }
1280+ Node :: Expr ( hir:: Expr { kind : hir:: ExprKind :: Closure ( closure) , .. } ) => {
1281+ def = Region :: Free ( closure. def_id . to_def_id ( ) , def. id ( ) . unwrap ( ) ) ;
12751282 }
12761283 _ => { }
12771284 }
@@ -1658,10 +1665,12 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
16581665/// "Constrained" basically means that it appears in any type but
16591666/// not amongst the inputs to a projection. In other words, `<&'a
16601667/// T as Trait<''b>>::Foo` does not constrain `'a` or `'b`.
1661- fn is_late_bound_map ( tcx : TyCtxt < ' _ > , def_id : LocalDefId ) -> Option < & FxIndexSet < LocalDefId > > {
1662- let hir_id = tcx. hir ( ) . local_def_id_to_hir_id ( def_id) ;
1663- let decl = tcx. hir ( ) . fn_decl_by_hir_id ( hir_id) ?;
1664- let generics = tcx. hir ( ) . get_generics ( def_id) ?;
1668+ fn is_late_bound_map (
1669+ tcx : TyCtxt < ' _ > ,
1670+ owner_id : hir:: OwnerId ,
1671+ ) -> Option < & FxIndexSet < hir:: ItemLocalId > > {
1672+ let decl = tcx. hir ( ) . fn_decl_by_hir_id ( owner_id. into ( ) ) ?;
1673+ let generics = tcx. hir ( ) . get_generics ( owner_id. def_id ) ?;
16651674
16661675 let mut late_bound = FxIndexSet :: default ( ) ;
16671676
@@ -1695,24 +1704,22 @@ fn is_late_bound_map(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<&FxIndexSet<
16951704 hir:: GenericParamKind :: Type { .. } | hir:: GenericParamKind :: Const { .. } => continue ,
16961705 }
16971706
1698- let param_def_id = tcx. hir ( ) . local_def_id ( param. hir_id ) ;
1699-
17001707 // appears in the where clauses? early-bound.
1701- if appears_in_where_clause. regions . contains ( & param_def_id ) {
1708+ if appears_in_where_clause. regions . contains ( & param . def_id ) {
17021709 continue ;
17031710 }
17041711
17051712 // does not appear in the inputs, but appears in the return type? early-bound.
1706- if !constrained_by_input. regions . contains ( & param_def_id )
1707- && appears_in_output. regions . contains ( & param_def_id )
1713+ if !constrained_by_input. regions . contains ( & param . def_id )
1714+ && appears_in_output. regions . contains ( & param . def_id )
17081715 {
17091716 continue ;
17101717 }
17111718
1712- debug ! ( "lifetime {:?} with id {:?} is late-bound" , param. name. ident( ) , param. hir_id ) ;
1719+ debug ! ( "lifetime {:?} with id {:?} is late-bound" , param. name. ident( ) , param. def_id ) ;
17131720
1714- let inserted = late_bound. insert ( param_def_id ) ;
1715- assert ! ( inserted, "visited lifetime {:?} twice" , param. hir_id ) ;
1721+ let inserted = late_bound. insert ( param . hir_id . local_id ) ;
1722+ assert ! ( inserted, "visited lifetime {:?} twice" , param. def_id ) ;
17161723 }
17171724
17181725 debug ! ( ?late_bound) ;
0 commit comments