@@ -23,7 +23,7 @@ use rustc_data_structures::fx::FxHashSet;
23
23
use std:: path:: Path ;
24
24
use std:: env;
25
25
26
- use syntax:: ast:: { self , Attribute , NodeId , PatKind , CRATE_NODE_ID } ;
26
+ use syntax:: ast:: { self , Attribute , NodeId , PatKind } ;
27
27
use syntax:: parse:: token;
28
28
use syntax:: visit:: { self , Visitor } ;
29
29
use syntax:: print:: pprust:: {
@@ -75,15 +75,13 @@ macro_rules! access_from_vis {
75
75
} ;
76
76
}
77
77
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 > ,
80
80
tcx : TyCtxt < ' tcx > ,
81
- dumper : & ' ll mut Dumper ,
81
+ dumper : Dumper ,
82
82
83
83
span : SpanUtils < ' l > ,
84
84
85
- cur_scope : NodeId ,
86
-
87
85
// Set of macro definition (callee) spans, and the set
88
86
// of macro use (callsite) spans. We store these to ensure
89
87
// we only write one macro def per unique macro definition, and
@@ -92,36 +90,29 @@ pub struct DumpVisitor<'l, 'tcx, 'll> {
92
90
// macro_calls: FxHashSet<Span>,
93
91
}
94
92
95
- impl < ' l , ' tcx , ' ll > DumpVisitor < ' l , ' tcx , ' ll > {
93
+ impl < ' l , ' tcx > DumpVisitor < ' l , ' tcx > {
96
94
pub fn new (
97
95
save_ctxt : SaveContext < ' l , ' tcx > ,
98
- dumper : & ' ll mut Dumper ,
99
- ) -> DumpVisitor < ' l , ' tcx , ' ll > {
96
+ ) -> DumpVisitor < ' l , ' tcx > {
100
97
let span_utils = SpanUtils :: new ( & save_ctxt. tcx . sess ) ;
98
+ let dumper = Dumper :: new ( save_ctxt. config . clone ( ) ) ;
101
99
DumpVisitor {
102
100
tcx : save_ctxt. tcx ,
103
101
save_ctxt,
104
102
dumper,
105
103
span : span_utils,
106
- cur_scope : CRATE_NODE_ID ,
107
104
// mac_defs: FxHashSet::default(),
108
105
// macro_calls: FxHashSet::default(),
109
106
}
110
107
}
111
108
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 ( )
120
111
}
121
112
122
113
fn nest_tables < F > ( & mut self , item_id : NodeId , f : F )
123
114
where
124
- F : FnOnce ( & mut DumpVisitor < ' l , ' tcx , ' ll > ) ,
115
+ F : FnOnce ( & mut Self ) ,
125
116
{
126
117
let item_def_id = self . tcx . hir ( ) . local_def_id_from_node_id ( item_id) ;
127
118
if self . tcx . has_typeck_tables ( item_def_id) {
@@ -320,7 +311,7 @@ impl<'l, 'tcx, 'll> DumpVisitor<'l, 'tcx, 'll> {
320
311
321
312
// walk the fn body
322
313
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) ) ;
324
315
}
325
316
}
326
317
@@ -405,7 +396,7 @@ impl<'l, 'tcx, 'll> DumpVisitor<'l, 'tcx, 'll> {
405
396
self . visit_ty ( & ret_ty) ;
406
397
}
407
398
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) ) ;
409
400
}
410
401
411
402
fn process_static_or_const_item (
@@ -1311,7 +1302,7 @@ impl<'l, 'tcx, 'll> DumpVisitor<'l, 'tcx, 'll> {
1311
1302
}
1312
1303
}
1313
1304
1314
- impl < ' l , ' tcx , ' ll > Visitor < ' l > for DumpVisitor < ' l , ' tcx , ' ll > {
1305
+ impl < ' l , ' tcx > Visitor < ' l > for DumpVisitor < ' l , ' tcx > {
1315
1306
fn visit_mod ( & mut self , m : & ' l ast:: Mod , span : Span , attrs : & [ ast:: Attribute ] , id : NodeId ) {
1316
1307
// Since we handle explicit modules ourselves in visit_item, this should
1317
1308
// 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> {
1349
1340
attributes : lower_attributes ( attrs. to_owned ( ) , & self . save_ctxt ) ,
1350
1341
} ,
1351
1342
) ;
1352
- self . nest_scope ( id , |v| visit:: walk_mod ( v , m) ) ;
1343
+ visit:: walk_mod ( self , m) ;
1353
1344
}
1354
1345
1355
1346
fn visit_item ( & mut self , item : & ' l ast:: Item ) {
@@ -1404,7 +1395,7 @@ impl<'l, 'tcx, 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll> {
1404
1395
}
1405
1396
Mod ( ref m) => {
1406
1397
self . process_mod ( item) ;
1407
- self . nest_scope ( item . id , |v| visit:: walk_mod ( v , m) ) ;
1398
+ visit:: walk_mod ( self , m) ;
1408
1399
}
1409
1400
Ty ( ref ty, ref ty_params) => {
1410
1401
let qualname = format ! ( "::{}" ,
@@ -1570,7 +1561,7 @@ impl<'l, 'tcx, 'll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll> {
1570
1561
// walk the body
1571
1562
self . nest_tables ( ex. id , |v| {
1572
1563
v. process_formals ( & decl. inputs , & id) ;
1573
- v. nest_scope ( ex . id , |v| v . visit_expr ( body) )
1564
+ v. visit_expr ( body)
1574
1565
} ) ;
1575
1566
}
1576
1567
ast:: ExprKind :: ForLoop ( ref pattern, ref subexpression, ref block, _) => {
0 commit comments