diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-06-16 16:58:17 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-06-16 16:58:17 -0700 |
| commit | 33242578331ab6e22384f686d930780d7fdf27e5 (patch) | |
| tree | 361ef9054b679b74749195fe061ec15938fb16aa /src/libsyntax | |
| parent | 0973eb4419d0598c1134106adef2ee8dc2a2b5ff (diff) | |
| download | rust-33242578331ab6e22384f686d930780d7fdf27e5.tar.gz rust-33242578331ab6e22384f686d930780d7fdf27e5.zip | |
rustc: Start accepting `*const T`
This does not yet change the compiler and libraries from `*T` to `*const T` as it will require a snapshot to do so. cc #7362
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 15 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 6 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 8b50a6270bc..f7bed002140 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1352,7 +1352,7 @@ impl<'a> Parser<'a> { } else if self.token == token::BINOP(token::STAR) { // STAR POINTER (bare pointer?) self.bump(); - TyPtr(self.parse_mt()) + TyPtr(self.parse_ptr()) } else if self.token == token::LBRACKET { // VECTOR self.expect(&token::LBRACKET); @@ -1429,6 +1429,19 @@ impl<'a> Parser<'a> { return TyRptr(opt_lifetime, mt); } + pub fn parse_ptr(&mut self) -> MutTy { + let mutbl = if self.eat_keyword(keywords::Mut) { + MutMutable + } else if self.eat_keyword(keywords::Const) { + MutImmutable + } else { + // NOTE: after a stage0 snap this should turn into a span_err. + MutImmutable + }; + let t = self.parse_ty(true); + MutTy { ty: t, mutbl: mutbl } + } + pub fn is_named_argument(&mut self) -> bool { let offset = match self.token { token::BINOP(token::AND) => 1, diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index a4a022708d9..960c9984a8e 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -486,11 +486,11 @@ declare_special_idents_and_keywords! { (40, Continue, "continue"); (41, Proc, "proc"); (42, Box, "box"); + (43, Const, "const"); 'reserved: - (43, Alignof, "alignof"); - (44, Be, "be"); - (45, Const, "const"); + (44, Alignof, "alignof"); + (45, Be, "be"); (46, Offsetof, "offsetof"); (47, Priv, "priv"); (48, Pure, "pure"); |
