@@ -30,6 +30,7 @@ use rustc::hir::map::Node;
30
30
use rustc:: session:: Session ;
31
31
use rustc:: ty:: { self , TyCtxt } ;
32
32
33
+ use std:: collections:: HashSet ;
33
34
use std:: path:: Path ;
34
35
35
36
use syntax:: ast:: { self , NodeId , PatKind , Attribute , CRATE_NODE_ID } ;
@@ -74,6 +75,7 @@ pub struct DumpVisitor<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> {
74
75
// we only write one macro def per unique macro definition, and
75
76
// one macro use per unique callsite span.
76
77
// mac_defs: HashSet<Span>,
78
+ macro_calls : HashSet < Span > ,
77
79
}
78
80
79
81
impl < ' l , ' tcx : ' l , ' ll , O : DumpOutput + ' ll > DumpVisitor < ' l , ' tcx , ' ll , O > {
@@ -89,6 +91,7 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
89
91
span : span_utils. clone ( ) ,
90
92
cur_scope : CRATE_NODE_ID ,
91
93
// mac_defs: HashSet::new(),
94
+ macro_calls : HashSet :: new ( ) ,
92
95
}
93
96
}
94
97
@@ -972,11 +975,19 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
972
975
/// callsite spans to record macro definition and use data, using the
973
976
/// mac_uses and mac_defs sets to prevent multiples.
974
977
fn process_macro_use ( & mut self , span : Span ) {
978
+ let source_span = span. source_callsite ( ) ;
979
+ if self . macro_calls . contains ( & source_span) {
980
+ return ;
981
+ }
982
+ self . macro_calls . insert ( source_span) ;
983
+
975
984
let data = match self . save_ctxt . get_macro_use_data ( span) {
976
985
None => return ,
977
986
Some ( data) => data,
978
987
} ;
979
988
989
+ self . dumper . macro_use ( data) ;
990
+
980
991
// FIXME write the macro def
981
992
// let mut hasher = DefaultHasher::new();
982
993
// data.callee_span.hash(&mut hasher);
@@ -996,7 +1007,6 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
996
1007
// }.lower(self.tcx));
997
1008
// }
998
1009
// }
999
- self . dumper . macro_use ( data) ;
1000
1010
}
1001
1011
1002
1012
fn process_trait_item ( & mut self , trait_item : & ' l ast:: TraitItem , trait_id : DefId ) {
0 commit comments