syntex_syntax 0.7.0

Export of libsyntax for code generation
b0VIM 7.4��tU��yericktErick-Tryzelaar-MBP.local~erickt/projects/rust/rust-syntex/syntex_syntax/src/ext/expand.rsutf-8
3210#"! Utph[i`�[$U\�R0`�T�`6	c�
f�c_c�
k%l�i�ReW�bKpF�ad&�h�{XU��M)(�
�
�
g
S
J
;


���xTJ=2��������<�
�
�

M
"
�	�	�	�	�	�	t	/	���G����W9'�����U-�����l����o4!����p]\���cTS7��                let pat_under = fld.cx.pat_wild(span);            let break_arm = {            // `_ => break`            };                fld.cx.arm(pat.span, vec![pat], body_expr)                let body_expr = fld.cx.expr_block(body);            let pat_arm = {            // `<pat> => <body>`            push_compiler_expansion(fld, span, "while let expansion");            //   }            //     }            //       _ => break            //       <pat> => <body>,            //     match <expr> {            //   [opt_ident]: loop {            //            // to:        ast::ExprWhileLet(pat, expr, body, opt_ident) => {        // From: `[opt_ident]: while let <pat> = <expr> <body>`        // Desugar ExprWhileLet        }            fld.cx.expr(span, ast::ExprWhile(cond, body, opt_ident))            let (body, opt_ident) = expand_loop_block(body, opt_ident, fld);            let cond = fld.fold_expr(cond);        ast::ExprWhile(cond, body, opt_ident) => {        }            })                span: fld.new_span(span),                node: e.node,                id: ast::DUMMY_NODE_ID,            fully_expanded.map(|e| ast::Expr {            fld.cx.bt_pop();            let fully_expanded = fld.fold_expr(expanded_expr);            //            // Keep going, outside-in.            };                }                    return e;                    // return DummyResult::raw_expr(span);                    // Ignore unknown macros.                None => {                Some(expr) => expr,                                                       mark_expr, fld) {                                                       |r| r.make_expr(),            let expanded_expr = match expand_mac_invoc(mac.clone(), span,        ast::ExprMac(mac, _) => {        // entry-point for all syntax extensions.        // expr_mac should really be expr_ext or something; it's the    e.clone().and_then(|ast::Expr {id, node, span}| match node {    }        });            },                span: None,                allow_internal_unstable: true,                format: CompilerExpansion,                name: expansion_desc.to_string(),            callee: NameAndSpan {            call_site: span,        fld.cx.bt_push(ExpnInfo {    fn push_compiler_expansion(fld: &mut MacroExpander, span: Span, expansion_desc: &str) {pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {use std_inject;use visit::Visitor;use visit;use util::small_vector::SmallVector;use ptr::P;use parse::token;use parse::token::{fresh_mark, fresh_name, intern};use parse;use fold::*;use fold;use feature_gate::{self, Features};use ext::base::*;use codemap::{Span, Spanned, ExpnInfo, NameAndSpan, MacroBang, MacroAttribute, CompilerExpansion};use codemap;use attr::AttrMetaMethods;use attr;use ext::build::AstBuilder;use ext::mtwt;use ast;use ast::TokenTree;use ast::{StmtExpr, StmtSemi};use ast::{ItemMac, MacStmtWithSemicolon, Mrk, Stmt, StmtDecl, StmtMac};use ast::{Local, Ident, MacInvocTT};use ast::{Block, Crate, DeclLocal, ExprMac, PatMac};// except according to those terms.// option. This file may not be copied, modified, or distributed// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or//// http://rust-lang.org/COPYRIGHT.// file at the top-level directory of this distribution and at// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHTad�)F��n*�}B�
�
d
!
���g\VUI4��f`_�
m
a
C
�	�	m				���p@��q6�D>=��O��}B��1+)(}    }        assert_eq!(resolved, [f_ident.name,Name(16),int_ident.name,Name(16),x_name,x_name]);        let x_name = x_ident.name;        let resolved : Vec<ast::Name> = idents.iter().map(|id| mtwt::resolve(*id)).collect();        let idents = crate_idents(&renamed_crate);        let renamed_crate = renamer.fold_crate(the_crate);        let mut renamer = PatIdentRenamer{renames: &renames};        let renames = vec!((x_ident,Name(16)));        let int_ident = token::str_to_ident("i32");        let x_ident = token::str_to_ident("x");        let f_ident = token::str_to_ident("f");        let the_crate = string_to_crate("fn f(x: i32){let x = x; x}".to_string());    fn pat_ident_renamer_test () {    #[test]    // test the PatIdentRenamer; only PatIdents get renamed    }        assert_eq!(resolved, [f_ident.name,Name(16),int_ident.name,Name(16),Name(16),Name(16)]);        let resolved : Vec<ast::Name> = idents.iter().map(|id| mtwt::resolve(*id)).collect();        let idents = crate_idents(&renamed_crate);        let renamed_crate = renamer.fold_crate(the_crate);        let mut renamer = IdentRenamer{renames: &renames};        let renames = vec!((x_ident,Name(16)));        let int_ident = token::str_to_ident("i32");        let x_ident = token::str_to_ident("x");        let f_ident = token::str_to_ident("f");        let the_crate = string_to_crate("fn f(x: i32){let x = x; x}".to_string());    fn ident_renamer_test () {    #[test]    // test the IdentRenamer directly    }        assert_eq!(idents, strs_to_idents(vec!("a","b","None","i","i","z","y")));        let idents = crate_bindings(&the_crate);        match 34 {None => 3, Some(i) | i => j, Foo{k:z,l:y} => \"banana\"}} }".to_string());        let the_crate = string_to_crate("fn main (a: i32) -> i32 {|b| {    fn crate_bindings_test(){    #[test]    // it's the name of a 0-ary variant, and that 'i' appears twice in succession.    // 'None' is listed as an identifier pattern because we don't yet know that    // test the list of identifier patterns gathered by the visitor. Note that    }        assert_eq!(idents, strs_to_idents(vec!("a","c","b","d")));        let idents = pattern_bindings(&*pat);            "(a,Foo{x:c @ (b,9),y:Bar(4,d)})".to_string());        let pat = string_to_pat(    fn pat_idents(){    #[test]    }        };                       resolved_binding);            assert_eq!(mtwt::resolve(v.segments[0].identifier),            }                mtwt::with_sctable(|x| mtwt::display_sctable(x));                         mtwt::resolve(v.segments[0].identifier));                println!("resolves to: {}",                println!("varref: {}", v.segments[0].identifier);                println!("resolves to: {}", resolved_binding);                println!("binding: {}", cxbind);                println!("this is xx varref \\# {}", idx);                println!("uh oh, xx binding didn't match xx varref:");            if mtwt::resolve(v.segments[0].identifier) != resolved_binding {        }).enumerate() {            && "xx" == &*token::get_ident(p.segments[0].identifier)            p.segments.len() == 1        for (idx,v) in varrefs.iter().filter(|p| {        // the xx binding should bind all of the xx varrefs:ad"�`��L
���kj�
�
t
0

�y9��|{M$�
�
�
o

�	�	�	p	B	A	����uH���yk`_A:9��}bXF��xngfQGED2���X#��L-,���zM3����               // Ignore unknown macros.        None => {        }            new_items            fld.cx.bt_pop();            }).collect();                fld.fold_stmt(s).into_iter()            let new_items = stmts.into_iter().flat_map(|s| {            // Keep going, outside-in.        Some(stmts) => {    let mut fully_expanded = match maybe_new_items {                         fld);                         |stmts, mark| stmts.move_map(|m| mark_stmt(m, mark)),                         |r| r.make_stmts(),        expand_mac_invoc(mac.and_then(|m| m), stmt.span,    let maybe_new_items =    };        _ => return expand_non_macro_stmt(stmt, fld)        StmtMac(mac, style) => (mac, style),    let (mac, style) = match stmt.clone().node {    let stmt = stmt.and_then(|stmt| stmt);fn expand_stmt(stmt: P<Stmt>, fld: &mut MacroExpander) -> SmallVector<P<Stmt>> {/// Expand a stmt}    items    fld.cx.bt_pop();    };        }            return SmallVector::zero();                                    &extnamestr));                            &format!("non-item macro in item position: {}",            fld.cx.span_err(path_span,        None => {        }                .collect()                .flat_map(|i| fld.fold_item(i).into_iter())                .map(|i| mark_item(i, fm))            items.into_iter()        Some(items) => {    let items = match items {    };        expanded.make_items()        };            }                }                    return SmallVector::zero();                                            &extnamestr));                                    &format!("{}! is not legal in item position",                    fld.cx.span_err(it.span,                _ => {                }                    return SmallVector::zero();                    fld.cx.bt_pop();                    // macro_rules! has a side effect but expands to nothing.                    fld.cx.insert_macro(def);                    };                        body: tts,                        allow_internal_unstable: allow_internal_unstable,                        use_locally: true,                        export: attr::contains_name(&it.attrs, "macro_export"),                        imported_from: None,                        span: it.span,                        id: ast::DUMMY_NODE_ID,                        attrs: it.attrs.clone(),                        ident: it.ident,                    let def = ast::MacroDef {                    }                            feature_gate::EXPLAIN_ALLOW_INTERNAL_UNSTABLE)                            it.span,                            "allow_internal_unstable",                            &fld.cx.parse_sess.span_diagnostic,                        feature_gate::emit_feature_err(                    if allow_internal_unstable && !fld.cx.ecfg.enable_allow_internal_unstable() {                    // etc.)                    // detected (including nested macro definitions                    // ensure any #[allow_internal_unstable]s are                                                                      "allow_internal_unstable");                    let allow_internal_unstable = attr::contains_name(&it.attrs,                    // DON'T mark before expansion.                    });                        }                            allow_internal_unstable: false,                            // the macro it creates allows it)                            // unstable (this is orthogonal to whether                            // `macro_rules!` doesn't directly allow                            span: None,ad�[��yxR!���b&�
{
^
K
A
@
#
����kG�����bF
�
�
�
�
a
:
#
�	�	�	C		��i6���{H/���^/����gQ?*����d���tT!���;���                                                }));                                                    contains_else_clause: contains_else_clause,                                                ast::MatchSource::IfLetDesugar {                                         ast::ExprMatch(expr, arms,            let match_expr = fld.cx.expr(span,            arms.push(else_arm);            arms.extend(else_if_arms.into_iter());            arms.push(pat_arm);            let mut arms = Vec::with_capacity(else_if_arms.len() + 2);            };                fld.cx.arm(span, vec![pat_under], else_expr)                let else_expr = elseopt.unwrap_or_else(|| fld.cx.expr_tuple(span, vec![]));                let pat_under = fld.cx.pat_wild(span);            let else_arm = {            // `_ => [<elseopt> | ()]`            let contains_else_clause = elseopt.is_some();            };                arms                }                    }                        }                            break;                            elseopt = None;                        None => {                        }                            break;                            elseopt = Some(e);                        Some((e, false)) => {                        }                            elseopt = Some(e);                        Some((e, true)) => {                    match elseopt_continue {                    }));                        _ => Some((P(els), false))                        }                            elseopt.map(|elseopt| (elseopt, true))                            });                                body: fld.cx.expr_block(then)                                guard: Some(cond),                                pats: vec![pat_under],                                attrs: vec![],                            arms.push(ast::Arm {                            let pat_under = fld.cx.pat_wild(span);                        ast::ExprIf(cond, then, elseopt) => {                        // else if                        .and_then(|els| els.and_then(|els| match els.node {                    let elseopt_continue = elseopt                loop {                let mut arms = vec![];            let else_if_arms = {            // `[_ if <elseopt_if_cond> => <elseopt_if_body>,]`            };                fld.cx.arm(pat.span, vec![pat], body_expr)                let body_expr = fld.cx.expr_block(body);            let pat_arm = {            // `<pat> => <body>`            push_compiler_expansion(fld, span, "if let expansion");            //   }            //     _ => [<elseopt> | ()]            //     [_ if <elseopt_if_cond> => <elseopt_if_body>,]            //     <pat> => <body>,            //   match <expr> {            //            // to:        ast::ExprIfLet(pat, expr, body, mut elseopt) => {        // From: `if let <pat> = <expr> <body> [<elseopt>]`        // Desugar ExprIfLet        }            result            fld.cx.bt_pop();            let result = fld.cx.expr(span, ast::ExprLoop(loop_block, opt_ident));            let (loop_block, opt_ident) = expand_loop_block(loop_block, opt_ident, fld);            let loop_block = fld.cx.block_expr(match_expr);            // `[opt_ident]: loop { ... }`                                    ast::ExprMatch(expr, arms, ast::MatchSource::WhileLetDesugar));            let match_expr = fld.cx.expr(span,            let arms = vec![pat_arm, break_arm];            // `match <expr> { ... }`            };                fld.cx.arm(span, vec![pat_under], break_expr)                let break_expr = fld.cx.expr_break(span);ad�`�����L��[$�
�
�
{
K

����eS7&����g�
�
�
�
e
+

	
�	�	~	S		��gN7!������c76���['�����f(��a` ����7('���{F���                        fld.cx.ident_of("next"),                        fld.cx.ident_of("Iterator"),                        fld.cx.ident_of("iter"),                        fld.cx.ident_of_std("core"),                    let strs = vec![                let next_path = {            let match_expr = {            // `match ::std::iter::Iterator::next(&mut iter) { ... }`            };                fld.cx.arm(span, vec![fld.cx.pat_none(span)], break_expr)                let break_expr = fld.cx.expr_break(span);            let break_arm = {            // `::std::option::Option::None => break`            };                fld.cx.arm(pat_span, vec![some_pat], body_expr)                let some_pat = fld.cx.pat_some(pat_span, pat);                let pat = noop_fold_pat(pat, fld);                let body_expr = fld.cx.expr_block(body);            let pat_arm = {            // `::std::option::Option::Some(<pat>) => <body>`            let pat_span = fld.new_span(pat.span);            };                rename_fld.fold_ident(ident)                let mut rename_fld = IdentRenamer{ renames: &mut rename_list };                let mut rename_list = vec![rename];                let rename = (ident, new_ident);                let new_ident = fresh_name(&ident);                let ident = fld.cx.ident_of("iter");            let iter = {            // create an hygienic ident            let head = fld.fold_expr(head);            // expand <head>            let span = fld.new_span(span);            push_compiler_expansion(fld, span, "for loop expansion");            //   }            //     result            //     };            //       }            //         }            //           }            //             ::std::option::Option::None => break            //             ::std::option::Option::Some(<pat>) => <body>,            //           match ::std::iter::Iterator::next(&mut iter) {            //         [opt_ident]: loop {            //       mut iter => {            //     let result = match ::std::iter::IntoIterator::into_iter(<head>) {            //   {            //            // to:        ast::ExprForLoop(pat, head, body, opt_ident) => {        // From: `[opt_ident]: for <pat> in <head> <body>`        // Desugar ExprForLoop        }            fld.cx.expr(span, ast::ExprLoop(loop_block, opt_ident))            let (loop_block, opt_ident) = expand_loop_block(loop_block, opt_ident, fld);        ast::ExprLoop(loop_block, opt_ident) => {        }            if_expr.map(|e| noop_fold_expr(e, fld))            let if_expr = fld.cx.expr(span, ast::ExprIf(cond, blk, elseopt));            }));                _ => P(els)                }                    result                    fld.cx.bt_pop();                    let result = fld.cx.expr_block(blk);                    });                        span: span                        rules: ast::DefaultBlock,                        id: ast::DUMMY_NODE_ID,                        expr: Some(P(els)),                        stmts: vec![],                    let blk = P(ast::Block {                    let span = els.span;                    // wrap the if-let expr in a block                    push_compiler_expansion(fld, span, "if let expansion");                ast::ExprIfLet(..) => {            let elseopt = elseopt.map(|els| els.and_then(|els| match els.node {        ast::ExprIf(cond, blk, elseopt) => {        // Desugar support for ExprIfLet in the ExprIf else position        }            result            fld.cx.bt_pop();            let result = fld.fold_expr(match_expr);ad
�[����A!���h	�
�
�
�
9
����� ����e>�
�
z
D
-
,
�	�	�	�	�	�	*	)	���oU�����G��E�pS@65&���������A��>��H,*���        // macro invocation in, rather than pulling it apart and        // it would almost certainly be cleaner to pass the whole    match mac.node {{    G: FnOnce(T, Mrk) -> T,    F: for<'a> FnOnce(Box<MacResult+'a>) -> Option<T>,                             -> Option<T> where                             fld: &mut MacroExpander)                             mark_thunk: G,                             parse_thunk: F,fn expand_mac_invoc<T, F, G>(mac: ast::Mac, span: codemap::Span,/// result until after calling make_expr, make_items, etc./// Our current interface doesn't allow us to apply the mark to the/// of expansion and the mark which must be applied to the result./// Expand a (not-ident-style) macro invocation. Returns the result}    })        }            }, fld))                span: span                node: node,                id: id,            P(noop_fold_expr(ast::Expr {        _ => {        }            result            fld.cx.bt_pop();            let result = P(ast::Expr{id:id, node: new_node, span: fld.new_span(span)});                                            rewritten_block);                                            rewritten_fn_decl,            let new_node = ast::ExprClosure(capture_clause,                = expand_and_rename_fn_decl_and_block(fn_decl, block, fld);            let (rewritten_fn_decl, rewritten_block)            push_compiler_expansion(fld, span, "closure expansion");        ast::ExprClosure(capture_clause, fn_decl, block) => {        }            result            fld.cx.bt_pop();                    Some(fld.cx.expr_ident(span, result_ident))));                    vec![fld.cx.stmt_let(span, false, result_ident, match_expr)],                    span,                fld.cx.block_all(            let result = fld.cx.expr_block(            let result_ident = token::gensym_ident("result");            // `{ let result = ...; result }`            let match_expr = fld.cx.expr_match(span, into_iter_expr, vec![iter_arm]);            };                fld.cx.expr_call(span, fld.cx.expr_path(into_iter_path), vec![head])                };                    fld.cx.path_global(span, strs)                    ];                        fld.cx.ident_of("into_iter"),                        fld.cx.ident_of("IntoIterator"),                        fld.cx.ident_of("iter"),                        fld.cx.ident_of_std("core"),                    let strs = vec![                let into_iter_path = {            let into_iter_expr = {            // `match ::std::iter::IntoIterator::into_iter(<head>) { ... }`            };                fld.cx.arm(span, vec![iter_pat], loop_expr)                    fld.cx.pat_ident_binding_mode(span, iter, ast::BindByValue(ast::MutMutable));                let iter_pat =            let iter_arm = {            // `mut iter => { ... }`            let loop_expr = fld.cx.expr(span, ast::ExprLoop(loop_block, opt_ident));            let (loop_block, opt_ident) = expand_loop_block(loop_block, opt_ident, fld);            let loop_block = fld.cx.block_expr(match_expr);            // `[opt_ident]: loop { ... }`            };                            ast::ExprMatch(next_expr, arms, ast::MatchSource::ForLoopDesugar))                fld.cx.expr(pat_span,                let arms = vec![pat_arm, break_arm];                    fld.cx.expr_call(span, fld.cx.expr_path(next_path), vec![ref_mut_iter]);                let next_expr =                let ref_mut_iter = fld.cx.expr_mut_addr_of(span, fld.cx.expr_ident(span, iter));                };                    fld.cx.path_global(span, strs)                    ];ad�`�����vZ:&��_�
�
�
t
;

�z5��^D�
�
y
[
;




�	�	�	�	u	N	L	K	!	��{B����L
	��_?��nM$����g3����`-���S��                rename_fld.fold_stmt(x).expect_one("rename_fold didn't return one value")                let mut rename_fld = IdentRenamer{renames:pending_renames};                let pending_renames = &mut fld.cx.syntax_env.info().pending_renames;            let renamed_stmt = {            // perform all pending renames        let new_stmts = stmts.into_iter().flat_map(|x| {    b.map(|Block {id, stmts, expr, rules, span}| {pub fn expand_block_elts(b: P<Block>, fld: &mut MacroExpander) -> P<Block> {// expand the elements of a block.}                     expand_block_elts(blk, fld))    with_exts_frame!(fld.cx.syntax_env,false,    // see note below about treatment of exts tablepub fn expand_block(blk: P<Block>, fld: &mut MacroExpander) -> P<Block> {// expand a block. pushes a new exts_frame, then calls expand_block_elts}    pat_idents.ident_accumulator    }        pat_idents.visit_pat(&*arg.pat);    for arg in &fn_decl.inputs {    let mut pat_idents = PatIdentFinder{ident_accumulator:Vec::new()};fn fn_decl_arg_bindings(fn_decl: &ast::FnDecl) -> Vec<ast::Ident> {/// find the PatIdent paths in a}    name_finder.ident_accumulator    name_finder.visit_pat(pat);    let mut name_finder = PatIdentFinder{ident_accumulator:Vec::new()};fn pattern_bindings(pat: &ast::Pat) -> Vec<ast::Ident> {/// find the PatIdent paths in a pattern}    }        }            _ => visit::walk_pat(self, pattern)            // use the default traversal for non-PatIdents            }                }                    self.visit_pat(&**subpat)                if let Some(ref subpat) = *inner {                // visit optional subpattern of PatIdent:                self.ident_accumulator.push(path1.node);            ast::Pat { id: _, node: ast::PatIdent(_, ref path1, ref inner), span: _ } => {        match *pattern {    fn visit_pat(&mut self, pattern: &ast::Pat) {impl<'v> Visitor<'v> for PatIdentFinder {}    ident_accumulator: Vec<ast::Ident>struct PatIdentFinder {#[derive(Clone)]/// array/// from a given thingy and puts them in a mutable/// A visitor that extracts the PatIdent (binding) paths}    }        body: rewritten_body,        guard: rewritten_guard,        pats: rewritten_pats,        attrs: fold::fold_attrs(arm.attrs, fld),    ast::Arm {    let rewritten_body = fld.fold_expr(rename_fld.fold_expr(arm.body));        arm.guard.map(|g| fld.fold_expr(rename_fld.fold_expr(g)));    let rewritten_guard =    let mut rename_fld = IdentRenamer{renames:&new_renames};    // apply renaming and then expansion to the guard and the body:    let rewritten_pats = expanded_pats.move_map(|pat| rename_pats_fld.fold_pat(pat));    let mut rename_pats_fld = PatIdentRenamer{renames:&new_renames};    // apply the renaming, but only to the PatIdents:    let new_renames = idents.into_iter().map(|id| (id, fresh_name(&id))).collect();    let idents = pattern_bindings(&*expanded_pats[0]);    // first one to extract them and generate new names:    // all of the pats must have the same set of bindings, so use the    }        panic!("encountered match arm with 0 patterns");    if expanded_pats.is_empty() {    let expanded_pats = arm.pats.move_map(|pat| fld.fold_pat(pat));    // expand pats... they might contain macro uses:fn expand_arm(arm: ast::Arm, fld: &mut MacroExpander) -> ast::Arm {// expand the arm of a 'match', renaming for macro hygiene}    }        }            }, fld)                span: stmt_span                node: node,            noop_fold_stmt(Spanned {        _ => {        }),            }                }, fld)                    span: stmt_spanad�c���yS:��qbB6&�
�
�
�
�
�
�
�
?
,

����b5����N�
�
f
P
&

�	�	p	]	\	0		����W.��l����E��Z4���@���r[Z7
���e*������        };            }                }                    return DummyResult::raw_pat(span);                                            &extnamestr));                                    &format!("{}! is not legal in pattern position",                    fld.cx.span_err(span,                _ => {                }                    mark_pat(expanded,fm)                    // mark after:                    };                        }                            return DummyResult::raw_pat(span);                            );                                    )                                    &extnamestr                                    "non-pattern macro in pattern position: {}",                                &format!(                                pth.span,                            fld.cx.span_err(                        None => {                        Some(e) => e,                    let expanded = match pat {                                              &marked_before[..]).make_pat();                                              mac_span,                    let pat = expander.expand(fld.cx,                    let mac_span = fld.cx.original_span();                    let marked_before = mark_tts(&tts[..], fm);                    let fm = fresh_mark();                    });                        }                            allow_internal_unstable: allow_internal_unstable,                            span: tt_span,                            format: MacroBang,                            name: extnamestr.to_string(),                        callee: NameAndSpan {                        call_site: span,                    fld.cx.bt_push(ExpnInfo {                NormalTT(ref expander, tt_span, allow_internal_unstable) => {            Some(rc) => match *rc {            }                return p.and_then(|p| p);                // let compilation continue                */                                        extnamestr));                                &format!("macro undefined: '{}!'",                fld.cx.span_err(pth.span,                /*                // Ignore unknown macros.            None => {        let marked_after = match fld.cx.syntax_env.find(&extname.name) {        let extnamestr = token::get_ident(extname);        let extname = pth.segments[0].identifier;        }            return DummyResult::raw_pat(span);            fld.cx.span_err(pth.span, "expected macro name without module separators");        if pth.segments.len() > 1 {        };            _ => unreachable!()            },                }                    (pth, tts)                MacInvocTT(pth, tts, _) => {            PatMac(mac) => match mac.node {        let (pth, tts) = match node {    p.clone().map(|ast::Pat {node, span, ..}| {    }        _ => return noop_fold_pat(p, fld)        PatMac(_) => {}    match p.node {fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {}    })        }            span: span            rules: rules,            expr: new_expr,            stmts: new_stmts,            id: fld.new_id(id),        Block {        });            fld.fold_expr(expr)            };                rename_fld.fold_expr(x)                let mut rename_fld = IdentRenamer{renames:pending_renames};                let pending_renames = &mut fld.cx.syntax_env.info().pending_renames;            let expr = {        let new_expr = expr.map(|x| {        }).collect();            fld.fold_stmt(renamed_stmt).into_iter()            // expand macros in the statement            };ad�f�����];$��W9�
�
�
�
P
F
@

�����Y �����a#
�
�
�
�
p

�	�	k	;	���mI	�����jdba;���tP��s��[Z9
��n5����I:'��                    ..(*it).clone()                    attrs: new_attrs,                let it = P(ast::Item {            _ => {            },                result.into_iter().map(|i| Annotatable::Item(i)).collect()                }                    fld.cx.mod_pop();                if valid_ident {                                              noop_fold_item(it, fld));                                              macro_use,                let result = with_exts_frame!(fld.cx.syntax_env,                let macro_use = contains_macro_use(fld, &new_attrs[..]);                }                    fld.cx.mod_push(it.ident);                if valid_ident {                    it.ident.name != parse::token::special_idents::invalid.name;                let valid_ident =            ast::ItemMod(_) | ast::ItemForeignMod(_) => {            }                expand_item_mac(it, fld).into_iter().map(|i| Annotatable::Item(i)).collect()            ast::ItemMac(..) => {        Annotatable::Item(it) => match it.node {    let mut new_items: SmallVector<Annotatable> = match a {    expand_decorators(a.clone(), fld, &mut decorator_items, &mut new_attrs);    let mut new_attrs = Vec::new();    let mut decorator_items = SmallVector::zero();    let a = expand_item_multi_modifier(a, fld);                      -> SmallVector<Annotatable> {                      fld: &mut MacroExpander)fn expand_annotatable(a: Annotatable,}    }        fold::noop_fold_mac(mac, self)    fn fold_mac(&mut self, mac: ast::Mac) -> ast::Mac {    }        })            _ => unreachable!()            },                }                    span: self.new_span(span)                    node: new_node,                    id: id,                ast::Pat {                                  sub.map(|p| self.fold_pat(p)));                                  Spanned{span: self.new_span(sp), node: new_ident},                    ast::PatIdent(binding_mode,                let new_node =                                      ctxt: mtwt::apply_renames(self.renames, ident.ctxt)};                let new_ident = Ident{name: ident.name,            ast::PatIdent(binding_mode, Spanned{span: sp, node: ident}, sub) => {        pat.map(|ast::Pat {id, node, span}| match node {        }            _ => return noop_fold_pat(pat, self)            ast::PatIdent(..) => {},        match pat.node {    fn fold_pat(&mut self, pat: P<ast::Pat>) -> P<ast::Pat> {impl<'a> Folder for PatIdentRenamer<'a> {}    renames: &'a mtwt::RenameList,pub struct PatIdentRenamer<'a> {/// where we want to rename the args but not the fn name or the generics etc./// focused than IdentRenamer, and is needed for FnDecl,/// the idents that are in PatIdent patterns. This is more narrowly/// A tree-folder that applies every rename in its list to}    }        fold::noop_fold_mac(mac, self)    fn fold_mac(&mut self, mac: ast::Mac) -> ast::Mac {    }        }            ctxt: mtwt::apply_renames(self.renames, id.ctxt),            name: id.name,        Ident {    fn fold_ident(&mut self, id: Ident) -> Ident {impl<'a> Folder for IdentRenamer<'a> {}    renames: &'a mtwt::RenameList,pub struct IdentRenamer<'a> {/// (and lots of things that will turn out to be neither)/// to every identifier, including both bindings and varrefs/// A tree-folder that applies every rename in its (mutable) list}    })        }            span: span            node: fully_expanded,            id: ast::DUMMY_NODE_ID,        ast::Pat {        fld.cx.bt_pop();            fld.fold_pat(marked_after).node.clone();        let fully_expanded =ad�c���wv@����^�
�
w
O
<

����e������jQ%�
�
�
T

�	�	�	z	[	I	:	0	*	(	'	�����a'%	���_32��s?��dJ21��K$���j-����k\* ���                              fld: &mut MacroExpander)fn expand_item_multi_modifier(mut it: Annotatable,}    }        }            _ => new_attrs.push((*attr).clone()),            },                _ => new_attrs.push((*attr).clone()),                }                    fld.cx.bt_pop();                        .flat_map(|ann| expand_annotatable(ann, fld).into_iter()));                    decorator_items.extend(items.into_iter()                               &mut |ann| items.push(ann));                               &a,                               &attr.node.value,                               attr.span,                    dec.expand(fld.cx,                    let mut items: SmallVector<Annotatable> = SmallVector::zero();                    // but that double-mut-borrows fld                    // we'd ideally decorator_items.push_all(expand_annotatable(ann, fld)),                    });                        }                            allow_internal_unstable: true,                            // for now.                            // attributes can do whatever they like,                            span: Some(attr.span),                            format: MacroAttribute,                            name: mname.to_string(),                        callee: NameAndSpan {                        call_site: attr.span,                    fld.cx.bt_push(ExpnInfo {                    attr::mark_used(&attr);                MultiDecorator(ref dec) => {            Some(rc) => match *rc {        match fld.cx.syntax_env.find(&intern(&mname)) {        let mname = attr.name();    for attr in a.attrs() {{                     new_attrs: &mut Vec<ast::Attribute>)                     decorator_items: &mut SmallVector<Annotatable>,                     fld: &mut MacroExpander,fn expand_decorators(a: Annotatable,partition!(multi_modifiers, MultiModifier);}    }        }            })                }                    _ => false                    },                        _ => false                        $variant(..) => true,                    Some(rc) => match *rc {                match fld.cx.syntax_env.find(&intern(&attr.name())) {            attrs.iter().cloned().partition(|attr| {                     -> (Vec<ast::Attribute>, Vec<ast::Attribute>) {                    fld: &MacroExpander)        fn $fn_name(attrs: &[ast::Attribute],    ($fn_name: ident, $variant: ident) => {macro_rules! partition {// Partition a set of attributes into one kind of attribute, and other kinds.}    new_items    new_items.extend(decorator_items.into_iter());    };        }            expand_impl_item(ii, fld).into_iter().map(Annotatable::ImplItem).collect()        Annotatable::ImplItem(ii) => {        }.into_iter().map(Annotatable::TraitItem).collect(),            _ => fold::noop_fold_trait_item(it, fld)            })),                span: fld.new_span(ti.span)                },                    _ => unreachable!()                    }                        ast::MethodTraitItem(sig, Some(body))                        let (sig, body) = expand_and_rename_method(sig, body, fld);                    ast::MethodTraitItem(sig, Some(body)) => {                node: match ti.node  {                attrs: ti.attrs,                ident: ti.ident,                id: ti.id,            ast::MethodTraitItem(_, Some(_)) => SmallVector::one(it.map(|ti| ast::TraitItem {        Annotatable::TraitItem(it) => match it.node {        },            }                noop_fold_item(it, fld).into_iter().map(|i| Annotatable::Item(i)).collect()                });ad>�c���0
�������\8�
�
�
W
"
��vO���n\8)	�
�
�
�
�
�
�
o
=

�	�	�	�	r	>	*	����pM���`Q)��{WG%��c<;��u7����xM$�����k&��/// the block, returning both the new FnDecl and the new Block./// PatIdents in its arguments to perform renaming in the FnDecl and/// Given a fn_decl and a block and a MacroExpander, expand the fn_decl, then use the}    }        _ => fold::noop_fold_impl_item(ii, fld)        }            }                }                    SmallVector::one(ii)                    // SmallVector::zero()                    // Ignore unknown macros.                None => {                }                    new_items                    fld.cx.bt_pop();                    }).collect();                        expand_impl_item(ii, fld).into_iter()                    let new_items = impl_items.into_iter().flat_map(|ii| {                    // expand again if necessary                Some(impl_items) => {            match maybe_new_items {                                 fld);                                 |meths, mark| meths.move_map(|m| mark_impl_item(m, mark)),                                 |r| r.make_impl_items(),                expand_mac_invoc(mac, span,            let maybe_new_items =            });                _ => unreachable!()                ast::MacImplItem(mac) => (ii.span, mac),            let (span, mac) = ii.clone().and_then(|ii| match ii.node {        ast::MacImplItem(_) => {        })),            span: fld.new_span(ii.span)            },                _ => unreachable!()                }                    ast::MethodImplItem(sig, body)                    let (sig, body) = expand_and_rename_method(sig, body, fld);                ast::MethodImplItem(sig, body) => {            node: match ii.node  {            vis: ii.vis,            attrs: ii.attrs,            ident: ii.ident,            id: ii.id,        ast::MethodImplItem(..) => SmallVector::one(ii.map(|ii| ast::ImplItem {    match ii.node {                 -> SmallVector<P<ast::ImplItem>> {fn expand_impl_item(ii: P<ast::ImplItem>, fld: &mut MacroExpander)}    it.expect_item()    let it = expand_item_multi_modifier(Annotatable::Item(it), fld);                         -> P<ast::Item> {                         fld: &mut MacroExpander)fn expand_item_modifiers(it: P<ast::Item>,}    expand_item_multi_modifier(it, fld)    // Expansion may have added new ItemModifiers.    }        }            _ => unreachable!()            },                _ => unreachable!()                }                    fld.cx.bt_pop();                    it = mac.expand(fld.cx, attr.span, &*attr.node.value, it);                    });                        }                            allow_internal_unstable: true,                            // for now                            // attributes can do whatever they like,                            span: Some(attr.span),                            format: MacroAttribute,                            name: mname.to_string(),                        callee: NameAndSpan {                        call_site: attr.span,                    fld.cx.bt_push(ExpnInfo {                    attr::mark_used(attr);                MultiModifier(ref mac) => {            Some(rc) => match *rc {        match fld.cx.syntax_env.find(&intern(&mname)) {        let mname = attr.name();    for attr in &modifiers {    }        return it    if modifiers.is_empty() {    it = it.fold_attrs(other_attrs);    // Update the attrs, leave everything else alone. Is this mutation really a good idea?    let (modifiers, other_attrs) = multi_modifiers(it.attrs(), fld);                              -> Annotatable {ad/�k�j���S�
�
X

����g2���k8"�
�
�
~
g
e
d
4

�	�	�	�	�	a	[	Y	X	(	�����c]\
����rlk�������X:43��YSR��}wvE%����tSMKJ&
������TI��                match self.features {            pub fn $getter(&self) -> bool {        $(    ($( fn $getter:ident = $field:ident, )*) => {macro_rules! feature_tests {}    pub trace_mac: bool,    pub recursion_limit: usize,    pub features: Option<&'feat Features>,    pub crate_name: String,pub struct ExpansionConfig<'feat> {}    }        expn_id: cx.backtrace(),        hi: sp.hi,        lo: sp.lo,    Span {    /* this discards information in the case of macro-defining macros */fn new_span(cx: &ExtCtxt, sp: Span) -> Span {}    }        new_span(self.cx, span)    fn new_span(&mut self, span: Span) -> Span {    }            .into_iter().map(|i| i.expect_impl_item()).collect()        expand_annotatable(Annotatable::ImplItem(i), self)    fn fold_impl_item(&mut self, i: P<ast::ImplItem>) -> SmallVector<P<ast::ImplItem>> {    }            .into_iter().map(|i| i.expect_trait_item()).collect()        expand_annotatable(Annotatable::TraitItem(i), self)    fn fold_trait_item(&mut self, i: P<ast::TraitItem>) -> SmallVector<P<ast::TraitItem>> {    }        expand_arm(arm, self)    fn fold_arm(&mut self, arm: ast::Arm) -> ast::Arm {    }        expand_block(block, self)    fn fold_block(&mut self, block: P<Block>) -> P<Block> {    }        expand_stmt(stmt, self)    fn fold_stmt(&mut self, stmt: P<ast::Stmt>) -> SmallVector<P<ast::Stmt>> {    }        expand_item_underscore(item, self)    fn fold_item_underscore(&mut self, item: ast::Item_) -> ast::Item_ {    }        expand_item(item, self)    fn fold_item(&mut self, item: P<ast::Item>) -> SmallVector<P<ast::Item>> {    }        expand_pat(pat, self)    fn fold_pat(&mut self, pat: P<ast::Pat>) -> P<ast::Pat> {    }        expand_expr(expr, self)    fn fold_expr(&mut self, expr: P<ast::Expr>) -> P<ast::Expr> {impl<'a, 'b> Folder for MacroExpander<'a, 'b> {}    }        MacroExpander { cx: cx }    pub fn new(cx: &'a mut ExtCtxt<'b>) -> MacroExpander<'a, 'b> {impl<'a, 'b> MacroExpander<'a, 'b> {}    pub cx: &'a mut ExtCtxt<'b>,pub struct MacroExpander<'a, 'b:'a> {/// A tree-folder that performs macro expansion}    }, rewritten_body)        decl: rewritten_fn_decl        constness: sig.constness,        unsafety: sig.unsafety,        explicit_self: fld.fold_explicit_self(sig.explicit_self),        abi: sig.abi,        generics: fld.fold_generics(sig.generics),    (ast::MethodSig {        = expand_and_rename_fn_decl_and_block(sig.decl, body, fld);    let (rewritten_fn_decl, rewritten_body)                            -> (ast::MethodSig, P<ast::Block>) {                            fld: &mut MacroExpander)fn expand_and_rename_method(sig: ast::MethodSig, body: P<ast::Block>,}    (rewritten_fn_decl,rewritten_body)    let rewritten_body = fld.fold_block(rename_fld.fold_block(block));    let mut rename_fld = IdentRenamer{renames: &renames};    // now, a renamer for *all* idents, for the body:    let rewritten_fn_decl = rename_pat_fld.fold_fn_decl(expanded_decl);    let mut rename_pat_fld = PatIdentRenamer{renames: &renames};    // first, a renamer for the PatIdents, for the fn_decl:        idents.iter().map(|id : &ast::Ident| (*id,fresh_name(id))).collect();    let renames =    let idents = fn_decl_arg_bindings(&*expanded_decl);    let expanded_decl = fld.fold_fn_decl(fn_decl);                                       -> (P<ast::FnDecl>, P<ast::Block>) {                                       fld: &mut MacroExpander)fn expand_and_rename_fn_decl_and_block(fn_decl: P<ast::FnDecl>, block: P<ast::Block>,ad �l���~smkjE����g]WVA�
�
�
Y

�����b��`�
�
�
�
�
v
p
o
F



�	�	b	R	P	O	0		��Z8����t_D
����R����j`ZXW����G����Z976���A?>��// apply a given mark to the given item. Used following the expansion of a macro.}        .expect_one("marking a stmt didn't return exactly one stmt")    Marker{mark:m}.fold_stmt(stmt)fn mark_stmt(stmt: P<ast::Stmt>, m: Mrk) -> P<ast::Stmt> {// apply a given mark to the given stmt. Used following the expansion of a macro.}    Marker{mark:m}.fold_pat(pat)fn mark_pat(pat: P<ast::Pat>, m: Mrk) -> P<ast::Pat> {// apply a given mark to the given pattern. Used following the expansion of a macro.}    Marker{mark:m}.fold_expr(expr)fn mark_expr(expr: P<ast::Expr>, m: Mrk) -> P<ast::Expr> {// apply a given mark to the given expr. Used following the expansion of a macro.}    noop_fold_tts(tts, &mut Marker{mark:m})fn mark_tts(tts: &[TokenTree], m: Mrk) -> Vec<TokenTree> {// apply a given mark to the given token trees. Used prior to expansion of a macro.}    }        }            span: span,            },                }                               mtwt::apply_mark(self.mark, ctxt))                               self.fold_tts(&tts[..]),                    MacInvocTT(self.fold_path(path),                MacInvocTT(path, tts, ctxt) => {            node: match node {        Spanned {    fn fold_mac(&mut self, Spanned {node, span}: ast::Mac) -> ast::Mac {    }        }            ctxt: mtwt::apply_mark(self.mark, id.ctxt)            name: id.name,        ast::Ident {    fn fold_ident(&mut self, id: Ident) -> Ident {impl Folder for Marker {struct Marker { mark: Mrk }// A Marker adds the given mark to the syntax context// Marker - add a mark to a context// the ones defined here include:// version of a closure in (SyntaxContext -> SyntaxContext).// element that has one. a CtxtFn is a trait-ified// ASTs and making some change to the context of every// all of these functions are for walking over// HYGIENIC CONTEXT EXTENSION:}    return ret;    parse_sess.span_diagnostic.handler().abort_if_errors();    ret.exported_macros = expander.cx.exported_macros.clone();    let mut ret = expander.fold_crate(c);    }        expander.cx.syntax_env.insert(name, extension);    for (name, extension) in user_exts {    }        expander.cx.insert_macro(def);    for def in imported_macros {    let mut expander = MacroExpander::new(&mut cx);    cx.use_std = std_inject::use_std(&c);    let mut cx = ExtCtxt::new(parse_sess, c.config.clone(), cfg);                           c: Crate) -> Crate {                           user_exts: Vec<NamedSyntaxExtension>,                           imported_macros: Vec<ast::MacroDef>,                           // these are the macros being imported to this crate:                           cfg: ExpansionConfig<'feat>,pub fn expand_crate<'feat>(parse_sess: &parse::ParseSess,}    }        fn enable_custom_derive = allow_custom_derive,        fn enable_allow_internal_unstable = allow_internal_unstable,        fn enable_trace_macros = allow_trace_macros,        fn enable_concat_idents = allow_concat_idents,        fn enable_log_syntax = allow_log_syntax,        fn enable_asm = allow_asm,        fn enable_quotes = allow_quote,    feature_tests! {    }        }            trace_mac: false,            recursion_limit: 64,            features: None,            crate_name: crate_name,        ExpansionConfig {    pub fn default(crate_name: String) -> ExpansionConfig<'static> {impl<'feat> ExpansionConfig<'feat> {}    }        )*            }                }                    _ => false,                    Some(&Features { $field: true, .. }) => true,ad�i��\ZY��KIH	�
�

~
7

�����_�������t#�
�
�
�
�
r
"

�	�	�	�	q	\	9				��a*�����p����{4����yLB<;��S,&%����PJI��]1���            src,            "<test>".to_string(),        let crate_ast = parse::parse_crate_from_source_str(        let sess = parse::ParseSess::new();                   fn inty() -> i32 { z!() }".to_string();        let src = "fn bogus() {macro_rules! z (() => (3+4));}\    #[test] fn macros_cant_escape_fns_test () {    #[should_panic]    // make sure that macros can't escape fns    }        ExpansionConfig::default("test".to_string())    fn test_ecfg() -> ExpansionConfig<'static> {    // *kind* of failure occurs.    // these following tests are quite fragile, in that they don't test what    }        ident_finder.ident_accumulator        visit::walk_crate(&mut ident_finder, the_crate);        let mut ident_finder = IdentFinder{ident_accumulator: Vec::new()};    fn crate_idents(the_crate: &ast::Crate) -> Vec<ast::Ident> {    /// Find the idents in a crate    }        }            self.ident_accumulator.push(id);        fn visit_ident(&mut self, _: codemap::Span, id: ast::Ident){    impl<'v> Visitor<'v> for IdentFinder {    }        ident_accumulator: Vec<ast::Ident>    struct IdentFinder {    // as a side note, I'm starting to want to abstract over these....    /// A Visitor that extracts the identifiers from a thingy.    }        path_finder.path_accumulator        visit::walk_crate(&mut path_finder, the_crate);        let mut path_finder = PathExprFinderContext{path_accumulator:Vec::new()};    fn crate_varrefs(the_crate : &ast::Crate) -> Vec<ast::Path> {    // find the variable references in a crate    }        }            visit::walk_expr(self, expr);            }                self.path_accumulator.push(p.clone());            if let ast::ExprPath(None, ref p) = expr.node {        fn visit_expr(&mut self, expr: &ast::Expr) {    impl<'v> Visitor<'v> for PathExprFinderContext {    }        path_accumulator: Vec<ast::Path> ,    struct PathExprFinderContext {    #[derive(Clone)]    // array (passed in to the traversal)    // from a given thingy and puts them in a mutable    // a visitor that extracts the paths    use visit::Visitor;    use visit;    use util::parser_testing::{string_to_pat, string_to_crate, strs_to_idents};    use util::parser_testing::{string_to_parser};    use parse::token;    use parse;    use fold::Folder;    use ext::mtwt;    use codemap;    use ast::Name;    use ast;    use super::{PatIdentFinder, IdentRenamer, PatIdentRenamer, ExpansionConfig};    use super::{pattern_bindings, expand_crate};mod tests {#[cfg(test)]}    }                                           with no macro invocations");                                           "macro exterminator: expected AST \        self.sess.span_diagnostic.span_bug(mac.span,    fn visit_mac(&mut self, mac: &ast::Mac) {impl<'a, 'v> Visitor<'v> for MacroExterminator<'a> {}    sess: &'a parse::ParseSessstruct MacroExterminator<'a>{/// A visitor that ensures that no macro invocations remain in an AST.}    visit::walk_crate(&mut MacroExterminator{sess:sess}, krate);pub fn check_for_macros(sess: &parse::ParseSess, krate: &ast::Crate) {/// Check that there are no macro invocations left in the AST:}        .expect_one("marking an impl item didn't return exactly one impl item")    Marker{mark:m}.fold_impl_item(ii)fn mark_impl_item(ii: P<ast::ImplItem>, m: Mrk) -> P<ast::ImplItem> {// apply a given mark to the given item. Used following the expansion of a macro.}        .expect_one("marking an item didn't return exactly one item")    Marker{mark:m}.fold_item(expr)fn mark_item(expr: P<ast::Item>, m: Mrk) -> P<ast::Item> {adyR�����N:	��f*�
�
�
�
�
X

��n2�����X.�
�
_
Y
X
-
�	�	e	?	9	8		����N)�����J�l!��>���z>7���@��j�yx    // but that would make things even harder to understand, and might not be    // in principle, you might want to control this boolean on a per-varref basis,    // name *and* the same marks"? Understanding this is really pretty painful.    // not just "do these have the same name", but "do they have the same    // oog... I also want tests that check "bound-identifier-=?". That is,    //    // names; differences in marks don't matter any more.    // The comparisons are done post-mtwt-resolve, so we're comparing renamed    //    // the bindings and the varrefs discovered by the name-finder and the path-finder.    // Note also that this matrix is dependent on the implicit ordering of    //    // indicating which bindings capture which identifiers.    // Put differently; this is a sparse representation of a boolean matrix    //    // should match the first varref.    // binding should match the second two varrefs, and the second binding    // three varrefs, the array [[1, 2], [0]] would indicate that the first    // should match.  So, for instance, in a program with two bindings and    // interpreted as the varrefs in the varref traversal that this binding    // induced by visit.  Each of these arrays contains a list of indexes,    // outer array corresponds to a binding in the traversal of the AST    // text of the crate, and also an array of arrays.  Each element in the    // the right varrefs. The specification of the test case includes the    // renaming tests expand a crate and then check that the bindings match    }            );            fn f(zz: i32) {foo!(zz);}".to_string()            "macro_rules! foo ((zz) => (287;));        expand_crate_str(    #[test] fn self_macro_parsing(){    // should be able to use a bound identifier as a literal in a macro definition:    }            "macro_rules! m((a)=>(13)) ;fn main(){m!(a);}".to_string());        expand_crate_str(    #[test] fn macro_tokens_should_match(){    }        name_finder.ident_accumulator        visit::walk_crate(&mut name_finder, the_crate);        let mut name_finder = PatIdentFinder{ident_accumulator:Vec::new()};    fn crate_bindings(the_crate : &ast::Crate) -> Vec<ast::Ident> {    // find the pat_ident paths in a crate    }        expand_crate(&ps,test_ecfg(),vec!(),vec!(),crate_ast)        // the cfg argument actually does matter, here...        let crate_ast = panictry!(string_to_parser(&ps, crate_str).parse_crate_mod());        let ps = parse::ParseSess::new();    fn expand_crate_str(crate_str: String) -> ast::Crate {    }        expand_crate(&sess, test_ecfg(), vec!(), vec!(), crate_ast);            Vec::new(), &sess);            src,            "<test>".to_string(),        let crate_ast = parse::parse_crate_from_source_str(        let sess = parse::ParseSess::new();                   fn inty() -> i32 { z!() }".to_string();        let src = "#[macro_use] mod foo {macro_rules! z (() => (3+4));}\    #[test] fn macros_can_escape_flattened_mods_test () {    // macro_use modules should allow macros to escape    }        expand_crate(&sess,test_ecfg(),vec!(),vec!(),crate_ast);            Vec::new(), &sess);            src,            "<test>".to_string(),        let crate_ast = parse::parse_crate_from_source_str(        let sess = parse::ParseSess::new();                   fn inty() -> i32 { z!() }".to_string();        let src = "mod foo {macro_rules! z (() => (3+4));}\    #[test] fn macros_cant_escape_mods_test () {    #[should_panic]    // make sure that macros can't escape modules    }        expand_crate(&sess,test_ecfg(),vec!(),vec!(),crate_ast);        // should fail:            Vec::new(), &sess);ad8�W����nG���=	�
�
/

�V.��J�
�
h
U
#
�	�	�	�	�	L	����}b����|3����T6���xlW<��Z'�����|[@��xcTNM���    // but *shouldn't* bind because it was inserted by a different macro....    // create a really evil test case where a $x appears inside a binding of $x    }            0)              true),              vec!(vec!(0)),              fn main() { let outer!(g) = 13; g;}",              macro_rules! outer ( ($e:pat ) => (inner!($e)));            &("macro_rules! inner ( ($e:pat ) => ($e));        run_renaming_test(    fn pat_expand_issue_15221(){    #[test]    // fn main(){let g1_1 = 13; g1_1}}    // should expand into    // interpolated nodes weren't getting labeled.    }            0)              true),              vec!(vec!(1,3),vec!(0,2),vec!(0,2)),              // NB: the third "binding" is the repeat of the second one.              fn z() {match 8 {x => bad_macro!(x)}}",            &("macro_rules! bad_macro (($ex:expr) => ({match 9 {x | x if x == $ex => x + $ex}}));        run_renaming_test(    fn issue_9384(){    #[test]    // fn z() {match 8 {x_1 => {match 9 {x_2 | x_2 if x_2 == x_1 => x_2 + x_1}}}}    // match variable hygiene. Should expand into    }            0)              vec!(vec!(0)),false),              fn a(){g!(z)}",              ({macro_rules! f(($y:ident)=>({let $y=3;$x}));f!($x)}));            &("macro_rules! g (($x:ident) =>        run_renaming_test(    fn issue_6994(){    #[test]    #[ignore]    // be "let z_123 = 3; z_123"    // (just g) along the other, so the result of the whole thing should    // the z flows into and out of two macros (g & f) along one path, and one    // FIXME #6994:    }              vec!(vec!(0)), true), 0)            &("fn main() {let hrcoo = 19; macro_rules! getx(()=>(hrcoo)); getx!();}",        run_renaming_test(    fn issue_8062(){    #[test]    #[ignore]    // we have no plans to support. ... unless it's needed for item hygiene....    // suggests that this can only occur in the presence of local-expand, which    // not behave exactly like MTWT, but a conversation with Matthew Flatt    // no longer a fixme #8062: this test exposes a *potential* bug; our system does    }        }            run_renaming_test(s,idx);        for (idx,s) in tests.iter().enumerate() {                );                 vec!(vec!(0)), false)                  fn main() -> i32 {user!(z)}",                  macro_rules! user(($x:ident) => ({letty!($x); $x}));                ("macro_rules! letty(($x:ident) => (let $x = 15;));                // this was an awesome test case, and caught a *lot* of bugs.                // capture the one following the semicolon.                // the marks going in and out of letty should cancel, allowing that $x to                 vec!(vec!(1)), false),                ("macro_rules! f (($x:ident) => ({let b=9; ($x + b)})); fn a() -> i32 { f!(b)}",                // the b before the plus should not be renamed (requires marks)                 vec!(vec!(1)), false),                ("macro_rules! f (($x:ident) => (b + $x)); fn a() -> i32 { let b = 13; f!(b)}",                // the use of b after the + should be renamed, the other one not:                 vec!(vec!(0)), false),                ("fn main () {let x: i32 = 13;x;}",                // both x's should be renamed (how is this causing a bug?)                 vec!(vec!(0,1),vec!(2)), false),                ("fn a() -> i32 { let b = 13; let c = b; b+c }",            vec!(// b & c should get new names throughout, in the expr too:        let tests: Vec<RenamingTest> =    fn automatic_renaming () {    #[test]    type RenamingTest = (&'static str, Vec<Vec<usize>>, bool);    // necessary for thorough testing.ad<�b���I= ���,�
�
�
�
�
|
p
Q
6

���vaRLK4����j:�
�
�
�
�
l
Q
!
�	�	�	�	�	�	b	V	7		���f`_C����h=������m/��XM����L��^��f2��                    // good lord, you can't make a path with 0 segments, can you?                let print_hygiene_debug_info = || {            for (idx,varref) in varrefs.iter().enumerate() {                    (varrefs.len() > *shouldmatch.iter().max().unwrap()));            assert!((shouldmatch.is_empty()) ||            // shouldmatch can't name varrefs that don't exist:            let binding_marks = mtwt::marksof(bindings[binding_idx].ctxt, invalid_name);            let binding_name = mtwt::resolve(bindings[binding_idx]);        for (binding_idx,shouldmatch) in bound_connections.iter().enumerate() {        assert_eq!(bindings.len(),bound_connections.len());        // must be one check clause for each binding:        let varrefs = crate_varrefs(&cr);        let bindings = crate_bindings(&cr);        let cr = expand_crate_str(teststr.to_string());        };            (ref str,ref conns, bic) => (str.to_string(), conns.clone(), bic)        let (teststr, bound_connections, bound_ident_check) = match *t {        let invalid_name = token::special_idents::invalid.name;    fn run_renaming_test(t: &RenamingTest, test_idx: usize) {    // run one of the renaming tests    }            0)              vec!(vec!(0)), true),              iterator_impl! { }",              () => { item!( impl Entries { fn size_hint(&self) { self;}});}}              macro_rules! iterator_impl {              struct Entries;            &("macro_rules! item { ($i:item) => {$i}}        run_renaming_test(    fn item_macro_workaround(){    #[test]    // expands to impl Entries {fn size_hint(&self_1) {self_1;}    // another nested macro    }            fn f(){A.thirteen;}".to_string());            impl A{ my_method!(); }            struct A;            "macro_rules! my_method (() => (fn thirteen(&self) -> i32 {13}));        expand_crate_str(    fn macro_in_method_posn(){    #[test]    // macro_rules in method position. Sadly, unimplemented.    }            0)              true),              vec!(vec!(1)),            fn f(){(|x : i32| {(inject_x!() + x)})(3);}",            &("macro_rules! inject_x (()=>(x));        run_renaming_test(    fn closure_arg_hygiene(){    #[test]    // expands to fn f(){(|x_1 : i32| {(x_2 + x_1)})(3);}    // closure arg hygiene (ExprClosure)    }            0)              vec!(vec!(1),vec!(0)),true),              fn q(x: i32) { bad_macro!(x); }",            &("macro_rules! bad_macro (($ex:expr) => (fn g(x: i32){ x + $ex }));        run_renaming_test(    fn issue_9383(){    #[test]    // expands to fn q(x_1: i32){fn g(x_2: i32){x_2 + x_1};}    // item fn hygiene    }            0)              true),              vec!(vec!(0)),              add_method!(A);",              (impl $T {  fn thingy(&self) {self;} }));              macro_rules! add_method (($T:ty) =>            &("struct A;        run_renaming_test(    fn method_arg_hygiene_2(){    #[test]    // expands to struct A; impl A {fn thingy(&self_1) {self_1;}}    // ooh, got another bite?    }            0)              true),              vec!(vec!(0),vec!(3)),              impl A{fn get_x(&self, x: i32) {self + inject_self!() + inject_x!() + x;} }",              struct A;              macro_rules! inject_self (()=>(self));            &("macro_rules! inject_x (()=>(x));        run_renaming_test(    fn method_arg_hygiene(){    #[test]    // method expands to fn get_x(&self_0, x_1: i32) {self_0 + self_2 + x_3 + x_1}    // method arg hygiene    // can't write this test case until we have macro-generating macros.ad$lK�o(��I%�
|
&
��P=
�p7�
�
T

�	�	R			��W#���X���\��wa=+
��'	���h?���v9���mlk        let varrefs = crate_varrefs(&cr);        let resolved_binding = mtwt::resolve(*cxbind);        };            _ => panic!("expected just one binding for ext_cx")            (1, Some(b)) => *b,        let cxbind = match (cxbinds.len(), cxbinds.get(0)) {        let cxbinds: &[&ast::Ident] = &cxbinds[..];            }).collect();                "xx" == string                let string = &ident[..];                let ident = token::get_ident(**b);            bindings.iter().filter(|b| {        let cxbinds: Vec<&ast::Ident> =        let bindings = crate_bindings(&cr);        // find the xx binding        let cr = expand_crate_str(crate_str);".to_string();foo_module!();macro_rules! foo_module (() => (mod generated { fn a() { let xx = 147; fmt_wrap!(xx);}}));        let crate_str = "macro_rules! fmt_wrap(($b:expr)=>($b.to_string()));    fn fmt_in_macro_used_inside_module_macro() {    #[test]    }        }            }                }                    assert!(!fail);                    }                        print_hygiene_debug_info();                        println!("uh oh, matches but shouldn't:");                        println!("");                        println!("text of test case: \"{}\"", teststr);                        println!("failure on test {}",test_idx);                    if fail {                    // temp debugging:                        && (varref_name == binding_name);                    let fail = (varref.segments.len() == 1)                    let varref_name = mtwt::resolve(varref.segments[0].identifier);                } else {                    }                        assert_eq!(varref_marks,binding_marks.clone());                        // should be the same, too:                        // we're checking bound-identifier=?, and the marks                    if bound_ident_check {                    assert_eq!(varref_name,binding_name);                    }                        print_hygiene_debug_info();                        println!("uh oh, should match but doesn't:");                    if !(varref_name==binding_name) {                                                     invalid_name);                                                           .ctxt,                                                           .identifier                    let varref_marks = mtwt::marksof(varref.segments[0]                    let varref_name = mtwt::resolve(varref.segments[0].identifier);                    assert_eq!(varref.segments.len(),1);                    // be free-identifier=? or bound-identifier=? to the given binding                    // it should be a path of length 1, and it should                if shouldmatch.contains(&idx) {                };                    mtwt::with_sctable(|x| mtwt::display_sctable(x));                             binding_idx, bindings[binding_idx], binding_name);                    println!("binding #{}: {}, resolves to {}",                    println!("varref's first segment's string: \"{}\"", &string[..]);                    let string = token::get_ident(final_varref_ident);                    println!("varref #{}: {:?}, resolves to {}",idx, varref_idents, varref_name);                        .collect();                        = varref.segments.iter().map(|s| s.identifier)                    let varref_idents : Vec<ast::Ident>                    let varref_name = mtwt::resolve(final_varref_ident);                    };                        None => panic!("varref with 0 path segments?")                        Some(pathsegment) => pathsegment.identifier,                    let final_varref_ident = match varref.segments.last() {ad0�U�~eG"���\0�
�
]
C

���|M65���^,�
�
�
L

�	�		P			�t)���T��p8���)���rW#
���^+���������F����fn expand_loop_block(loop_block: P<Block>,/// must be propagated to the enclosed context./// body is in a block enclosed by loop head so the renaming of loop label/// The renaming procedure for loop is different in the sense that the loop////// Rename loop label and expand its loop body}    }        }            }                }                    }                        None                                    &extnamestr));                            &format!("'{}' is not a tt-style macro",                            pth.span,                        fld.cx.span_err(                    _ => {                    }                        Some(mark_thunk(parsed,fm))                        };                            }                                return None;                                            ));                                            &extnamestr[..]                                    &format!("non-expression macro in expression position: {}",                                    pth.span,                                fld.cx.span_err(                            None => {                            Some(e) => e,                        let parsed = match opt_parsed {                        };                            parse_thunk(expanded)                                                            &marked_before[..]);                                                            mac_span,                            let expanded = expandfun.expand(fld.cx,                        let opt_parsed = {                        let mac_span = fld.cx.original_span();                        // the macro.                        // relevant span and it's the actual invocation of                        // be the root of the call stack. That's the most                        // The span that we pass to the expanders we want to                        let marked_before = mark_tts(&tts[..], fm);                        let fm = fresh_mark();                            });                                },                                    allow_internal_unstable: allow_internal_unstable,                                    span: exp_span,                                    format: MacroBang,                                    name: extnamestr.to_string(),                                callee: NameAndSpan {                                call_site: span,                        fld.cx.bt_push(ExpnInfo {                    NormalTT(ref expandfun, exp_span, allow_internal_unstable) => {                Some(rc) => match *rc {                }                    None                    // let compilation continue                    */                                &extnamestr));                        &format!("macro undefined: '{}!'",                        pth.span,                    fld.cx.span_err(                    /*                    // Ignore unknown macros.                None => {            match fld.cx.syntax_env.find(&extname.name) {            let extnamestr = token::get_ident(extname);            let extname = pth.segments[0].identifier;            }                return None;                // let compilation continue                                separators");                                "expected macro name without module \                fld.cx.span_err(pth.span,            if pth.segments.len() > 1 {        MacInvocTT(pth, tts, _) => {        // Token-tree macros:        // in this file.        // for the other three macro invocation chunks of code        // marking the tts and the ctxt separately. This also goesad�\��nU%���\�
�
g
)
(
��[/��|{I?�
�
�
�
�
M
,
�	�	�	�	�	�	�	c	%	����ZXW<���Y��E;	�{c,���O������c:��������U���                       fld: &mut MacroExpander) -> SmallVector<P<ast::Item>> {pub fn expand_item_mac(it: P<ast::Item>,// logic as for expression-position macro invocations.// Support for item-position macro invocations, exactly the same}    false    }        }            return true;            }                _ => fld.cx.span_err(attr.span, "arguments to macro_use are not allowed here"),                ast::MetaWord(..) => (),            match attr.node.value.node {        if is_use {        };            }                                             #[macro_use] mod ...");                fld.cx.fileline_help(attr.span, "consider an outer attribute, \            if let ast::AttrInner = attr.node.style {            is_use = true;            fld.cx.span_warn(attr.span, "macro_escape is a deprecated synonym for macro_use");        if attr.check_name("macro_escape") {        let mut is_use = attr.check_name("macro_use");    for attr in attrs {fn contains_macro_use(fld: &mut MacroExpander, attrs: &[ast::Attribute]) -> bool {// does this attribute list contain "macro_use" ?}    }        _ => noop_fold_item_underscore(item, fld)        }                        expanded_generics, rewritten_body)            ast::ItemFn(rewritten_fn_decl, unsafety, constness, abi,            let expanded_generics = fold::noop_fold_generics(generics,fld);                = expand_and_rename_fn_decl_and_block(decl, body, fld);            let (rewritten_fn_decl, rewritten_body)        ast::ItemFn(decl, unsafety, constness, abi, generics, body) => {    match item {fn expand_item_underscore(item: ast::Item_, fld: &mut MacroExpander) -> ast::Item_ {/// Expand item_underscore}        .into_iter().map(|i| i.expect_item()).collect()    expand_annotatable(Annotatable::Item(it), fld)    let it = expand_item_modifiers(it, fld);                   -> SmallVector<P<ast::Item>> {pub fn expand_item(it: P<ast::Item>, fld: &mut MacroExpander)// When we enter a module, record it, for the sake of `module!`}     })      result      $extsboxexpr.pop_frame();      let result = $e;      $extsboxexpr.info().macros_escape = $macros_escape;    ({$extsboxexpr.push_frame();    ($extsboxexpr:expr,$macros_escape:expr,$e:expr) =>macro_rules! with_exts_frame {// must be a macro so that $e isn't evaluated too early.// eval $e with a new exts frame.}    }        None => (fld.fold_block(loop_block), opt_ident)        }            (expanded_block, Some(renamed_ident))            fld.cx.syntax_env.pop_frame();            let expanded_block = expand_block_elts(loop_block, fld);            fld.cx.syntax_env.info().pending_renames.push(rename);            fld.cx.syntax_env.push_frame();            // in a block enclosed by loop head.            // `break` or `continue` to pick up because by definition they are            // The rename *must* be added to the enclosed syntax context for            let renamed_ident = rename_fld.fold_ident(label);            let mut rename_fld = IdentRenamer{renames: &mut rename_list};            let mut rename_list = vec!(rename);            // and be renamed incorrectly.            // the same context will pick that up in the deferred renaming pass            // syntax context otherwise an unrelated `break` or `continue` in            // The rename *must not* be added to the pending list of current            let rename = (label, new_label);            let new_label = fresh_name(&label);        Some(label) => {    match opt_ident {                     fld: &mut MacroExpander) -> (P<Block>, Option<Ident>) {                     opt_ident: Option<Ident>,ad|R��vgW
����p^�
�
�
X
"


�����7���0�
�
t
^
0

�	�	m	E	����W��]*��_I���X0����E���q>���nm?��|x                               format: MacroBang,                            name: extnamestr.to_string(),                        callee: NameAndSpan {                        call_site: it.span,                    fld.cx.bt_push(ExpnInfo {                    }                        return SmallVector::zero();                                        );                                        &format!("macro_rules! expects an ident argument")                        fld.cx.span_err(path_span,                    if it.ident.name == parse::token::special_idents::invalid.name {                MacroRulesTT => {                }                    expander.expand(fld.cx, it.span, it.ident, marked_tts)                    let marked_tts = mark_tts(&tts[..], fm);                    // mark before expansion:                    });                        }                            allow_internal_unstable: allow_internal_unstable,                            span: span,                            format: MacroBang,                            name: extnamestr.to_string(),                        callee: NameAndSpan {                        call_site: it.span,                    fld.cx.bt_push(ExpnInfo {                    }                        return SmallVector::zero();                                                &extnamestr));                                        &format!("macro {}! expects an ident argument",                        fld.cx.span_err(path_span,                    if it.ident.name == parse::token::special_idents::invalid.name {                IdentTT(ref expander, span, allow_internal_unstable) => {                }                    expander.expand(fld.cx, it.span, &marked_before[..])                    let marked_before = mark_tts(&tts[..], fm);                    // mark before expansion:                    });                        }                            allow_internal_unstable: allow_internal_unstable,                            span: span,                            format: MacroBang,                            name: extnamestr.to_string(),                        callee: NameAndSpan {                        call_site: it.span,                    fld.cx.bt_push(ExpnInfo {                    }                        return SmallVector::zero();                                               token::get_ident(it.ident)));                                               extnamestr,                                      &format!("macro {}! expects no ident argument, given '{}'",                            .span_err(path_span,                        fld.cx                    if it.ident.name != parse::token::special_idents::invalid.name {                NormalTT(ref expander, span, allow_internal_unstable) => {            Some(rc) => match *rc {            }                return SmallVector::one(it);                // let compilation continue                */                                        extnamestr));                                &format!("macro undefined: '{}!'",                fld.cx.span_err(path_span,                /*                // Ignore unknown macros.            None => {        let expanded = match fld.cx.syntax_env.find(&extname.name) {    let items = {    let fm = fresh_mark();    let extnamestr = token::get_ident(extname);    };        _ => fld.cx.span_bug(it.span, "invalid item macro invocation")        }            (pth.segments[0].identifier, pth.span, (*tts).clone())        }) => {            ..            node: MacInvocTT(ref pth, ref tts, _),        ItemMac(codemap::Spanned {    let (extname, path_span, tts) = match it.node {adwT�����^���nG�
�
�
w
g
<
2
,
+



��a.	��j�
�
J

�	�	F	��i&��R��M��~:���g)����X����}o\3���wv                        node_id),                        }),                            span: span                            node: decl,                    node: StmtDecl(P(Spanned {                noop_fold_stmt(Spanned {            _ => {            }                }))                    span: stmt_span                        node_id),                        }),                            span: span                            node: DeclLocal(rewritten_local),                    node: StmtDecl(P(Spanned {                SmallVector::one(P(Spanned {                });                    }                        span: span                        source: source,                        init: init.map(|e| fld.fold_expr(e)),                        // also, don't forget to expand the init:                        pat: rewritten_pat,                        ty: expanded_ty,                        id: id,                    Local {                          .extend(new_pending_renames.into_iter());                    fld.cx.syntax_env.info().pending_renames                    // add them to the existing pending renames:                    };                        rename_fld.fold_pat(expanded_pat)                        let mut rename_fld = IdentRenamer{renames: &mut new_pending_renames};                        // nested binding to allow borrow to expire:                    let rewritten_pat = {                    // ones have already been applied):                    // rewrite the pattern using the new names (the old                        idents.iter().map(|ident| (*ident, fresh_name(ident))).collect();                    let mut new_pending_renames =                    let idents = pattern_bindings(&*expanded_pat);                    // generate fresh names, push them to a new pending list                    // the new names are gensyms for the old ones.                    // names, as well... but that should be okay, as long as                    // oh dear heaven... this is going to include the enum                    // find the PatIdents in the pattern:                    let expanded_pat = fld.fold_pat(pat);                    // expand the pat (it might contain macro uses):                    let expanded_ty = ty.map(|t| fld.fold_ty(t));                    // and thus may have a macro use                    // expand the ty since TyFixedLengthVec contains an Expr                let rewritten_local = local.map(|Local {id, pat, ty, init, source, span}| {                // take it apart:            DeclLocal(local) => {        StmtDecl(decl, node_id) => decl.and_then(|Spanned {node: decl, span}| match decl {    match node {    // is it a let?                         -> SmallVector<P<Stmt>> {fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroExpander)// expand_stmt, above.// expand a non-macro stmt. this is essentially the fallthrough for}    fully_expanded    }        }            fully_expanded.push(new_stmt);            });                }                    span: span                    },                        _ => node /* might already have a semi */                        StmtExpr(e, stmt_id) => StmtSemi(e, stmt_id),                    node: match node {                Spanned {            let new_stmt = stmt.map(|Spanned {node, span}| {        if let Some(stmt) = fully_expanded.pop() {    if style == MacStmtWithSemicolon {    // semicolon to the final statement produced by expansion.    // If this is a macro invocation with a semicolon, then apply that    };        }            SmallVector::one(P(stmt))            // SmallVector::zero()