@@ -23,7 +23,7 @@ use rustc_data_structures::fx::FxHashSet;
2323use std:: path:: Path ;
2424use std:: env;
2525
26- use syntax:: ast:: { self , Attribute , NodeId , PatKind , CRATE_NODE_ID } ;
26+ use syntax:: ast:: { self , Attribute , NodeId , PatKind } ;
2727use syntax:: parse:: token;
2828use syntax:: visit:: { self , Visitor } ;
2929use syntax:: print:: pprust:: {
@@ -75,15 +75,13 @@ macro_rules! access_from_vis {
7575 } ;
7676}
7777
78- pub struct DumpVisitor < ' l , ' tcx , ' ll > {
79- save_ctxt : SaveContext < ' l , ' tcx > ,
78+ pub struct DumpVisitor < ' l , ' tcx > {
79+ pub save_ctxt : SaveContext < ' l , ' tcx > ,
8080 tcx : TyCtxt < ' tcx > ,
81- dumper : & ' ll mut Dumper ,
81+ dumper : Dumper ,
8282
8383 span : SpanUtils < ' l > ,
8484
85- cur_scope : NodeId ,
86-
8785 // Set of macro definition (callee) spans, and the set
8886 // of macro use (callsite) spans. We store these to ensure
8987 // we only write one macro def per unique macro definition, and
@@ -92,36 +90,29 @@ pub struct DumpVisitor<'l, 'tcx, 'll> {
9290 // macro_calls: FxHashSet<Span>,
9391}
9492
95- impl < ' l , ' tcx , ' ll > DumpVisitor < ' l , ' tcx , ' ll > {
93+ impl < ' l , ' tcx > DumpVisitor < ' l , ' tcx > {
9694 pub fn new (
9795 save_ctxt : SaveContext < ' l , ' tcx > ,
98- dumper : & ' ll mut Dumper ,
99- ) -> DumpVisitor < ' l , ' tcx , ' ll > {
96+ ) -> DumpVisitor < ' l , ' tcx > {
10097 let span_utils = SpanUtils :: new ( & save_ctxt. tcx . sess ) ;
98+ let dumper = Dumper :: new ( save_ctxt. config . clone ( ) ) ;
10199 DumpVisitor {
102100 tcx : save_ctxt. tcx ,
103101 save_ctxt,
104102 dumper,
105103 span : span_utils,
106- cur_scope : CRATE_NODE_ID ,
107104 // mac_defs: FxHashSet::default(),
108105 // macro_calls: FxHashSet::default(),
109106 }
110107 }
111108
112- fn nest_scope < F > ( & mut self , scope_id : NodeId , f : F )
113- where
114- F : FnOnce ( & mut DumpVisitor < ' l , ' tcx , ' ll > ) ,
115- {
116- let parent_scope = self . cur_scope ;
117- self . cur_scope = scope_id;
118- f ( self ) ;
119- self . cur_scope = parent_scope;
109+ pub fn analysis ( & self ) -> & rls_data:: Analysis {
110+ self . dumper . analysis ( )
120111 }
121112
122113 fn nest_tables < F > ( & mut self , item_id : NodeId , f : F )
123114 where
124- F : FnOnce ( & mut DumpVisitor < ' l , ' tcx , ' ll > ) ,
115+ F : FnOnce ( & mut Self ) ,
125116 {
126117 let item_def_id = self . tcx . hir ( ) . local_def_id_from_node_id ( item_id) ;
127118 if self . tcx . has_typeck_tables ( item_def_id) {
@@ -320,7 +311,7 @@ impl<'l, 'tcx, 'll> DumpVisitor<'l, 'tcx, 'll> {
320311
321312 // walk the fn body
322313 if let Some ( body) = body {
323- self . nest_tables ( id, |v| v. nest_scope ( id , |v| v . visit_block ( body) ) ) ;
314+ self . nest_tables ( id, |v| v. visit_block ( body) ) ;
324315 }
325316 }
326317
@@ -405,7 +396,7 @@ impl<'l, 'tcx, 'll> DumpVisitor<'l, 'tcx, 'll> {
405396 self . visit_ty ( & ret_ty) ;
406397 }
407398
408- self . nest_tables ( item. id , |v| v. nest_scope ( item . id , |v| v . visit_block ( & body) ) ) ;
399+ self . nest_tables ( item. id , |v| v. visit_block ( & body) ) ;
409400 }
410401
411402 fn process_static_or_const_item (
@@ -1311,7 +1302,7 @@ impl<'l, 'tcx, 'll> DumpVisitor<'l, 'tcx, 'll> {
13111302 }
13121303}
13131304
1314- impl < ' l , ' tcx , ' ll > Visitor < ' l > for DumpVisitor < ' l , ' tcx , ' ll > {
1305+ impl < ' l , ' tcx > Visitor < ' l > for DumpVisitor < ' l , ' tcx > {
13151306 fn visit_mod ( & mut self , m : & ' l ast:: Mod , span : Span , attrs : & [ ast:: Attribute ] , id : NodeId ) {
13161307 // Since we handle explicit modules ourselves in visit_item, this should
13171308 // only get called for the root module of a crate.
@@ -1349,7 +1340,7 @@ impl<'l, 'tcx, 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll> {
13491340 attributes : lower_attributes ( attrs. to_owned ( ) , & self . save_ctxt ) ,
13501341 } ,
13511342 ) ;
1352- self . nest_scope ( id , |v| visit:: walk_mod ( v , m) ) ;
1343+ visit:: walk_mod ( self , m) ;
13531344 }
13541345
13551346 fn visit_item ( & mut self , item : & ' l ast:: Item ) {
@@ -1404,7 +1395,7 @@ impl<'l, 'tcx, 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll> {
14041395 }
14051396 Mod ( ref m) => {
14061397 self . process_mod ( item) ;
1407- self . nest_scope ( item . id , |v| visit:: walk_mod ( v , m) ) ;
1398+ visit:: walk_mod ( self , m) ;
14081399 }
14091400 Ty ( ref ty, ref ty_params) => {
14101401 let qualname = format ! ( "::{}" ,
@@ -1570,7 +1561,7 @@ impl<'l, 'tcx, 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll> {
15701561 // walk the body
15711562 self . nest_tables ( ex. id , |v| {
15721563 v. process_formals ( & decl. inputs , & id) ;
1573- v. nest_scope ( ex . id , |v| v . visit_expr ( body) )
1564+ v. visit_expr ( body)
15741565 } ) ;
15751566 }
15761567 ast:: ExprKind :: ForLoop ( ref pattern, ref subexpression, ref block, _) => {
0 commit comments