diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-09-14 15:20:09 -0700 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-09-14 15:22:15 -0700 |
| commit | 7107b4eff51e58aa1ae5e30b073b4d788b13a2cb (patch) | |
| tree | c2a529a20d4ba0986ce75ac1e4234be46e77c820 /src/libsyntax/parse | |
| parent | 34cece99cce373546d62aed06a7ec55d04aaa124 (diff) | |
| download | rust-7107b4eff51e58aa1ae5e30b073b4d788b13a2cb.tar.gz rust-7107b4eff51e58aa1ae5e30b073b4d788b13a2cb.zip | |
Have parser recognize static, self region.
Fixes a bug in methods that &self couldn't be referenced in the body. Also fixes #2479.
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c96cfdfe6bc..fa506a062b4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -4,7 +4,7 @@ use result::Result; use either::{Either, Left, Right}; use std::map::{HashMap, str_hash}; use token::{can_begin_expr, is_ident, is_ident_or_path, is_plain_ident, - INTERPOLATED}; + INTERPOLATED, special_idents}; use codemap::{span,fss_none}; use util::interner::interner; use ast_util::{spanned, respan, mk_sp, ident_to_path, operator_prec}; @@ -51,7 +51,8 @@ use ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute, pat_ident, pat_lit, pat_range, pat_rec, pat_region, pat_struct, pat_tup, pat_uniq, pat_wild, path, private, proto, proto_bare, proto_block, proto_box, proto_uniq, provided, public, pure_fn, - purity, re_anon, re_named, region, rem, required, ret_style, + purity, re_static, re_self, re_anon, re_named, region, + rem, required, ret_style, return_val, self_ty, shl, shr, stmt, stmt_decl, stmt_expr, stmt_semi, struct_def, struct_field, struct_variant_kind, subtract, sty_box, sty_by_ref, sty_region, sty_static, sty_uniq, @@ -432,8 +433,10 @@ impl parser { fn region_from_name(s: Option<ident>) -> @region { let r = match s { - Some (id) => re_named(id), - None => re_anon + Some(id) if id == special_idents::static => ast::re_static, + Some(id) if id == special_idents::self_ => re_self, + Some(id) => re_named(id), + None => re_anon }; @{id: self.get_id(), node: r} @@ -614,7 +617,7 @@ impl parser { let name = self.parse_value_ident(); self.bump(); name - } else { token::special_idents::invalid } + } else { special_idents::invalid } }; let t = self.parse_ty(false); @@ -2388,7 +2391,7 @@ impl parser { fn is_self_ident() -> bool { match self.token { - token::IDENT(id, false) if id == token::special_idents::self_ + token::IDENT(id, false) if id == special_idents::self_ => true, _ => false } @@ -2603,7 +2606,7 @@ impl parser { // This is a new-style impl declaration. // XXX: clownshoes - let ident = token::special_idents::clownshoes_extensions; + let ident = special_idents::clownshoes_extensions; // Parse the type. let ty = self.parse_ty(false); @@ -3019,7 +3022,7 @@ impl parser { } (ast::anonymous, - token::special_idents::clownshoes_foreign_mod) + special_idents::clownshoes_foreign_mod) } }; |
