From 94327d00c6a5329e510ae364850fa34cd758b83c Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 21 Mar 2013 17:29:49 -0700 Subject: librustc: Replace the `&static` bound with `'static` --- src/libsyntax/parse/parser.rs | 77 ++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 37 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 95f8afd538a..6c942acc34d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2704,49 +2704,52 @@ pub impl Parser { let mut result = opt_vec::Empty; loop { - if self.eat(&token::BINOP(token::AND)) { - if self.eat_keyword(&~"static") { - result.push(RegionTyParamBound); - } else { - self.span_err(*self.span, - ~"`&static` is the only permissible \ - region bound here"); + match *self.token { + token::LIFETIME(lifetime) => { + if str::eq_slice(*self.id_to_str(lifetime), "static") { + result.push(RegionTyParamBound); + } else { + self.span_err(*self.span, + ~"`'static` is the only permissible \ + region bound here"); + } + self.bump(); } - } else if is_ident(&*self.token) { - let maybe_bound = match *self.token { - token::IDENT(copy sid, _) => { - match *self.id_to_str(sid) { - ~"send" | - ~"copy" | - ~"const" | - ~"owned" => { - self.obsolete( - *self.span, - ObsoleteLowerCaseKindBounds); - - // Bogus value, but doesn't matter, since - // is an error - Some(TraitTyParamBound( - self.mk_ty_path(sid))) + token::IDENT(*) => { + let maybe_bound = match *self.token { + token::IDENT(copy sid, _) => { + match *self.id_to_str(sid) { + ~"send" | + ~"copy" | + ~"const" | + ~"owned" => { + self.obsolete( + *self.span, + ObsoleteLowerCaseKindBounds); + + // Bogus value, but doesn't matter, since + // is an error + Some(TraitTyParamBound( + self.mk_ty_path(sid))) + } + _ => None } - _ => None } - } - _ => fail!() - }; + _ => fail!() + }; - match maybe_bound { - Some(bound) => { - self.bump(); - result.push(bound); - } - None => { - let ty = self.parse_ty(false); - result.push(TraitTyParamBound(ty)); + match maybe_bound { + Some(bound) => { + self.bump(); + result.push(bound); + } + None => { + let ty = self.parse_ty(false); + result.push(TraitTyParamBound(ty)); + } } } - } else { - break; + _ => break, } if self.eat(&token::BINOP(token::PLUS)) { -- cgit 1.4.1-3-g733a5