File tree Expand file tree Collapse file tree 1 file changed +7
-17
lines changed
src/librustc_parse/parser Expand file tree Collapse file tree 1 file changed +7
-17
lines changed Original file line number Diff line number Diff line change @@ -1411,23 +1411,13 @@ impl<'a> Parser<'a> {
1411
1411
/// This can either be `;` when there's no body,
1412
1412
/// or e.g. a block when the function is a provided one.
1413
1413
fn parse_fn_body ( & mut self , attrs : & mut Vec < Attribute > ) -> PResult < ' a , Option < P < Block > > > {
1414
- let ( inner_attrs, body) = match self . token . kind {
1415
- token:: Semi => {
1416
- self . bump ( ) ;
1417
- ( Vec :: new ( ) , None )
1418
- }
1419
- token:: OpenDelim ( token:: Brace ) => {
1420
- let ( attrs, body) = self . parse_inner_attrs_and_block ( ) ?;
1421
- ( attrs, Some ( body) )
1422
- }
1423
- token:: Interpolated ( ref nt) => match * * nt {
1424
- token:: NtBlock ( ..) => {
1425
- let ( attrs, body) = self . parse_inner_attrs_and_block ( ) ?;
1426
- ( attrs, Some ( body) )
1427
- }
1428
- _ => return self . expected_semi_or_open_brace ( ) ,
1429
- } ,
1430
- _ => return self . expected_semi_or_open_brace ( ) ,
1414
+ let ( inner_attrs, body) = if self . check ( & token:: Semi ) {
1415
+ self . bump ( ) ;
1416
+ ( Vec :: new ( ) , None )
1417
+ } else if self . check ( & token:: OpenDelim ( token:: Brace ) ) || self . token . is_whole_block ( ) {
1418
+ self . parse_inner_attrs_and_block ( ) . map ( |( attrs, body) | ( attrs, Some ( body) ) ) ?
1419
+ } else {
1420
+ return self . expected_semi_or_open_brace ( ) ;
1431
1421
} ;
1432
1422
attrs. extend ( inner_attrs) ;
1433
1423
Ok ( body)
You can’t perform that action at this time.
0 commit comments