@@ -73,7 +73,11 @@ impl<'a> Parser<'a> {
73
73
// or `auto trait` items. We aim to parse an arbitrary path `a::b` but not something
74
74
// that starts like a path (1 token), but it fact not a path.
75
75
// 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
+ } ?
77
81
} else if let Some ( item) =
78
82
self . parse_item_common ( attrs. clone ( ) , false , true , |_| true , force_collect) ?
79
83
{
@@ -85,21 +89,22 @@ impl<'a> Parser<'a> {
85
89
self . mk_stmt ( lo, StmtKind :: Empty )
86
90
} else if self . token != token:: CloseDelim ( token:: Brace ) {
87
91
// 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
+ } ?;
89
99
self . mk_stmt ( lo. to ( e. span ) , StmtKind :: Expr ( e) )
90
100
} else {
91
101
self . error_outer_attrs ( & attrs. take_for_recovery ( ) ) ;
92
102
return Ok ( None ) ;
93
103
} ) )
94
104
}
95
105
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| {
103
108
let path = this. parse_path ( PathStyle :: Expr ) ?;
104
109
105
110
if this. eat ( & token:: Not ) {
0 commit comments