@@ -39,7 +39,6 @@ use rustc_ast::node_id::NodeMap;
39
39
use rustc_ast:: token:: { self , Token } ;
40
40
use rustc_ast:: tokenstream:: { CanSynthesizeMissingTokens , TokenStream , TokenTree } ;
41
41
use rustc_ast:: visit:: { self , AssocCtxt , Visitor } ;
42
- use rustc_ast:: walk_list;
43
42
use rustc_ast:: { self as ast, * } ;
44
43
use rustc_ast_pretty:: pprust;
45
44
use rustc_data_structures:: captures:: Captures ;
@@ -48,7 +47,7 @@ use rustc_data_structures::sync::Lrc;
48
47
use rustc_errors:: { struct_span_err, Applicability } ;
49
48
use rustc_hir as hir;
50
49
use rustc_hir:: def:: { DefKind , Namespace , PartialRes , PerNS , Res } ;
51
- use rustc_hir:: def_id:: { DefId , DefIdMap , DefPathHash , LocalDefId , CRATE_DEF_ID } ;
50
+ use rustc_hir:: def_id:: { DefId , DefPathHash , LocalDefId , CRATE_DEF_ID } ;
52
51
use rustc_hir:: definitions:: { DefKey , DefPathData , Definitions } ;
53
52
use rustc_hir:: intravisit;
54
53
use rustc_hir:: { ConstArg , GenericArg , InferKind , ParamName } ;
@@ -104,8 +103,6 @@ struct LoweringContext<'a, 'hir: 'a> {
104
103
owners : IndexVec < LocalDefId , Option < hir:: OwnerNode < ' hir > > > ,
105
104
bodies : BTreeMap < hir:: BodyId , hir:: Body < ' hir > > ,
106
105
107
- trait_impls : BTreeMap < DefId , Vec < LocalDefId > > ,
108
-
109
106
modules : BTreeMap < LocalDefId , hir:: ModuleItems > ,
110
107
111
108
generator_kind : Option < hir:: GeneratorKind > ,
@@ -158,8 +155,6 @@ struct LoweringContext<'a, 'hir: 'a> {
158
155
159
156
current_module : LocalDefId ,
160
157
161
- type_def_lifetime_params : DefIdMap < usize > ,
162
-
163
158
current_hir_id_owner : ( LocalDefId , u32 ) ,
164
159
item_local_id_counters : NodeMap < u32 > ,
165
160
node_id_to_hir_id : IndexVec < NodeId , Option < hir:: HirId > > ,
@@ -171,7 +166,7 @@ struct LoweringContext<'a, 'hir: 'a> {
171
166
pub trait ResolverAstLowering {
172
167
fn def_key ( & mut self , id : DefId ) -> DefKey ;
173
168
174
- fn item_generics_num_lifetimes ( & self , def : DefId , sess : & Session ) -> usize ;
169
+ fn item_generics_num_lifetimes ( & self , def : DefId ) -> usize ;
175
170
176
171
fn legacy_const_generic_args ( & mut self , expr : & Expr ) -> Option < Vec < usize > > ;
177
172
@@ -326,7 +321,6 @@ pub fn lower_crate<'a, 'hir>(
326
321
arena,
327
322
owners : IndexVec :: default ( ) ,
328
323
bodies : BTreeMap :: new ( ) ,
329
- trait_impls : BTreeMap :: new ( ) ,
330
324
modules : BTreeMap :: new ( ) ,
331
325
attrs : BTreeMap :: default ( ) ,
332
326
catch_scopes : Vec :: new ( ) ,
@@ -335,7 +329,6 @@ pub fn lower_crate<'a, 'hir>(
335
329
is_in_trait_impl : false ,
336
330
is_in_dyn_type : false ,
337
331
anonymous_lifetime_mode : AnonymousLifetimeMode :: PassThrough ,
338
- type_def_lifetime_params : Default :: default ( ) ,
339
332
current_module : CRATE_DEF_ID ,
340
333
current_hir_id_owner : ( CRATE_DEF_ID , 0 ) ,
341
334
item_local_id_counters : Default :: default ( ) ,
@@ -451,26 +444,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
451
444
fn visit_item ( & mut self , item : & ' tcx Item ) {
452
445
self . lctx . allocate_hir_id_counter ( item. id ) ;
453
446
454
- match item. kind {
455
- ItemKind :: Struct ( _, ref generics)
456
- | ItemKind :: Union ( _, ref generics)
457
- | ItemKind :: Enum ( _, ref generics)
458
- | ItemKind :: TyAlias ( box TyAliasKind ( _, ref generics, ..) )
459
- | ItemKind :: Trait ( box TraitKind ( _, _, ref generics, ..) ) => {
460
- let def_id = self . lctx . resolver . local_def_id ( item. id ) ;
461
- let count = generics
462
- . params
463
- . iter ( )
464
- . filter ( |param| {
465
- matches ! ( param. kind, ast:: GenericParamKind :: Lifetime { .. } )
466
- } )
467
- . count ( ) ;
468
- self . lctx . type_def_lifetime_params . insert ( def_id. to_def_id ( ) , count) ;
469
- }
470
- ItemKind :: Use ( ref use_tree) => {
471
- self . allocate_use_tree_hir_id_counters ( use_tree) ;
472
- }
473
- _ => { }
447
+ if let ItemKind :: Use ( ref use_tree) = item. kind {
448
+ self . allocate_use_tree_hir_id_counters ( use_tree) ;
474
449
}
475
450
476
451
visit:: walk_item ( self , item) ;
@@ -485,23 +460,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
485
460
self . lctx . allocate_hir_id_counter ( item. id ) ;
486
461
visit:: walk_foreign_item ( self , item) ;
487
462
}
488
-
489
- fn visit_ty ( & mut self , t : & ' tcx Ty ) {
490
- match t. kind {
491
- // Mirrors the case in visit::walk_ty
492
- TyKind :: BareFn ( ref f) => {
493
- walk_list ! ( self , visit_generic_param, & f. generic_params) ;
494
- // Mirrors visit::walk_fn_decl
495
- for parameter in & f. decl . inputs {
496
- // We don't lower the ids of argument patterns
497
- self . visit_pat ( & parameter. pat ) ;
498
- self . visit_ty ( & parameter. ty )
499
- }
500
- self . visit_fn_ret_ty ( & f. decl . output )
501
- }
502
- _ => visit:: walk_ty ( self , t) ,
503
- }
504
- }
505
463
}
506
464
507
465
self . lower_node_id ( CRATE_NODE_ID ) ;
@@ -515,10 +473,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
515
473
self . owners . ensure_contains_elem ( CRATE_DEF_ID , || None ) ;
516
474
self . owners [ CRATE_DEF_ID ] = Some ( hir:: OwnerNode :: Crate ( module) ) ;
517
475
518
- let body_ids = body_ids ( & self . bodies ) ;
519
- let proc_macros =
520
- c. proc_macros . iter ( ) . map ( |id| self . node_id_to_hir_id [ * id] . unwrap ( ) ) . collect ( ) ;
521
-
522
476
let mut trait_map: FxHashMap < _ , FxHashMap < _ , _ > > = FxHashMap :: default ( ) ;
523
477
for ( k, v) in self . resolver . take_trait_map ( ) . into_iter ( ) {
524
478
if let Some ( Some ( hir_id) ) = self . node_id_to_hir_id . get ( k) {
@@ -551,10 +505,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
551
505
let krate = hir:: Crate {
552
506
owners : self . owners ,
553
507
bodies : self . bodies ,
554
- body_ids,
555
- trait_impls : self . trait_impls ,
556
508
modules : self . modules ,
557
- proc_macros,
558
509
trait_map,
559
510
attrs : self . attrs ,
560
511
} ;
@@ -2749,14 +2700,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2749
2700
}
2750
2701
}
2751
2702
2752
- fn body_ids ( bodies : & BTreeMap < hir:: BodyId , hir:: Body < ' _ > > ) -> Vec < hir:: BodyId > {
2753
- // Sorting by span ensures that we get things in order within a
2754
- // file, and also puts the files in a sensible order.
2755
- let mut body_ids: Vec < _ > = bodies. keys ( ) . cloned ( ) . collect ( ) ;
2756
- body_ids. sort_by_key ( |b| bodies[ b] . value . span ) ;
2757
- body_ids
2758
- }
2759
-
2760
2703
/// Helper struct for delayed construction of GenericArgs.
2761
2704
struct GenericArgsCtor < ' hir > {
2762
2705
args : SmallVec < [ hir:: GenericArg < ' hir > ; 4 ] > ,
0 commit comments