diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-07-31 19:25:24 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-07-31 19:26:25 -0700 |
| commit | b414db041be115d877e5b17bc86ea019420b672c (patch) | |
| tree | d7e15ba792c8376aaabe9727726de34b03e89baf /src/libsyntax/ext | |
| parent | a841789a41941ad73a57cd9972dfbd5fdff02685 (diff) | |
| download | rust-b414db041be115d877e5b17bc86ea019420b672c.tar.gz rust-b414db041be115d877e5b17bc86ea019420b672c.zip | |
rustc: Parse by-reference pattern bindings with the "ref" keyword
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/auto_serialize.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/pipes/ast_builder.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/qquote.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/earley_parser.rs | 2 |
4 files changed, 10 insertions, 6 deletions
diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs index 57b6dc13b8a..90319feb4d2 100644 --- a/src/libsyntax/ext/auto_serialize.rs +++ b/src/libsyntax/ext/auto_serialize.rs @@ -228,7 +228,7 @@ impl helpers of ext_ctxt_helpers for ext_ctxt { let path = @{span: span, global: false, idents: ~[nm], rp: none, types: ~[]}; @{id: self.next_id(), - node: ast::pat_ident(path, none), + node: ast::pat_ident(ast::bind_by_ref, path, none), span: span} } @@ -834,7 +834,9 @@ fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: ast::ident, // Generate pattern var(v1, v2, v3) |pats| { if vec::is_empty(pats) { - ast::pat_ident(cx.path(v_span, ~[v_name]), none) + ast::pat_ident(ast::bind_by_ref, + cx.path(v_span, ~[v_name]), + none) } else { ast::pat_enum(cx.path(v_span, ~[v_name]), some(pats)) } diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index bb5b35233cd..89c53d16ac5 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -116,8 +116,10 @@ impl ast_builder of ext_ctxt_ast_builder for ext_ctxt { @{node: {is_mutbl: false, ty: self.ty_infer(), pat: @{id: self.next_id(), - node: ast::pat_ident( - path(ident, self.empty_span()), none), + node: ast::pat_ident(ast::bind_by_ref, + path(ident, + self.empty_span()), + none), span: self.empty_span()}, init: some({op: ast::init_move, expr: e}), diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs index 9dcb4da14fa..94753ea88e0 100644 --- a/src/libsyntax/ext/qquote.rs +++ b/src/libsyntax/ext/qquote.rs @@ -170,7 +170,7 @@ fn parse_crate(p: parser) -> @ast::crate { p.parse_crate_mod(~[]) } fn parse_ty(p: parser) -> @ast::ty { p.parse_ty(false) } fn parse_stmt(p: parser) -> @ast::stmt { p.parse_stmt(~[]) } fn parse_expr(p: parser) -> @ast::expr { p.parse_expr() } -fn parse_pat(p: parser) -> @ast::pat { p.parse_pat() } +fn parse_pat(p: parser) -> @ast::pat { p.parse_pat(true) } fn parse_item(p: parser) -> @ast::item { alt p.parse_item(~[], ast::public) { diff --git a/src/libsyntax/ext/tt/earley_parser.rs b/src/libsyntax/ext/tt/earley_parser.rs index c7a2713c26e..bd8fcf552da 100644 --- a/src/libsyntax/ext/tt/earley_parser.rs +++ b/src/libsyntax/ext/tt/earley_parser.rs @@ -326,7 +326,7 @@ fn parse_nt(p: parser, name: ~str) -> nonterminal { }} ~"block" { token::nt_block(p.parse_block()) } ~"stmt" { token::nt_stmt(p.parse_stmt(~[])) } - ~"pat" { token::nt_pat(p.parse_pat()) } + ~"pat" { token::nt_pat(p.parse_pat(true)) } ~"expr" { token::nt_expr(p.parse_expr()) } ~"ty" { token::nt_ty(p.parse_ty(false /* no need to disambiguate*/)) } // this could be handled like a token, since it is one |
