@@ -2420,12 +2420,6 @@ impl<'a> Parser<'a> {
2420
2420
expr. map ( |mut expr| {
2421
2421
attrs. extend :: < Vec < _ > > ( expr. attrs . into ( ) ) ;
2422
2422
expr. attrs = attrs;
2423
- if if let Some ( ref doc) = expr. attrs . iter ( ) . find ( |x| x. is_sugared_doc ) {
2424
- self . span_fatal_err ( doc. span , Error :: UselessDocComment ) . emit ( ) ;
2425
- true
2426
- } else { false } {
2427
- return expr;
2428
- }
2429
2423
match expr. node {
2430
2424
ExprKind :: If ( ..) | ExprKind :: IfLet ( ..) => {
2431
2425
if !expr. attrs . is_empty ( ) {
@@ -3110,9 +3104,6 @@ impl<'a> Parser<'a> {
3110
3104
3111
3105
// `else` token already eaten
3112
3106
pub fn parse_else_expr ( & mut self ) -> PResult < ' a , P < Expr > > {
3113
- if self . prev_token_kind == PrevTokenKind :: DocComment {
3114
- return Err ( self . span_fatal_err ( self . span , Error :: UselessDocComment ) ) ;
3115
- }
3116
3107
if self . eat_keyword ( keywords:: If ) {
3117
3108
return self . parse_if_expr ( ThinVec :: new ( ) ) ;
3118
3109
} else {
@@ -3126,9 +3117,6 @@ impl<'a> Parser<'a> {
3126
3117
span_lo : Span ,
3127
3118
mut attrs : ThinVec < Attribute > ) -> PResult < ' a , P < Expr > > {
3128
3119
// Parse: `for <src_pat> in <src_expr> <src_loop_block>`
3129
- if let Some ( doc) = attrs. iter ( ) . find ( |x| x. is_sugared_doc ) {
3130
- self . span_fatal_err ( doc. span , Error :: UselessDocComment ) . emit ( ) ;
3131
- }
3132
3120
3133
3121
let pat = self . parse_pat ( ) ?;
3134
3122
self . expect_keyword ( keywords:: In ) ?;
@@ -3144,9 +3132,6 @@ impl<'a> Parser<'a> {
3144
3132
pub fn parse_while_expr ( & mut self , opt_ident : Option < ast:: SpannedIdent > ,
3145
3133
span_lo : Span ,
3146
3134
mut attrs : ThinVec < Attribute > ) -> PResult < ' a , P < Expr > > {
3147
- if let Some ( doc) = attrs. iter ( ) . find ( |x| x. is_sugared_doc ) {
3148
- self . span_fatal_err ( doc. span , Error :: UselessDocComment ) . emit ( ) ;
3149
- }
3150
3135
if self . token . is_keyword ( keywords:: Let ) {
3151
3136
return self . parse_while_let_expr ( opt_ident, span_lo, attrs) ;
3152
3137
}
@@ -3175,9 +3160,6 @@ impl<'a> Parser<'a> {
3175
3160
pub fn parse_loop_expr ( & mut self , opt_ident : Option < ast:: SpannedIdent > ,
3176
3161
span_lo : Span ,
3177
3162
mut attrs : ThinVec < Attribute > ) -> PResult < ' a , P < Expr > > {
3178
- if let Some ( doc) = attrs. iter ( ) . find ( |x| x. is_sugared_doc ) {
3179
- self . span_fatal_err ( doc. span , Error :: UselessDocComment ) . emit ( ) ;
3180
- }
3181
3163
let ( iattrs, body) = self . parse_inner_attrs_and_block ( ) ?;
3182
3164
attrs. extend ( iattrs) ;
3183
3165
let span = span_lo. to ( body. span ) ;
@@ -3188,19 +3170,13 @@ impl<'a> Parser<'a> {
3188
3170
pub fn parse_catch_expr ( & mut self , span_lo : Span , mut attrs : ThinVec < Attribute > )
3189
3171
-> PResult < ' a , P < Expr > >
3190
3172
{
3191
- if let Some ( doc) = attrs. iter ( ) . find ( |x| x. is_sugared_doc ) {
3192
- self . span_fatal_err ( doc. span , Error :: UselessDocComment ) . emit ( ) ;
3193
- }
3194
3173
let ( iattrs, body) = self . parse_inner_attrs_and_block ( ) ?;
3195
3174
attrs. extend ( iattrs) ;
3196
3175
Ok ( self . mk_expr ( span_lo. to ( body. span ) , ExprKind :: Catch ( body) , attrs) )
3197
3176
}
3198
3177
3199
3178
// `match` token already eaten
3200
3179
fn parse_match_expr ( & mut self , mut attrs : ThinVec < Attribute > ) -> PResult < ' a , P < Expr > > {
3201
- if let Some ( doc) = attrs. iter ( ) . find ( |x| x. is_sugared_doc ) {
3202
- self . span_fatal_err ( doc. span , Error :: UselessDocComment ) . emit ( ) ;
3203
- }
3204
3180
let match_span = self . prev_span ;
3205
3181
let lo = self . prev_span ;
3206
3182
let discriminant = self . parse_expr_res ( RESTRICTION_NO_STRUCT_LITERAL ,
@@ -3238,9 +3214,6 @@ impl<'a> Parser<'a> {
3238
3214
maybe_whole ! ( self , NtArm , |x| x) ;
3239
3215
3240
3216
let attrs = self . parse_outer_attributes ( ) ?;
3241
- if let Some ( doc) = attrs. iter ( ) . find ( |x| x. is_sugared_doc ) {
3242
- self . span_fatal_err ( doc. span , Error :: UselessDocComment ) . emit ( ) ;
3243
- }
3244
3217
let pats = self . parse_pats ( ) ?;
3245
3218
let guard = if self . eat_keyword ( keywords:: If ) {
3246
3219
Some ( self . parse_expr ( ) ?)
@@ -3695,9 +3668,6 @@ impl<'a> Parser<'a> {
3695
3668
3696
3669
/// Parse a local variable declaration
3697
3670
fn parse_local ( & mut self , attrs : ThinVec < Attribute > ) -> PResult < ' a , P < Local > > {
3698
- if let Some ( doc) = attrs. iter ( ) . find ( |x| x. is_sugared_doc ) {
3699
- self . span_fatal_err ( doc. span , Error :: UselessDocComment ) . emit ( ) ;
3700
- }
3701
3671
let lo = self . span ;
3702
3672
let pat = self . parse_pat ( ) ?;
3703
3673
@@ -4187,8 +4157,6 @@ impl<'a> Parser<'a> {
4187
4157
stmts. push ( stmt) ;
4188
4158
} else if self . token == token:: Eof {
4189
4159
break ;
4190
- } else if let token:: DocComment ( _) = self . token {
4191
- return Err ( self . span_fatal_err ( self . span , Error :: UselessDocComment ) ) ;
4192
4160
} else {
4193
4161
// Found only `;` or `}`.
4194
4162
continue ;
0 commit comments