@@ -153,6 +153,7 @@ trait ResolverAstLoweringExt {
153153 fn get_label_res ( & self , id : NodeId ) -> Option < NodeId > ;
154154 fn get_lifetime_res ( & self , id : NodeId ) -> Option < LifetimeRes > ;
155155 fn take_extra_lifetime_params ( & mut self , id : NodeId ) -> Vec < ( Ident , NodeId , LifetimeRes ) > ;
156+ fn remap_extra_lifetime_params ( & mut self , from : NodeId , to : NodeId ) ;
156157 fn decl_macro_kind ( & self , def_id : LocalDefId ) -> MacroKind ;
157158}
158159
@@ -213,6 +214,11 @@ impl ResolverAstLoweringExt for ResolverAstLowering {
213214 self . extra_lifetime_params_map . remove ( & id) . unwrap_or_default ( )
214215 }
215216
217+ fn remap_extra_lifetime_params ( & mut self , from : NodeId , to : NodeId ) {
218+ let lifetimes = self . extra_lifetime_params_map . remove ( & from) . unwrap_or_default ( ) ;
219+ self . extra_lifetime_params_map . insert ( to, lifetimes) ;
220+ }
221+
216222 fn decl_macro_kind ( & self , def_id : LocalDefId ) -> MacroKind {
217223 self . builtin_macro_kinds . get ( & def_id) . copied ( ) . unwrap_or ( MacroKind :: Bang )
218224 }
@@ -1089,6 +1095,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10891095 // constructing the HIR for `impl bounds...` and then lowering that.
10901096
10911097 let impl_trait_node_id = self . next_node_id ( ) ;
1098+ // Shift `impl Trait` lifetime captures from the associated type bound's
1099+ // node id to the opaque node id, so that the opaque can actually use
1100+ // these lifetime bounds.
1101+ self . resolver
1102+ . remap_extra_lifetime_params ( constraint. id , impl_trait_node_id) ;
10921103
10931104 self . with_dyn_type_scope ( false , |this| {
10941105 let node_id = this. next_node_id ( ) ;
0 commit comments