File tree Expand file tree Collapse file tree 5 files changed +38
-11
lines changed Expand file tree Collapse file tree 5 files changed +38
-11
lines changed Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ block_comment_body : [block_comment | character] * ;
160160line_comment : "//" non_eol * ;
161161~~~~
162162
163- Comments in Rust code follow the general C++ style of line and block-comment forms.
163+ Comments in Rust code follow the general C++ style of line and block-comment forms.
164164Nested block comments are supported.
165165
166166Line comments beginning with exactly _ three_ slashes (` /// ` ), and block
@@ -3563,10 +3563,11 @@ There are four varieties of pointer in Rust:
35633563
35643564* Raw pointers (` * ` )
35653565 : Raw pointers are pointers without safety or liveness guarantees.
3566- Raw pointers are written ` *content ` ,
3567- for example ` *int ` means a raw pointer to an integer.
3568- Copying or dropping a raw pointer has no effect on the lifecycle of any other value.
3569- Dereferencing a raw pointer or converting it to any other pointer type is an [ ` unsafe ` operation] ( #unsafe-functions ) .
3566+ Raw pointers are written as ` *const T ` or ` *mut T ` ,
3567+ for example ` *const int ` means a raw pointer to an integer.
3568+ Copying or dropping a raw pointer has no effect on the lifecycle of any
3569+ other value. Dereferencing a raw pointer or converting it to any other
3570+ pointer type is an [ ` unsafe ` operation] ( #unsafe-functions ) .
35703571 Raw pointers are generally discouraged in Rust code;
35713572 they exist to support interoperability with foreign code,
35723573 and writing performance-critical or low-level functions.
Original file line number Diff line number Diff line change @@ -30,8 +30,7 @@ syn keyword rustKeyword unsafe virtual while
3030syn keyword rustKeyword use nextgroup =rustModPath skipwhite skipempty
3131" FIXME: Scoped impl's name is also fallen in this category
3232syn keyword rustKeyword mod trait struct enum type nextgroup =rustIdentifier skipwhite skipempty
33- syn keyword rustStorage mut ref static
34- syn keyword rustObsoleteStorage const
33+ syn keyword rustStorage mut ref static const
3534
3635syn keyword rustInvalidBareKeyword crate
3736
Original file line number Diff line number Diff line change @@ -1365,7 +1365,7 @@ impl<'a> Parser<'a> {
13651365 } else if self . token == token:: BINOP ( token:: STAR ) {
13661366 // STAR POINTER (bare pointer?)
13671367 self . bump ( ) ;
1368- TyPtr ( self . parse_mt ( ) )
1368+ TyPtr ( self . parse_ptr ( ) )
13691369 } else if self . token == token:: LBRACKET {
13701370 // VECTOR
13711371 self . expect ( & token:: LBRACKET ) ;
@@ -1442,6 +1442,19 @@ impl<'a> Parser<'a> {
14421442 return TyRptr ( opt_lifetime, mt) ;
14431443 }
14441444
1445+ pub fn parse_ptr ( & mut self ) -> MutTy {
1446+ let mutbl = if self . eat_keyword ( keywords:: Mut ) {
1447+ MutMutable
1448+ } else if self . eat_keyword ( keywords:: Const ) {
1449+ MutImmutable
1450+ } else {
1451+ // NOTE: after a stage0 snap this should turn into a span_err.
1452+ MutImmutable
1453+ } ;
1454+ let t = self . parse_ty ( true ) ;
1455+ MutTy { ty : t, mutbl : mutbl }
1456+ }
1457+
14451458 pub fn is_named_argument ( & mut self ) -> bool {
14461459 let offset = match self . token {
14471460 token:: BINOP ( token:: AND ) => 1 ,
Original file line number Diff line number Diff line change @@ -512,11 +512,11 @@ declare_special_idents_and_keywords! {
512512 ( 40 , Continue , "continue" ) ;
513513 ( 41 , Proc , "proc" ) ;
514514 ( 42 , Box , "box" ) ;
515+ ( 43 , Const , "const" ) ;
515516
516517 ' reserved:
517- ( 43 , Alignof , "alignof" ) ;
518- ( 44 , Be , "be" ) ;
519- ( 45 , Const , "const" ) ;
518+ ( 44 , Alignof , "alignof" ) ;
519+ ( 45 , Be , "be" ) ;
520520 ( 46 , Offsetof , "offsetof" ) ;
521521 ( 47 , Priv , "priv" ) ;
522522 ( 48 , Pure , "pure" ) ;
Original file line number Diff line number Diff line change 1+ // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ fn main ( ) {
12+ let _a: * const int = 3 as * const int ;
13+ let _a: * mut int = 3 as * mut int ;
14+ }
You can’t perform that action at this time.
0 commit comments