fn expand_mac_invoc<T, F, G>(mac: ast::Mac,
                             span: codemap::Span,
                             parse_thunk: F,
                             mark_thunk: G,
                             fld: &mut MacroExpander)
                             -> Option<T> where
    F: for<'a> FnOnce(Box<MacResult+'a>) -> Option<T>,
    G: FnOnce(T, Mrk) -> T,
{
    match mac.node {
        // it would almost certainly be cleaner to pass the whole
        // macro invocation in, rather than pulling it apart and
        // marking the tts and the ctxt separately. This also goes
        // for the other three macro invocation chunks of code
        // in this file.
        // Token-tree macros:
        MacInvocTT(pth, tts, _) => {
            if pth.segments.len() > 1 {
                fld.cx.span_err(pth.span,
                                "expected macro name without module \
                                separators");
                // let compilation continue
                return None;
            }
            let extname = pth.segments[0].identifier.name;
            match fld.cx.syntax_env.find(&extname) {
                None => {
                    fld.cx.span_err(
                        pth.span,
                        &format!("macro undefined: '{}!'",
                                &extname));

                    // let compilation continue
                    None
                }
                Some(rc) => match *rc {
                    NormalTT(ref expandfun, exp_span, allow_internal_unstable) => {
                        fld.cx.bt_push(ExpnInfo {
                                call_site: span,
                                callee: NameAndSpan {
                                    format: MacroBang(extname),
                                    span: exp_span,
                                    allow_internal_unstable: allow_internal_unstable,
                                },
                            });
                        let fm = fresh_mark();
                        let marked_before = mark_tts(&tts[..], fm);

                        // The span that we pass to the expanders we want to
                        // be the root of the call stack. That's the most
                        // relevant span and it's the actual invocation of
                        // the macro.
                        let mac_span = fld.cx.original_span();

                        let opt_parsed = {
                            let expanded = expandfun.expand(fld.cx,
                                                            mac_span,
                                                            &marked_before[..]);
                            parse_thunk(expanded)
                        };
                        let parsed = match opt_parsed {
                            Some(e) => e,
                            None => {
                                fld.cx.span_err(
                                    pth.span,
                                    &format!("non-expression macro in expression position: {}",
                                            extname
                                            ));
                                return None;
                            }
                        };
                        Some(mark_thunk(parsed,fm))
                    }
                    _ => {
                        fld.cx.span_err(
                            pth.span,
                            &format!("'{}' is not a tt-style macro",
                                    extname));
                        None
                    }
                }
            }
        }
    }
}
/// Expand a (not-ident-style) macro invocation. Returns the result
/// of expansion and the mark which must be applied to the result.
/// Our current interface doesn't allow us to apply the mark to the
/// result until after calling make_expr, make_items, etc.
Expand a (not-ident-style) macro invocation. Returns the result
of expansion and the mark which must be applied to the result.
Our current interface doesn't allow us to apply the mark to the
result until after calling make_expr, make_items, etc.
Expand a ( not - ident - style ) macro invocation . Returns the result of expansion and the mark which must be applied to the result . Our current interface doesn ' t allow us to apply the mark to the result until after calling make_expr make_items etc .
fn expand_mac_invoc<T, F, G>(mac: ast::Mac,
                             span: codemap::Span,
                             parse_thunk: F,
                             mark_thunk: G,
                             fld: &mut MacroExpander)
                             -> Option<T> where
    F: for<'a> FnOnce(Box<MacResult+'a>) -> Option<T>,
    G: FnOnce(T, Mrk) -> T,
{
    match mac.node {
        // it would almost certainly be cleaner to pass the whole
        // macro invocation in, rather than pulling it apart and
        // marking the tts and the ctxt separately. This also goes
        // for the other three macro invocation chunks of code
        // in this file.
        // Token-tree macros:
        MacInvocTT(pth, tts, _) => {
            if pth.segments.len() > 1 {
                fld.cx.span_err(pth.span,
                                "expected macro name without module \
                                separators");
                // let compilation continue
                return None;
            }
            let extname = pth.segments[0].identifier.name;
            match fld.cx.syntax_env.find(&extname) {
                None => {
                    fld.cx.span_err(
                        pth.span,
                        &format!("macro undefined: '{}!'",
                                &extname));
                    // let compilation continue
                    None
                }
                Some(rc) => match *rc {
                    NormalTT(ref expandfun, exp_span, allow_internal_unstable) => {
                        fld.cx.bt_push(ExpnInfo {
                                call_site: span,
                                callee: NameAndSpan {
                                    format: MacroBang(extname),
                                    span: exp_span,
                                    allow_internal_unstable: allow_internal_unstable,
                                },
                            });
                        let fm = fresh_mark();
                        let marked_before = mark_tts(&tts[..], fm);
                        // The span that we pass to the expanders we want to
                        // be the root of the call stack. That's the most
                        // relevant span and it's the actual invocation of
                        // the macro.
                        let mac_span = fld.cx.original_span();
                        let opt_parsed = {
                            let expanded = expandfun.expand(fld.cx,
                                                            mac_span,
                                                            &marked_before[..]);
                            parse_thunk(expanded)
                        };
                        let parsed = match opt_parsed {
                            Some(e) => e,
                            None => {
                                fld.cx.span_err(
                                    pth.span,
                                    &format!("non-expression macro in expression position: {}",
                                            extname
                                            ));
                                return None;
                            }
                        };
                        Some(mark_thunk(parsed,fm))
                    }
                    _ => {
                        fld.cx.span_err(
                            pth.span,
                            &format!("'{}' is not a tt-style macro",
                                    extname));
                        None
                    }
                }
            }
        }
    }
}
fn expand_mac_invoc < T , F , G > ( mac : ast :: Mac , span : codemap :: Span , parse_thunk : F , mark_thunk : G , fld : & mut MacroExpander ) -> Option < T > where F : for < ' a > FnOnce ( Box < MacResult + ' a > ) -> Option < T > , G : FnOnce ( T , Mrk ) -> T , { match mac . node { // it would almost certainly be cleaner to pass the whole // macro invocation in, rather than pulling it apart and // marking the tts and the ctxt separately. This also goes // for the other three macro invocation chunks of code // in this file. // Token-tree macros: MacInvocTT ( pth , tts , _ ) => { if pth . segments . len ( ) > 1 { fld . cx . span_err ( pth . span , " \
 " ) ; // let compilation continue return None ; } let extname = pth . segments [ 0 ] . identifier . name ; match fld . cx . syntax_env . find ( & extname ) { None => { fld . cx . span_err ( pth . span , & format ! ( " " extname ) ) ; // let compilation continue None } Some ( rc ) => match * rc { NormalTT ( ref expandfun , exp_span , allow_internal_unstable ) => { fld . cx . bt_push ( ExpnInfo { call_site : span , callee : NameAndSpan { format : MacroBang ( extname ) , span : exp_span , allow_internal_unstable : allow_internal_unstable , } , } ) ; let fm = fresh_mark ( ) ; let marked_before = mark_tts ( & tts [ .. ] , fm ) ; // The span that we pass to the expanders we want to // be the root of the call stack. That's the most // relevant span and it's the actual invocation of // the macro. let mac_span = fld . cx . original_span ( ) ; let opt_parsed = { let expanded = expandfun . expand ( fld . cx , mac_span , & marked_before [ .. ] ) ; parse_thunk ( expanded ) } ; let parsed = match opt_parsed { Some ( e ) => e , None => { fld . cx . span_err ( pth . span , & format ! ( " " extname ) ) ; return None ; } } ; Some ( mark_thunk ( parsed , fm ) ) } _ => { fld . cx . span_err ( pth . span , & format ! ( " " extname ) ) ; None } } } } } }
Expand a (not-ident-style) macro invocation.
Expand a ( not - ident - style ) macro invocation .
mac
ast::Mac
span
codemap::Span
parse_thunk
F
mark_thunk
G
fld
&mut MacroExpander
mac
ast::Mac
span
codemap::Span
parse_thunk
F
mark_thunk
G
fld
&mut MacroExpander