Skip to content

Commit 03a1d5d

Browse files
committed
---
yaml --- r: 79483 b: refs/heads/snap-stage3 c: 3261b6e h: refs/heads/master i: 79481: d638f4b 79479: a35979e v: v3
1 parent 458698c commit 03a1d5d

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 124eb2119c78651cfaaa7a046a101fa2e20f83ca
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 34f31e296191f7c4cfcad8c81bf6bca00a32d9e2
4+
refs/heads/snap-stage3: 3261b6eece84161355bac8dad8427af5221cbf0d
55
refs/heads/try: ac820906c0e53eab79a98ee64f7231f57c3887b4
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libsyntax/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ pub enum BlockCheckMode {
472472
UnsafeBlock,
473473
}
474474

475-
#[deriving(Eq, Encodable, Decodable,IterBytes)]
475+
#[deriving(Clone, Eq, Encodable, Decodable,IterBytes)]
476476
pub struct Expr {
477477
id: NodeId,
478478
node: Expr_,

branches/snap-stage3/src/libsyntax/ext/expand.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ fn expand_non_macro_stmt (exts: SyntaxEnv,
603603
}
604604

605605
// a visitor that extracts the pat_ident paths
606-
// from a given pattern and puts them in a mutable
606+
// from a given thingy and puts them in a mutable
607607
// array (passed in to the traversal)
608608
#[deriving(Clone)]
609609
struct NewNameFinderContext {
@@ -748,15 +748,14 @@ impl Visitor<()> for NewNameFinderContext {
748748
}
749749
}
750750

751-
// a visitor that extracts the path exprs from
752-
// a crate/expression/whatever and puts them in a mutable
751+
// a visitor that extracts the paths
752+
// from a given thingy and puts them in a mutable
753753
// array (passed in to the traversal)
754754
#[deriving(Clone)]
755755
struct NewPathExprFinderContext {
756756
path_accumulator: @mut ~[ast::Path],
757757
}
758758

759-
760759
// XXX : YIKES a lot of boilerplate again....
761760
impl Visitor<()> for NewPathExprFinderContext {
762761

@@ -875,7 +874,7 @@ impl Visitor<()> for NewPathExprFinderContext {
875874
}
876875

877876
// return a visitor that extracts the pat_ident paths
878-
// from a given pattern and puts them in a mutable
877+
// from a given thingy and puts them in a mutable
879878
// array (passed in to the traversal)
880879
pub fn new_name_finder(idents: @mut ~[ast::Ident]) -> @mut Visitor<()> {
881880
let context = @mut NewNameFinderContext {
@@ -913,6 +912,7 @@ pub fn renames_to_fold(renames : @mut ~[(ast::Ident,ast::Name)]) -> @ast_fold {
913912
make_fold(f_pre)
914913
}
915914

915+
// expand a block. pushes a new exts_frame, then calls expand_block_elts
916916
pub fn expand_block(extsbox: @mut SyntaxEnv,
917917
_cx: @ExtCtxt,
918918
blk: &Block,
@@ -924,7 +924,7 @@ pub fn expand_block(extsbox: @mut SyntaxEnv,
924924
expand_block_elts(*extsbox, blk, fld))
925925
}
926926

927-
927+
// expand the elements of a block.
928928
pub fn expand_block_elts(exts: SyntaxEnv, b: &Block, fld: @ast_fold) -> Block {
929929
let block_info = get_block_info(exts);
930930
let pending_renames = block_info.pending_renames;
@@ -949,6 +949,7 @@ pub fn expand_block_elts(exts: SyntaxEnv, b: &Block, fld: @ast_fold) -> Block {
949949
}
950950

951951
// rename_fold should never return "None".
952+
// (basically, just .get() with a better message...)
952953
fn mustbesome<T>(val : Option<T>) -> T {
953954
match val {
954955
Some(v) => v,
@@ -971,8 +972,8 @@ pub fn new_span(cx: @ExtCtxt, sp: Span) -> Span {
971972
}
972973

973974
// FIXME (#2247): this is a moderately bad kludge to inject some macros into
974-
// the default compilation environment. It would be much nicer to use
975-
// a mechanism like syntax_quote to ensure hygiene.
975+
// the default compilation environment in that it injects strings, rather than
976+
// syntax elements.
976977

977978
pub fn std_macros() -> @str {
978979
return
@@ -1453,6 +1454,10 @@ pub fn fun_to_ctxt_folder<T : 'static + CtxtFn>(cf: @T) -> @AstFoldFns {
14531454
|ast::Ident{name, ctxt}, _| {
14541455
ast::Ident{name:name,ctxt:cf.f(ctxt)}
14551456
};
1457+
// we've also got to pick up macro invocations; they can
1458+
// appear as exprs, stmts, items, and types. urg, it's going
1459+
// to be easier just to add a fold_mac, I think.
1460+
//let fold_ex : @
14561461
@AstFoldFns{
14571462
fold_ident : fi,
14581463
// check that it works, then add the fold_expr clause....
@@ -1631,14 +1636,15 @@ mod test {
16311636

16321637
// try a double-rename, with pending_renames.
16331638
let a3_name = gensym("a3");
1639+
// a context that renames from ("a",empty) to "a2" :
16341640
let ctxt2 = new_rename(ast::Ident::new(a_name),a2_name,EMPTY_CTXT);
16351641
let pending_renames = @mut ~[(ast::Ident::new(a_name),a2_name),
16361642
(ast::Ident{name:a_name,ctxt:ctxt2},a3_name)];
16371643
let double_renamed = renames_to_fold(pending_renames).fold_crate(item_ast);
16381644
let varrefs = @mut ~[];
16391645
visit::walk_crate(&mut new_path_finder(varrefs), &double_renamed, ());
16401646
match varrefs {
1641-
@[Path{segments:[ref seg],_}] => assert_eq!(mtwt_resolve(seg.identifier),a2_name),
1647+
@[Path{segments:[ref seg],_}] => assert_eq!(mtwt_resolve(seg.identifier),a3_name),
16421648
_ => assert_eq!(0,1)
16431649
}
16441650
}

0 commit comments

Comments
 (0)