File tree 3 files changed +15
-2
lines changed
3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -1878,7 +1878,8 @@ impl<'a> Parser<'a> {
1878
1878
let parser_snapshot_before_ty = self . clone ( ) ;
1879
1879
self . eat_incorrect_doc_comment ( "a method argument's type" ) ;
1880
1880
let mut ty = self . parse_ty ( ) ;
1881
- if ty. is_ok ( ) && self . token == token:: Colon {
1881
+ if ty. is_ok ( ) && self . token != token:: Comma &&
1882
+ self . token != token:: CloseDelim ( token:: Paren ) {
1882
1883
// This wasn't actually a type, but a pattern looking like a type,
1883
1884
// so we are going to rollback and re-parse for recovery.
1884
1885
ty = self . unexpected ( ) ;
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ trait T {
6
6
7
7
fn bar ( ( x, y) : ( i32 , i32 ) ) { } //~ ERROR patterns aren't allowed in methods without bodies
8
8
9
+ fn method ( S { .. } : S ) { } //~ ERROR patterns aren't allowed in methods without bodies
10
+
9
11
fn f ( & ident: & S ) { } // ok
10
12
fn g ( & & ident: & & S ) { } // ok
11
13
fn h ( mut ident : S ) { } // ok
Original file line number Diff line number Diff line change @@ -18,6 +18,16 @@ help: give this argument a name or use an underscore to ignore it
18
18
LL | fn bar(_: (i32, i32)) {} //~ ERROR patterns aren't allowed in methods without bodies
19
19
| ^
20
20
21
- error: aborting due to 2 previous errors
21
+ error[E0642]: patterns aren't allowed in methods without bodies
22
+ --> $DIR/E0642.rs:9:15
23
+ |
24
+ LL | fn method(S { .. }: S) {} //~ ERROR patterns aren't allowed in methods without bodies
25
+ | ^^^^^^^^
26
+ help: give this argument a name or use an underscore to ignore it
27
+ |
28
+ LL | fn method(_: S) {} //~ ERROR patterns aren't allowed in methods without bodies
29
+ | ^
30
+
31
+ error: aborting due to 3 previous errors
22
32
23
33
For more information about this error, try `rustc --explain E0642`.
You can’t perform that action at this time.
0 commit comments