diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-01-10 11:16:54 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-01-10 11:16:54 -0800 |
| commit | 2a1b6c4de993c8db1bda35d58426d873e9e514c2 (patch) | |
| tree | a348bb8b51487c1504a9c923c2bf489e58047348 /src/libsyntax/parse/parser.rs | |
| parent | 982830c836b8c2c9cb3fd311c826bf5775ad1232 (diff) | |
| download | rust-2a1b6c4de993c8db1bda35d58426d873e9e514c2.tar.gz rust-2a1b6c4de993c8db1bda35d58426d873e9e514c2.zip | |
librustc: Implement `&static` as the replacement for `Durable`. r=nmatsakis
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1a549fc93d5..6974ac508aa 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -10,7 +10,8 @@ use core::prelude::*; -use ast::{ProtoBox, ProtoUniq, provided, public, pure_fn, purity, re_static}; +use ast::{ProtoBox, ProtoUniq, RegionTyParamBound, TraitTyParamBound}; +use ast::{provided, public, pure_fn, purity, re_static}; use ast::{_mod, add, arg, arm, attribute, bind_by_ref, bind_infer}; use ast::{bind_by_value, bind_by_move, bitand, bitor, bitxor, blk}; use ast::{blk_check_mode, box, by_copy, by_move, by_ref, by_val}; @@ -2401,8 +2402,16 @@ impl Parser { fn parse_optional_ty_param_bounds() -> @~[ty_param_bound] { let mut bounds = ~[]; if self.eat(token::COLON) { - while is_ident(self.token) { - if is_ident(self.token) { + loop { + if self.eat(token::BINOP(token::AND)) { + if self.eat_keyword(~"static") { + bounds.push(RegionTyParamBound); + } else { + self.span_err(copy self.span, + ~"`&static` is the only permissible \ + region bound here"); + } + } else if is_ident(self.token) { let maybe_bound = match self.token { token::IDENT(copy sid, _) => { match *self.id_to_str(sid) { @@ -2415,7 +2424,7 @@ impl Parser { ObsoleteLowerCaseKindBounds); // Bogus value, but doesn't matter, since // is an error - Some(ty_param_bound(self.mk_ty_path(sid))) + Some(TraitTyParamBound(self.mk_ty_path(sid))) } _ => None @@ -2430,11 +2439,12 @@ impl Parser { bounds.push(bound); } None => { - bounds.push(ty_param_bound(self.parse_ty(false))); + let ty = self.parse_ty(false); + bounds.push(TraitTyParamBound(ty)); } } } else { - bounds.push(ty_param_bound(self.parse_ty(false))); + break; } } } |
