File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ //! The token sequence `&raw` *only* starts a raw borrow expr if it's immediately
2
+ //! followed by either `const` or `mut`. If that's not the case, the `&` denotes
3
+ //! the start of a normal borrow expr where `raw` is interpreted as a regular
4
+ //! identifier and thus denotes the start of a path expr.
5
+ //!
6
+ //! This test ensures that we never commit too early/overzealously in the parser
7
+ //! when encountering the sequence `&raw` (even during parse error recovery) so
8
+ //! as not to regress preexisting code.
9
+
10
+ //@ check-pass
11
+
12
+ fn main ( ) { // the odd formatting in here is intentional
13
+ let raw = 0 ;
14
+ let _ = & raw ;
15
+
16
+ let raw = 0 ;
17
+ let local = 1 ;
18
+ let _: i32 = & raw * local;
19
+
20
+ let raw = |_| ( ) ;
21
+ let local = [ 0 ] ;
22
+ let ( ) = & raw ( local[ 0 ] ) ;
23
+ }
24
+
25
+ macro_rules! check {
26
+ ( $e: expr) => { compile_error!( "expr" ) ; } ;
27
+ ( & raw $e: expr) => { } ;
28
+ }
29
+
30
+ check ! ( & raw local) ;
You can’t perform that action at this time.
0 commit comments