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
@@ -3563,10 +3563,11 @@ There are four varieties of pointer in Rust:
3563
3563
3564
3564
* Raw pointers (` * ` )
3565
3565
: 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 ) .
3570
3571
Raw pointers are generally discouraged in Rust code;
3571
3572
they exist to support interoperability with foreign code,
3572
3573
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 @@ -1365,7 +1365,7 @@ impl<'a> Parser<'a> {
1365
1365
} else if self . token == token:: BINOP ( token:: STAR ) {
1366
1366
// STAR POINTER (bare pointer?)
1367
1367
self . bump ( ) ;
1368
- TyPtr ( self . parse_mt ( ) )
1368
+ TyPtr ( self . parse_ptr ( ) )
1369
1369
} else if self . token == token:: LBRACKET {
1370
1370
// VECTOR
1371
1371
self . expect ( & token:: LBRACKET ) ;
@@ -1442,6 +1442,19 @@ impl<'a> Parser<'a> {
1442
1442
return TyRptr ( opt_lifetime, mt) ;
1443
1443
}
1444
1444
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
+
1445
1458
pub fn is_named_argument ( & mut self ) -> bool {
1446
1459
let offset = match self . token {
1447
1460
token:: BINOP ( token:: AND ) => 1 ,
Original file line number Diff line number Diff line change @@ -512,11 +512,11 @@ declare_special_idents_and_keywords! {
512
512
( 40 , Continue , "continue" ) ;
513
513
( 41 , Proc , "proc" ) ;
514
514
( 42 , Box , "box" ) ;
515
+ ( 43 , Const , "const" ) ;
515
516
516
517
' reserved:
517
- ( 43 , Alignof , "alignof" ) ;
518
- ( 44 , Be , "be" ) ;
519
- ( 45 , Const , "const" ) ;
518
+ ( 44 , Alignof , "alignof" ) ;
519
+ ( 45 , Be , "be" ) ;
520
520
( 46 , Offsetof , "offsetof" ) ;
521
521
( 47 , Priv , "priv" ) ;
522
522
( 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