/// Collects all macro invocations reachable at this time in this AST fragment, and replace
/// them with "placeholders" - dummy macro invocations with specially crafted `NodeId`s.
/// Then call into resolver that builds a skeleton ("reduced graph") of the fragment and
/// prepares data for resolving paths of macro invocations.
Collects all macro invocations reachable at this time in this AST fragment, and replace
them with "placeholders" - dummy macro invocations with specially crafted `NodeId`s.
Then call into resolver that builds a skeleton ("reduced graph") of the fragment and
prepares data for resolving paths of macro invocations.
Collects all macro invocations reachable at this time in this AST fragment and replace them with " placeholders " - dummy macro invocations with specially crafted ` NodeId ` s . Then call into resolver that builds a skeleton ( " reduced graph " ) of the fragment and prepares data for resolving paths of macro invocations .
fn collect_invocations(
        &mut self,
        mut fragment: AstFragment,
        extra_placeholders: &[NodeId],
    ) -> (AstFragment, Vec<(Invocation, Option<Lrc<SyntaxExtension>>)>) {
        // Resolve `$crate`s in the fragment for pretty-printing.
        self.cx.resolver.resolve_dollar_crates();
        let mut invocations = {
            let mut collector = InvocationCollector {
                // Non-derive macro invocations cannot see the results of cfg expansion - they
                // will either be removed along with the item, or invoked before the cfg/cfg_attr
                // attribute is expanded. Therefore, we don't need to configure the tokens
                // Derive macros *can* see the results of cfg-expansion - they are handled
                // specially in `fully_expand_fragment`
                cfg: StripUnconfigured {
                    sess: &self.cx.sess,
                    features: self.cx.ecfg.features,
                    config_tokens: false,
                },
                cx: self.cx,
                invocations: Vec::new(),
                monotonic: self.monotonic,
            };
            fragment.mut_visit_with(&mut collector);
            fragment.add_placeholders(extra_placeholders);
            collector.invocations
        };
        if self.monotonic {
            self.cx
                .resolver
                .visit_ast_fragment_with_placeholders(self.cx.current_expansion.id, &fragment);
            if self.cx.sess.opts.debugging_opts.incremental_relative_spans {
                for (invoc, _) in invocations.iter_mut() {
                    let expn_id = invoc.expansion_data.id;
                    let parent_def = self.cx.resolver.invocation_parent(expn_id);
                    let span = match &mut invoc.kind {
                        InvocationKind::Bang { ref mut span, .. } => span,
                        InvocationKind::Attr { attr, .. } => &mut attr.span,
                        InvocationKind::Derive { path, .. } => &mut path.span,
                    };
                    *span = span.with_parent(Some(parent_def));
                }
            }
        }
        (fragment, invocations)
    }
fn collect_invocations ( & mut self , mut fragment : AstFragment , extra_placeholders : & [ NodeId ] , ) -> ( AstFragment , Vec < ( Invocation , Option < Lrc < SyntaxExtension > > ) > ) { // Resolve `$crate`s in the fragment for pretty-printing. self . cx . resolver . resolve_dollar_crates ( ) ; let mut invocations = { let mut collector = InvocationCollector { // Non-derive macro invocations cannot see the results of cfg expansion - they // will either be removed along with the item, or invoked before the cfg/cfg_attr // attribute is expanded. Therefore, we don't need to configure the tokens // Derive macros *can* see the results of cfg-expansion - they are handled // specially in `fully_expand_fragment` cfg : StripUnconfigured { sess : & self . cx . sess , features : self . cx . ecfg . features , config_tokens : false , } , cx : self . cx , invocations : Vec :: new ( ) , monotonic : self . monotonic , } ; fragment . mut_visit_with ( & mut collector ) ; fragment . add_placeholders ( extra_placeholders ) ; collector . invocations } ; if self . monotonic { self . cx . resolver . visit_ast_fragment_with_placeholders ( self . cx . current_expansion . id , & fragment ) ; if self . cx . sess . opts . debugging_opts . incremental_relative_spans { for ( invoc , _ ) in invocations . iter_mut ( ) { let expn_id = invoc . expansion_data . id ; let parent_def = self . cx . resolver . invocation_parent ( expn_id ) ; let span = match & mut invoc . kind { InvocationKind :: Bang { ref mut span , .. } => span , InvocationKind :: Attr { attr , .. } => & mut attr . span , InvocationKind :: Derive { path , .. } => & mut path . span , } ; * span = span . with_parent ( Some ( parent_def ) ) ; } } } ( fragment , invocations ) }
Collects all macro invocations reachable at this time in this AST fragment, and replace
them with "placeholders" - dummy macro invocations with specially crafted `NodeId`s.
Collects all macro invocations reachable at this time in this AST fragment and replace them with " placeholders " - dummy macro invocations with specially crafted ` NodeId ` s .
&mut self
fragment
AstFragment
extra_placeholders
&[NodeId]