File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Expand file tree Collapse file tree 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> {
18781878 let parser_snapshot_before_ty = self . clone ( ) ;
18791879 self . eat_incorrect_doc_comment ( "a method argument's type" ) ;
18801880 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 ) {
18821883 // This wasn't actually a type, but a pattern looking like a type,
18831884 // so we are going to rollback and re-parse for recovery.
18841885 ty = self . unexpected ( ) ;
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ trait T {
66
77 fn bar ( ( x, y) : ( i32 , i32 ) ) { } //~ ERROR patterns aren't allowed in methods without bodies
88
9+ fn method ( S { .. } : S ) { } //~ ERROR patterns aren't allowed in methods without bodies
10+
911 fn f ( & ident: & S ) { } // ok
1012 fn g ( & & ident: & & S ) { } // ok
1113 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
1818LL | fn bar(_: (i32, i32)) {} //~ ERROR patterns aren't allowed in methods without bodies
1919 | ^
2020
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
2232
2333For more information about this error, try `rustc --explain E0642`.
You can’t perform that action at this time.
0 commit comments