diff options
| author | bors <bors@rust-lang.org> | 2014-06-24 04:16:53 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-06-24 04:16:53 +0000 |
| commit | 768921371311430c8eb953bfdddece53a6071e6e (patch) | |
| tree | 4fef35c86317ce8b203714e80900632b1ce9eec0 /src/libsyntax/parse/parser.rs | |
| parent | 10b12bc123984dfd0858a68c5ad2fe33cdc01ede (diff) | |
| parent | 33242578331ab6e22384f686d930780d7fdf27e5 (diff) | |
| download | rust-768921371311430c8eb953bfdddece53a6071e6e.tar.gz rust-768921371311430c8eb953bfdddece53a6071e6e.zip | |
auto merge of #14952 : alexcrichton/rust/const-unsafe-pointers, r=brson
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 --- Note that the corresponding RFC, https://github.com/rust-lang/rfcs/pull/68, has not yet been accepted. It was [discussed at the last meeting](https://github.com/rust-lang/rust/wiki/Meeting-weekly-2014-06-10#rfc-pr-68-unsafe-pointers-rename-t-to-const-t) and decided to be accepted, however. I figured I'd get started on the preliminary work for the RFC that will be required regardless.
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e3a028ed4d6..e1319304e04 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1365,7 +1365,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); @@ -1442,6 +1442,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, |
