@@ -73,7 +73,11 @@ impl<'a> Parser<'a> {
7373 // or `auto trait` items. We aim to parse an arbitrary path `a::b` but not something
7474 // that starts like a path (1 token), but it fact not a path.
7575 // Also, we avoid stealing syntax from `parse_item_`.
76- self . parse_stmt_path_start ( lo, attrs, force_collect) ?
76+ if force_collect == ForceCollect :: Yes {
77+ self . collect_tokens_no_attrs ( |this| this. parse_stmt_path_start ( lo, attrs) )
78+ } else {
79+ self . parse_stmt_path_start ( lo, attrs)
80+ } ?
7781 } else if let Some ( item) =
7882 self . parse_item_common ( attrs. clone ( ) , false , true , |_| true , force_collect) ?
7983 {
@@ -85,21 +89,22 @@ impl<'a> Parser<'a> {
8589 self . mk_stmt ( lo, StmtKind :: Empty )
8690 } else if self . token != token:: CloseDelim ( token:: Brace ) {
8791 // Remainder are line-expr stmts.
88- let e = self . parse_expr_res ( Restrictions :: STMT_EXPR , Some ( attrs) ) ?;
92+ let e = if force_collect == ForceCollect :: Yes {
93+ self . collect_tokens_no_attrs ( |this| {
94+ this. parse_expr_res ( Restrictions :: STMT_EXPR , Some ( attrs) )
95+ } )
96+ } else {
97+ self . parse_expr_res ( Restrictions :: STMT_EXPR , Some ( attrs) )
98+ } ?;
8999 self . mk_stmt ( lo. to ( e. span ) , StmtKind :: Expr ( e) )
90100 } else {
91101 self . error_outer_attrs ( & attrs. take_for_recovery ( ) ) ;
92102 return Ok ( None ) ;
93103 } ) )
94104 }
95105
96- fn parse_stmt_path_start (
97- & mut self ,
98- lo : Span ,
99- attrs : AttrWrapper ,
100- force_collect : ForceCollect ,
101- ) -> PResult < ' a , Stmt > {
102- let stmt = self . collect_tokens_trailing_token ( attrs, force_collect, |this, attrs| {
106+ fn parse_stmt_path_start ( & mut self , lo : Span , attrs : AttrWrapper ) -> PResult < ' a , Stmt > {
107+ let stmt = self . collect_tokens_trailing_token ( attrs, ForceCollect :: No , |this, attrs| {
103108 let path = this. parse_path ( PathStyle :: Expr ) ?;
104109
105110 if this. eat ( & token:: Not ) {
0 commit comments