@@ -39,7 +39,6 @@ use rustc_ast::node_id::NodeMap;
3939use rustc_ast:: token:: { self , Token } ;
4040use rustc_ast:: tokenstream:: { CanSynthesizeMissingTokens , TokenStream , TokenTree } ;
4141use rustc_ast:: visit:: { self , AssocCtxt , Visitor } ;
42- use rustc_ast:: walk_list;
4342use rustc_ast:: { self as ast, * } ;
4443use rustc_ast_pretty:: pprust;
4544use rustc_data_structures:: captures:: Captures ;
@@ -48,7 +47,7 @@ use rustc_data_structures::sync::Lrc;
4847use rustc_errors:: { struct_span_err, Applicability } ;
4948use rustc_hir as hir;
5049use 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 } ;
5251use rustc_hir:: definitions:: { DefKey , DefPathData , Definitions } ;
5352use rustc_hir:: intravisit;
5453use rustc_hir:: { ConstArg , GenericArg , InferKind , ParamName } ;
@@ -104,8 +103,6 @@ struct LoweringContext<'a, 'hir: 'a> {
104103 owners : IndexVec < LocalDefId , Option < hir:: OwnerNode < ' hir > > > ,
105104 bodies : BTreeMap < hir:: BodyId , hir:: Body < ' hir > > ,
106105
107- trait_impls : BTreeMap < DefId , Vec < LocalDefId > > ,
108-
109106 modules : BTreeMap < LocalDefId , hir:: ModuleItems > ,
110107
111108 generator_kind : Option < hir:: GeneratorKind > ,
@@ -158,8 +155,6 @@ struct LoweringContext<'a, 'hir: 'a> {
158155
159156 current_module : LocalDefId ,
160157
161- type_def_lifetime_params : DefIdMap < usize > ,
162-
163158 current_hir_id_owner : ( LocalDefId , u32 ) ,
164159 item_local_id_counters : NodeMap < u32 > ,
165160 node_id_to_hir_id : IndexVec < NodeId , Option < hir:: HirId > > ,
@@ -171,7 +166,7 @@ struct LoweringContext<'a, 'hir: 'a> {
171166pub trait ResolverAstLowering {
172167 fn def_key ( & mut self , id : DefId ) -> DefKey ;
173168
174- fn item_generics_num_lifetimes ( & self , def : DefId , sess : & Session ) -> usize ;
169+ fn item_generics_num_lifetimes ( & self , def : DefId ) -> usize ;
175170
176171 fn legacy_const_generic_args ( & mut self , expr : & Expr ) -> Option < Vec < usize > > ;
177172
@@ -326,7 +321,6 @@ pub fn lower_crate<'a, 'hir>(
326321 arena,
327322 owners : IndexVec :: default ( ) ,
328323 bodies : BTreeMap :: new ( ) ,
329- trait_impls : BTreeMap :: new ( ) ,
330324 modules : BTreeMap :: new ( ) ,
331325 attrs : BTreeMap :: default ( ) ,
332326 catch_scopes : Vec :: new ( ) ,
@@ -335,7 +329,6 @@ pub fn lower_crate<'a, 'hir>(
335329 is_in_trait_impl : false ,
336330 is_in_dyn_type : false ,
337331 anonymous_lifetime_mode : AnonymousLifetimeMode :: PassThrough ,
338- type_def_lifetime_params : Default :: default ( ) ,
339332 current_module : CRATE_DEF_ID ,
340333 current_hir_id_owner : ( CRATE_DEF_ID , 0 ) ,
341334 item_local_id_counters : Default :: default ( ) ,
@@ -451,26 +444,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
451444 fn visit_item ( & mut self , item : & ' tcx Item ) {
452445 self . lctx . allocate_hir_id_counter ( item. id ) ;
453446
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) ;
474449 }
475450
476451 visit:: walk_item ( self , item) ;
@@ -485,23 +460,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
485460 self . lctx . allocate_hir_id_counter ( item. id ) ;
486461 visit:: walk_foreign_item ( self , item) ;
487462 }
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- }
505463 }
506464
507465 self . lower_node_id ( CRATE_NODE_ID ) ;
@@ -515,10 +473,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
515473 self . owners . ensure_contains_elem ( CRATE_DEF_ID , || None ) ;
516474 self . owners [ CRATE_DEF_ID ] = Some ( hir:: OwnerNode :: Crate ( module) ) ;
517475
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-
522476 let mut trait_map: FxHashMap < _ , FxHashMap < _ , _ > > = FxHashMap :: default ( ) ;
523477 for ( k, v) in self . resolver . take_trait_map ( ) . into_iter ( ) {
524478 if let Some ( Some ( hir_id) ) = self . node_id_to_hir_id . get ( k) {
@@ -551,10 +505,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
551505 let krate = hir:: Crate {
552506 owners : self . owners ,
553507 bodies : self . bodies ,
554- body_ids,
555- trait_impls : self . trait_impls ,
556508 modules : self . modules ,
557- proc_macros,
558509 trait_map,
559510 attrs : self . attrs ,
560511 } ;
@@ -2749,14 +2700,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
27492700 }
27502701}
27512702
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-
27602703/// Helper struct for delayed construction of GenericArgs.
27612704struct GenericArgsCtor < ' hir > {
27622705 args : SmallVec < [ hir:: GenericArg < ' hir > ; 4 ] > ,
0 commit comments