@@ -84,9 +84,6 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
8484 generator_kind : None ,
8585 task_context : None ,
8686 current_item : None ,
87- lifetimes_to_define : Default :: default ( ) ,
88- is_collecting_anonymous_lifetimes : None ,
89- in_scope_lifetimes : Vec :: new ( ) ,
9087 captured_lifetimes : None ,
9188 allow_try_trait : Some ( [ sym:: try_trait_v2] [ ..] . into ( ) ) ,
9289 allow_gen_future : Some ( [ sym:: gen_future] [ ..] . into ( ) ) ,
@@ -149,36 +146,8 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
149146 // This is used to track which lifetimes have already been defined,
150147 // and which need to be replicated when lowering an async fn.
151148 match parent_hir. node ( ) . expect_item ( ) . kind {
152- hir:: ItemKind :: Impl ( hir:: Impl { ref of_trait, ref generics , .. } ) => {
149+ hir:: ItemKind :: Impl ( hir:: Impl { ref of_trait, .. } ) => {
153150 lctx. is_in_trait_impl = of_trait. is_some ( ) ;
154- lctx. in_scope_lifetimes = generics
155- . params
156- . iter ( )
157- . filter ( |param| {
158- matches ! ( param. kind, hir:: GenericParamKind :: Lifetime { .. } )
159- } )
160- . map ( |param| {
161- let def_id =
162- parent_hir. nodes . local_id_to_def_id [ & param. hir_id . local_id ] ;
163- let name = param. name ;
164- ( name, def_id)
165- } )
166- . collect ( ) ;
167- }
168- hir:: ItemKind :: Trait ( _, _, ref generics, ..) => {
169- lctx. in_scope_lifetimes = generics
170- . params
171- . iter ( )
172- . filter ( |param| {
173- matches ! ( param. kind, hir:: GenericParamKind :: Lifetime { .. } )
174- } )
175- . map ( |param| {
176- let def_id =
177- parent_hir. nodes . local_id_to_def_id [ & param. hir_id . local_id ] ;
178- let name = param. name ;
179- ( name, def_id)
180- } )
181- . collect ( ) ;
182151 }
183152 _ => { }
184153 } ;
@@ -286,7 +255,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
286255 ref body,
287256 ..
288257 } ) => {
289- let fn_def_id = self . resolver . local_def_id ( id) ;
290258 self . with_new_scopes ( |this| {
291259 this. current_item = Some ( ident. span ) ;
292260
@@ -299,7 +267,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
299267 this. lower_maybe_async_body ( span, & decl, asyncness, body. as_deref ( ) ) ;
300268
301269 let ( generics, decl) =
302- this. add_implicit_generics ( generics, fn_def_id , |this, idty| {
270+ this. add_implicit_generics ( generics, id , |this, idty| {
303271 let ret_id = asyncness. opt_return_id ( ) ;
304272 this. lower_fn_decl ( & decl, Some ( ( id, idty) ) , FnDeclKind :: Fn , ret_id)
305273 } ) ;
@@ -415,9 +383,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
415383 // method, it will not be considered an in-band
416384 // lifetime to be added, but rather a reference to a
417385 // parent lifetime.
418- let lowered_trait_def_id = hir_id. expect_owner ( ) ;
419386 let ( generics, ( trait_ref, lowered_ty) ) =
420- self . add_implicit_generics ( ast_generics, lowered_trait_def_id , |this, _| {
387+ self . add_implicit_generics ( ast_generics, id , |this, _| {
421388 let trait_ref = trait_ref. as_ref ( ) . map ( |trait_ref| {
422389 this. lower_trait_ref (
423390 trait_ref,
@@ -431,12 +398,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
431398 ( trait_ref, lowered_ty)
432399 } ) ;
433400
434- let new_impl_items =
435- self . with_in_scope_lifetime_defs ( & ast_generics. params , |this| {
436- this. arena . alloc_from_iter (
437- impl_items. iter ( ) . map ( |item| this. lower_impl_item_ref ( item) ) ,
438- )
439- } ) ;
401+ let new_impl_items = self
402+ . arena
403+ . alloc_from_iter ( impl_items. iter ( ) . map ( |item| self . lower_impl_item_ref ( item) ) ) ;
440404
441405 // `defaultness.has_value()` is never called for an `impl`, always `true` in order
442406 // to not cause an assertion failure inside the `lower_defaultness` function.
@@ -743,7 +707,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
743707 ForeignItemKind :: Fn ( box Fn { ref sig, ref generics, .. } ) => {
744708 let fdec = & sig. decl ;
745709 let ( generics, ( fn_dec, fn_args) ) =
746- self . add_implicit_generics ( generics, def_id , |this, _| {
710+ self . add_implicit_generics ( generics, i . id , |this, _| {
747711 (
748712 // Disallow `impl Trait` in foreign items.
749713 this. lower_fn_decl ( fdec, None , FnDeclKind :: ExternFn , None ) ,
@@ -1343,9 +1307,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
13431307 kind : FnDeclKind ,
13441308 is_async : Option < NodeId > ,
13451309 ) -> ( hir:: Generics < ' hir > , hir:: FnSig < ' hir > ) {
1346- let fn_def_id = self . resolver . local_def_id ( id) ;
13471310 let header = self . lower_fn_header ( sig. header ) ;
1348- let ( generics, decl) = self . add_implicit_generics ( generics, fn_def_id , |this, idty| {
1311+ let ( generics, decl) = self . add_implicit_generics ( generics, id , |this, idty| {
13491312 this. lower_fn_decl ( & sig. decl , Some ( ( id, idty) ) , kind, is_async)
13501313 } ) ;
13511314 ( generics, hir:: FnSig { header, decl, span : self . lower_span ( sig. span ) } )
@@ -1487,24 +1450,20 @@ impl<'hir> LoweringContext<'_, 'hir> {
14871450 ref bounded_ty,
14881451 ref bounds,
14891452 span,
1490- } ) => self . with_in_scope_lifetime_defs ( & bound_generic_params, |this| {
1491- hir:: WherePredicate :: BoundPredicate ( hir:: WhereBoundPredicate {
1492- bound_generic_params : this. lower_generic_params (
1493- bound_generic_params,
1494- ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
1495- ) ,
1496- bounded_ty : this. lower_ty (
1497- bounded_ty,
1498- ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ,
1499- ) ,
1500- bounds : this. arena . alloc_from_iter ( bounds. iter ( ) . map ( |bound| {
1501- this. lower_param_bound (
1502- bound,
1503- ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ,
1504- )
1505- } ) ) ,
1506- span : this. lower_span ( span) ,
1507- } )
1453+ } ) => hir:: WherePredicate :: BoundPredicate ( hir:: WhereBoundPredicate {
1454+ bound_generic_params : self . lower_generic_params (
1455+ bound_generic_params,
1456+ ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
1457+ ) ,
1458+ bounded_ty : self
1459+ . lower_ty ( bounded_ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ,
1460+ bounds : self . arena . alloc_from_iter ( bounds. iter ( ) . map ( |bound| {
1461+ self . lower_param_bound (
1462+ bound,
1463+ ImplTraitContext :: Disallowed ( ImplTraitPosition :: Bound ) ,
1464+ )
1465+ } ) ) ,
1466+ span : self . lower_span ( span) ,
15081467 } ) ,
15091468 WherePredicate :: RegionPredicate ( WhereRegionPredicate {
15101469 ref lifetime,
0 commit comments