diff options
| author | Luqman Aden <me@luqman.ca> | 2013-03-04 18:03:21 -0800 |
|---|---|---|
| committer | Luqman Aden <me@luqman.ca> | 2013-03-18 17:31:41 -0700 |
| commit | 42f95d055c2f22078f5c94c0d0ca229e1561ccb8 (patch) | |
| tree | 390c70d8758494f9e974582f90145bf3719e7aec /src/libsyntax/parse | |
| parent | e78f2e2ac577f9c47cd58af52d3bcd496254545d (diff) | |
| download | rust-42f95d055c2f22078f5c94c0d0ca229e1561ccb8.tar.gz rust-42f95d055c2f22078f5c94c0d0ca229e1561ccb8.zip | |
Allow constant expressions in [Type * n].
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 8a883b73a64..c7e93635d4c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -642,7 +642,8 @@ pub impl Parser { self.obsolete(*self.last_span, ObsoleteMutVector); } - // Parse the `* 3` in `[ int * 3 ]` + // Parse the `* e` in `[ int * e ]` + // where `e` is a const expression let t = match self.maybe_parse_fixed_vstore_with_star() { None => ty_vec(mt), Some(suffix) => ty_fixed_length_vec(mt, suffix) @@ -814,23 +815,9 @@ pub impl Parser { }) } - fn maybe_parse_fixed_vstore_with_star(&self) -> Option<uint> { + fn maybe_parse_fixed_vstore_with_star(&self) -> Option<@ast::expr> { if self.eat(&token::BINOP(token::STAR)) { - match *self.token { - token::LIT_INT_UNSUFFIXED(i) if i >= 0i64 => { - self.bump(); - Some(i as uint) - } - _ => { - self.fatal( - fmt!( - "expected integral vector length \ - but found `%s`", - token_to_str(self.reader, © *self.token) - ) - ); - } - } + Some(self.parse_expr()) } else { None } |
