File tree 4 files changed +51
-4
lines changed
4 files changed +51
-4
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ impl<'a> TokenTreesReader<'a> {
129
129
while parser. token != token:: Eof {
130
130
if let Err ( diff_err) = parser. err_diff_marker ( ) {
131
131
diff_errs. push ( diff_err) ;
132
- } else if parser. token . is_keyword ( kw:: If ) {
132
+ } else if parser. is_keyword_ahead ( 0 , & [ kw:: If , kw :: While ] ) {
133
133
in_cond = true ;
134
134
} else if matches ! (
135
135
parser. token. kind,
Original file line number Diff line number Diff line change @@ -1115,7 +1115,7 @@ impl<'a> Parser<'a> {
1115
1115
}
1116
1116
1117
1117
/// Returns whether any of the given keywords are `dist` tokens ahead of the current one.
1118
- fn is_keyword_ahead ( & self , dist : usize , kws : & [ Symbol ] ) -> bool {
1118
+ pub fn is_keyword_ahead ( & self , dist : usize , kws : & [ Symbol ] ) -> bool {
1119
1119
self . look_ahead ( dist, |t| kws. iter ( ) . any ( |& kw| t. is_keyword ( kw) ) )
1120
1120
}
1121
1121
Original file line number Diff line number Diff line change @@ -9,6 +9,27 @@ fn main() {
9
9
}
10
10
}
11
11
12
+ fn quux ( ) {
13
+ while let ( ) = ( )
14
+ && let ( ) = ( ) { //~ERROR: found a `{` in the middle of a let-chain
15
+ & & let ( ) = ( )
16
+ {
17
+ }
18
+ }
19
+
20
+ fn foobar( ) {
21
+ while false { }
22
+ {
23
+ & & let ( ) = ( )
24
+ }
25
+
26
+ fn fubar( ) {
27
+ while false {
28
+ {
29
+ & & let ( ) = ( )
30
+ }
31
+ }
32
+
12
33
fn qux ( ) {
13
34
let foo = false ;
14
35
match foo {
Original file line number Diff line number Diff line change 1
1
error: this file contains an unclosed delimiter
2
- --> $DIR/brace-in-let-chain.rs:37 :54
2
+ --> $DIR/brace-in-let-chain.rs:58 :54
3
3
|
4
4
LL | fn main() {
5
5
| - unclosed delimiter
6
6
...
7
+ LL | fn quux() {
8
+ | - unclosed delimiter
9
+ ...
10
+ LL | fn foobar() {
11
+ | - unclosed delimiter
12
+ ...
13
+ LL | fn fubar() {
14
+ | - unclosed delimiter
15
+ ...
7
16
LL | fn qux() {
8
17
| - unclosed delimiter
9
18
...
@@ -24,6 +33,23 @@ LL | }
24
33
LL | }
25
34
| ^
26
35
36
+ error: found a `{` in the middle of a let-chain
37
+ --> $DIR/brace-in-let-chain.rs:14:24
38
+ |
39
+ LL | && let () = () {
40
+ | ^
41
+ |
42
+ note: you might have meant to continue the let-chain here
43
+ --> $DIR/brace-in-let-chain.rs:15:9
44
+ |
45
+ LL | && let () = ()
46
+ | ^^^^^^
47
+ help: consider removing this brace to parse the `let` as part of the same chain
48
+ |
49
+ LL - && let () = () {
50
+ LL + && let () = ()
51
+ |
52
+
27
53
error: found a `{` in the middle of a let-chain
28
54
--> $DIR/brace-in-let-chain.rs:6:24
29
55
|
@@ -41,5 +67,5 @@ LL - && let () = () {
41
67
LL + && let () = ()
42
68
|
43
69
44
- error: aborting due to 2 previous errors
70
+ error: aborting due to 3 previous errors
45
71
You can’t perform that action at this time.
0 commit comments