@@ -2420,12 +2420,6 @@ impl<'a> Parser<'a> {
24202420 expr. map ( |mut expr| {
24212421 attrs. extend :: < Vec < _ > > ( expr. attrs . into ( ) ) ;
24222422 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- }
24292423 match expr. node {
24302424 ExprKind :: If ( ..) | ExprKind :: IfLet ( ..) => {
24312425 if !expr. attrs . is_empty ( ) {
@@ -3110,9 +3104,6 @@ impl<'a> Parser<'a> {
31103104
31113105 // `else` token already eaten
31123106 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- }
31163107 if self . eat_keyword ( keywords:: If ) {
31173108 return self . parse_if_expr ( ThinVec :: new ( ) ) ;
31183109 } else {
@@ -3126,9 +3117,6 @@ impl<'a> Parser<'a> {
31263117 span_lo : Span ,
31273118 mut attrs : ThinVec < Attribute > ) -> PResult < ' a , P < Expr > > {
31283119 // 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- }
31323120
31333121 let pat = self . parse_pat ( ) ?;
31343122 self . expect_keyword ( keywords:: In ) ?;
@@ -3144,9 +3132,6 @@ impl<'a> Parser<'a> {
31443132 pub fn parse_while_expr ( & mut self , opt_ident : Option < ast:: SpannedIdent > ,
31453133 span_lo : Span ,
31463134 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- }
31503135 if self . token . is_keyword ( keywords:: Let ) {
31513136 return self . parse_while_let_expr ( opt_ident, span_lo, attrs) ;
31523137 }
@@ -3175,9 +3160,6 @@ impl<'a> Parser<'a> {
31753160 pub fn parse_loop_expr ( & mut self , opt_ident : Option < ast:: SpannedIdent > ,
31763161 span_lo : Span ,
31773162 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- }
31813163 let ( iattrs, body) = self . parse_inner_attrs_and_block ( ) ?;
31823164 attrs. extend ( iattrs) ;
31833165 let span = span_lo. to ( body. span ) ;
@@ -3188,19 +3170,13 @@ impl<'a> Parser<'a> {
31883170 pub fn parse_catch_expr ( & mut self , span_lo : Span , mut attrs : ThinVec < Attribute > )
31893171 -> PResult < ' a , P < Expr > >
31903172 {
3191- if let Some ( doc) = attrs. iter ( ) . find ( |x| x. is_sugared_doc ) {
3192- self . span_fatal_err ( doc. span , Error :: UselessDocComment ) . emit ( ) ;
3193- }
31943173 let ( iattrs, body) = self . parse_inner_attrs_and_block ( ) ?;
31953174 attrs. extend ( iattrs) ;
31963175 Ok ( self . mk_expr ( span_lo. to ( body. span ) , ExprKind :: Catch ( body) , attrs) )
31973176 }
31983177
31993178 // `match` token already eaten
32003179 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- }
32043180 let match_span = self . prev_span ;
32053181 let lo = self . prev_span ;
32063182 let discriminant = self . parse_expr_res ( RESTRICTION_NO_STRUCT_LITERAL ,
@@ -3238,9 +3214,6 @@ impl<'a> Parser<'a> {
32383214 maybe_whole ! ( self , NtArm , |x| x) ;
32393215
32403216 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- }
32443217 let pats = self . parse_pats ( ) ?;
32453218 let guard = if self . eat_keyword ( keywords:: If ) {
32463219 Some ( self . parse_expr ( ) ?)
@@ -3695,9 +3668,6 @@ impl<'a> Parser<'a> {
36953668
36963669 /// Parse a local variable declaration
36973670 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- }
37013671 let lo = self . span ;
37023672 let pat = self . parse_pat ( ) ?;
37033673
@@ -4187,8 +4157,6 @@ impl<'a> Parser<'a> {
41874157 stmts. push ( stmt) ;
41884158 } else if self . token == token:: Eof {
41894159 break ;
4190- } else if let token:: DocComment ( _) = self . token {
4191- return Err ( self . span_fatal_err ( self . span , Error :: UselessDocComment ) ) ;
41924160 } else {
41934161 // Found only `;` or `}`.
41944162 continue ;
0 commit comments