+
+ /// Extract macro use and definition information from the AST node defined
+ /// by the given NodeId, using the expansion information from the node's
+ /// span.
+ ///
+ /// If the span is not macro-generated, do nothing, else use callee and
+ /// callsite spans to record macro definition and use data, using the
+ /// mac_uses and mac_defs sets to prevent multiples.
+ fn process_macro_use(&mut self, span: Span, id: NodeId) {
+ let data = match self.save_ctxt.get_macro_use_data(span, id) {
+ None => return,
+ Some(data) => data,
+ };
+ let mut hasher = SipHasher::new();
+ data.callee_span.hash(&mut hasher);
+ let hash = hasher.finish();
+ let qualname = format!("{}::{}", data.name, hash);
+ // Don't write macro definition for imported macros
+ if !self.mac_defs.contains(&data.callee_span)
+ && !data.imported {
+ self.mac_defs.insert(data.callee_span);
+ if let Some(sub_span) = self.span.span_for_macro_def_name(data.callee_span) {
+ self.fmt.macro_str(data.callee_span, sub_span,
+ data.name.clone(), qualname.clone());
+ }
+ }
+ if !self.mac_uses.contains(&data.span) {
+ self.mac_uses.insert(data.span);
+ if let Some(sub_span) = self.span.span_for_macro_use_name(data.span) {
+ self.fmt.macro_use_str(data.span, sub_span, data.name,
+ qualname, data.scope);
+ }
+ }
+ }