File tree 5 files changed +38
-11
lines changed
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] * ;
160
160
line_comment : "//" non_eol * ;
161
161
~~~~
162
162
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.
164
164
Nested block comments are supported.
165
165
166
166
Line comments beginning with exactly _ three_ slashes (` /// ` ), and block
@@ -3468,10 +3468,11 @@ There are four varieties of pointer in Rust:
3468
3468
3469
3469
* Raw pointers (` * ` )
3470
3470
: Raw pointers are pointers without safety or liveness guarantees.
3471
- Raw pointers are written ` *content ` ,
3472
- for example ` *int ` means a raw pointer to an integer.
3473
- Copying or dropping a raw pointer has no effect on the lifecycle of any other value.
3474
- Dereferencing a raw pointer or converting it to any other pointer type is an [ ` unsafe ` operation] ( #unsafe-functions ) .
3471
+ Raw pointers are written as ` *const T ` or ` *mut T ` ,
3472
+ for example ` *const int ` means a raw pointer to an integer.
3473
+ Copying or dropping a raw pointer has no effect on the lifecycle of any
3474
+ other value. Dereferencing a raw pointer or converting it to any other
3475
+ pointer type is an [ ` unsafe ` operation] ( #unsafe-functions ) .
3475
3476
Raw pointers are generally discouraged in Rust code;
3476
3477
they exist to support interoperability with foreign code,
3477
3478
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
30
30
syn keyword rustKeyword use nextgroup =rustModPath skipwhite skipempty
31
31
" FIXME: Scoped impl's name is also fallen in this category
32
32
syn 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
35
34
36
35
syn keyword rustInvalidBareKeyword crate
37
36
Original file line number Diff line number Diff line change @@ -1352,7 +1352,7 @@ impl<'a> Parser<'a> {
1352
1352
} else if self . token == token:: BINOP ( token:: STAR ) {
1353
1353
// STAR POINTER (bare pointer?)
1354
1354
self . bump ( ) ;
1355
- TyPtr ( self . parse_mt ( ) )
1355
+ TyPtr ( self . parse_ptr ( ) )
1356
1356
} else if self . token == token:: LBRACKET {
1357
1357
// VECTOR
1358
1358
self . expect ( & token:: LBRACKET ) ;
@@ -1429,6 +1429,19 @@ impl<'a> Parser<'a> {
1429
1429
return TyRptr ( opt_lifetime, mt) ;
1430
1430
}
1431
1431
1432
+ pub fn parse_ptr ( & mut self ) -> MutTy {
1433
+ let mutbl = if self . eat_keyword ( keywords:: Mut ) {
1434
+ MutMutable
1435
+ } else if self . eat_keyword ( keywords:: Const ) {
1436
+ MutImmutable
1437
+ } else {
1438
+ // NOTE: after a stage0 snap this should turn into a span_err.
1439
+ MutImmutable
1440
+ } ;
1441
+ let t = self . parse_ty ( true ) ;
1442
+ MutTy { ty : t, mutbl : mutbl }
1443
+ }
1444
+
1432
1445
pub fn is_named_argument ( & mut self ) -> bool {
1433
1446
let offset = match self . token {
1434
1447
token:: BINOP ( token:: AND ) => 1 ,
Original file line number Diff line number Diff line change @@ -486,11 +486,11 @@ declare_special_idents_and_keywords! {
486
486
( 40 , Continue , "continue" ) ;
487
487
( 41 , Proc , "proc" ) ;
488
488
( 42 , Box , "box" ) ;
489
+ ( 43 , Const , "const" ) ;
489
490
490
491
' reserved:
491
- ( 43 , Alignof , "alignof" ) ;
492
- ( 44 , Be , "be" ) ;
493
- ( 45 , Const , "const" ) ;
492
+ ( 44 , Alignof , "alignof" ) ;
493
+ ( 45 , Be , "be" ) ;
494
494
( 46 , Offsetof , "offsetof" ) ;
495
495
( 47 , Priv , "priv" ) ;
496
496
( 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