File tree Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Expand file tree Collapse file tree 3 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -7670,6 +7670,9 @@ impl<'a> Parser<'a> {
7670
7670
let ret = f ( self ) ;
7671
7671
let last_token = if self . token_cursor . stack . len ( ) == prev {
7672
7672
& mut self . token_cursor . frame . last_token
7673
+ } else if self . token_cursor . stack . is_empty ( ) { //&& !self.unclosed_delims.is_empty() {
7674
+ // This can happen with mismatched delimiters (#62881)
7675
+ return Ok ( ( ret?, TokenStream :: new ( vec ! [ ] ) ) ) ;
7673
7676
} else {
7674
7677
& mut self . token_cursor . stack [ prev] . last_token
7675
7678
} ;
Original file line number Diff line number Diff line change
1
+ fn main ( ) { }
2
+
3
+ fn f( ) -> isize { fn f ( ) -> isize { } pub f<
4
+ //~^ ERROR missing `fn` or `struct` for function or struct definition
5
+ //~| ERROR mismatched types
6
+ //~ ERROR this file contains an un-closed delimiter
Original file line number Diff line number Diff line change
1
+ error: this file contains an un-closed delimiter
2
+ --> $DIR/issue-62881.rs:6:53
3
+ |
4
+ LL | fn f() -> isize { fn f() -> isize {} pub f<
5
+ | - un-closed delimiter
6
+ ...
7
+ LL |
8
+ | ^
9
+
10
+ error: missing `fn` or `struct` for function or struct definition
11
+ --> $DIR/issue-62881.rs:3:41
12
+ |
13
+ LL | fn f() -> isize { fn f() -> isize {} pub f<
14
+ | ^
15
+
16
+ error[E0308]: mismatched types
17
+ --> $DIR/issue-62881.rs:3:29
18
+ |
19
+ LL | fn f() -> isize { fn f() -> isize {} pub f<
20
+ | - ^^^^^ expected isize, found ()
21
+ | |
22
+ | this function's body doesn't return
23
+ |
24
+ = note: expected type `isize`
25
+ found type `()`
26
+
27
+ error: aborting due to 3 previous errors
28
+
29
+ For more information about this error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments