@@ -30,6 +30,7 @@ use rustc::hir::map::Node;
3030use rustc:: session:: Session ;
3131use rustc:: ty:: { self , TyCtxt } ;
3232
33+ use std:: collections:: HashSet ;
3334use std:: path:: Path ;
3435
3536use syntax:: ast:: { self , NodeId , PatKind , Attribute , CRATE_NODE_ID } ;
@@ -74,6 +75,7 @@ pub struct DumpVisitor<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> {
7475 // we only write one macro def per unique macro definition, and
7576 // one macro use per unique callsite span.
7677 // mac_defs: HashSet<Span>,
78+ macro_calls : HashSet < Span > ,
7779}
7880
7981impl < ' 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> {
8991 span : span_utils. clone ( ) ,
9092 cur_scope : CRATE_NODE_ID ,
9193 // mac_defs: HashSet::new(),
94+ macro_calls : HashSet :: new ( ) ,
9295 }
9396 }
9497
@@ -972,11 +975,19 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
972975 /// callsite spans to record macro definition and use data, using the
973976 /// mac_uses and mac_defs sets to prevent multiples.
974977 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+
975984 let data = match self . save_ctxt . get_macro_use_data ( span) {
976985 None => return ,
977986 Some ( data) => data,
978987 } ;
979988
989+ self . dumper . macro_use ( data) ;
990+
980991 // FIXME write the macro def
981992 // let mut hasher = DefaultHasher::new();
982993 // data.callee_span.hash(&mut hasher);
@@ -996,7 +1007,6 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> {
9961007 // }.lower(self.tcx));
9971008 // }
9981009 // }
999- self . dumper . macro_use ( data) ;
10001010 }
10011011
10021012 fn process_trait_item ( & mut self , trait_item : & ' l ast:: TraitItem , trait_id : DefId ) {
0 commit comments