@@ -84,9 +84,6 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
84
84
generator_kind : None ,
85
85
task_context : None ,
86
86
current_item : None ,
87
- lifetimes_to_define : Default :: default ( ) ,
88
- is_collecting_anonymous_lifetimes : None ,
89
- in_scope_lifetimes : Vec :: new ( ) ,
90
87
captured_lifetimes : None ,
91
88
allow_try_trait : Some ( [ sym:: try_trait_v2] [ ..] . into ( ) ) ,
92
89
allow_gen_future : Some ( [ sym:: gen_future] [ ..] . into ( ) ) ,
@@ -149,36 +146,8 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
149
146
// This is used to track which lifetimes have already been defined,
150
147
// and which need to be replicated when lowering an async fn.
151
148
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, .. } ) => {
153
150
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 ( ) ;
182
151
}
183
152
_ => { }
184
153
} ;
@@ -286,7 +255,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
286
255
ref body,
287
256
..
288
257
} ) => {
289
- let fn_def_id = self . resolver . local_def_id ( id) ;
290
258
self . with_new_scopes ( |this| {
291
259
this. current_item = Some ( ident. span ) ;
292
260
@@ -299,7 +267,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
299
267
this. lower_maybe_async_body ( span, & decl, asyncness, body. as_deref ( ) ) ;
300
268
301
269
let ( generics, decl) =
302
- this. add_implicit_generics ( generics, fn_def_id , |this, idty| {
270
+ this. add_implicit_generics ( generics, id , |this, idty| {
303
271
let ret_id = asyncness. opt_return_id ( ) ;
304
272
this. lower_fn_decl ( & decl, Some ( ( id, idty) ) , FnDeclKind :: Fn , ret_id)
305
273
} ) ;
@@ -415,9 +383,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
415
383
// method, it will not be considered an in-band
416
384
// lifetime to be added, but rather a reference to a
417
385
// parent lifetime.
418
- let lowered_trait_def_id = hir_id. expect_owner ( ) ;
419
386
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, _| {
421
388
let trait_ref = trait_ref. as_ref ( ) . map ( |trait_ref| {
422
389
this. lower_trait_ref (
423
390
trait_ref,
@@ -431,12 +398,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
431
398
( trait_ref, lowered_ty)
432
399
} ) ;
433
400
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) ) ) ;
440
404
441
405
// `defaultness.has_value()` is never called for an `impl`, always `true` in order
442
406
// to not cause an assertion failure inside the `lower_defaultness` function.
@@ -743,7 +707,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
743
707
ForeignItemKind :: Fn ( box Fn { ref sig, ref generics, .. } ) => {
744
708
let fdec = & sig. decl ;
745
709
let ( generics, ( fn_dec, fn_args) ) =
746
- self . add_implicit_generics ( generics, def_id , |this, _| {
710
+ self . add_implicit_generics ( generics, i . id , |this, _| {
747
711
(
748
712
// Disallow `impl Trait` in foreign items.
749
713
this. lower_fn_decl ( fdec, None , FnDeclKind :: ExternFn , None ) ,
@@ -1343,9 +1307,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
1343
1307
kind : FnDeclKind ,
1344
1308
is_async : Option < NodeId > ,
1345
1309
) -> ( hir:: Generics < ' hir > , hir:: FnSig < ' hir > ) {
1346
- let fn_def_id = self . resolver . local_def_id ( id) ;
1347
1310
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| {
1349
1312
this. lower_fn_decl ( & sig. decl , Some ( ( id, idty) ) , kind, is_async)
1350
1313
} ) ;
1351
1314
( generics, hir:: FnSig { header, decl, span : self . lower_span ( sig. span ) } )
@@ -1487,24 +1450,20 @@ impl<'hir> LoweringContext<'_, 'hir> {
1487
1450
ref bounded_ty,
1488
1451
ref bounds,
1489
1452
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) ,
1508
1467
} ) ,
1509
1468
WherePredicate :: RegionPredicate ( WhereRegionPredicate {
1510
1469
ref lifetime,
0 commit comments