@@ -1264,14 +1264,21 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1264
1264
} else if let Some ( body_id) = outermost_body {
1265
1265
let fn_id = self . tcx . hir ( ) . body_owner ( body_id) ;
1266
1266
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 ( ..) , .. } )
1268
1268
| Node :: TraitItem ( hir:: TraitItem {
1269
- kind : hir:: TraitItemKind :: Fn ( ..) , ..
1269
+ owner_id,
1270
+ kind : hir:: TraitItemKind :: Fn ( ..) ,
1271
+ ..
1270
1272
} )
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 ( ) ) ;
1275
1282
}
1276
1283
_ => { }
1277
1284
}
@@ -1658,10 +1665,12 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
1658
1665
/// "Constrained" basically means that it appears in any type but
1659
1666
/// not amongst the inputs to a projection. In other words, `<&'a
1660
1667
/// 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 ) ?;
1665
1674
1666
1675
let mut late_bound = FxIndexSet :: default ( ) ;
1667
1676
@@ -1695,24 +1704,22 @@ fn is_late_bound_map(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<&FxIndexSet<
1695
1704
hir:: GenericParamKind :: Type { .. } | hir:: GenericParamKind :: Const { .. } => continue ,
1696
1705
}
1697
1706
1698
- let param_def_id = tcx. hir ( ) . local_def_id ( param. hir_id ) ;
1699
-
1700
1707
// 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 ) {
1702
1709
continue ;
1703
1710
}
1704
1711
1705
1712
// 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 )
1708
1715
{
1709
1716
continue ;
1710
1717
}
1711
1718
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 ) ;
1713
1720
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 ) ;
1716
1723
}
1717
1724
1718
1725
debug ! ( ?late_bound) ;
0 commit comments