@@ -152,10 +152,10 @@ impl<'a> Parser<'a> {
152152 expr
153153 }
154154 LhsExpr :: Unparsed { attrs } => {
155+ let attrs = self . parse_or_use_outer_attributes ( attrs) ?;
155156 if self . token . is_range_separator ( ) {
156157 return self . parse_expr_prefix_range ( attrs) ;
157158 } else {
158- let attrs = self . parse_or_use_outer_attributes ( attrs) ?;
159159 self . parse_expr_prefix ( attrs) ?
160160 }
161161 }
@@ -499,7 +499,12 @@ impl<'a> Parser<'a> {
499499 }
500500
501501 /// Parses prefix-forms of range notation: `..expr`, `..`, `..=expr`.
502- fn parse_expr_prefix_range ( & mut self , attrs : Option < AttrWrapper > ) -> PResult < ' a , P < Expr > > {
502+ fn parse_expr_prefix_range ( & mut self , attrs : AttrWrapper ) -> PResult < ' a , P < Expr > > {
503+ if !attrs. is_empty ( ) {
504+ let err = errors:: DotDotRangeAttribute { span : self . token . span } ;
505+ self . dcx ( ) . emit_err ( err) ;
506+ }
507+
503508 // Check for deprecated `...` syntax.
504509 if self . token == token:: DotDotDot {
505510 self . err_dotdotdot_syntax ( self . token . span ) ;
@@ -516,11 +521,7 @@ impl<'a> Parser<'a> {
516521 _ => RangeLimits :: Closed ,
517522 } ;
518523 let op = AssocOp :: from_token ( & self . token ) ;
519- // FIXME: `parse_prefix_range_expr` is called when the current
520- // token is `DotDot`, `DotDotDot`, or `DotDotEq`. If we haven't already
521- // parsed attributes, then trying to parse them here will always fail.
522- // We should figure out how we want attributes on range expressions to work.
523- let attrs = self . parse_or_use_outer_attributes ( attrs) ?;
524+ let attrs = self . parse_outer_attributes ( ) ?;
524525 self . collect_tokens_for_expr ( attrs, |this, attrs| {
525526 let lo = this. token . span ;
526527 let maybe_lt = this. look_ahead ( 1 , |t| t. clone ( ) ) ;
@@ -871,10 +872,10 @@ impl<'a> Parser<'a> {
871872 let has_lifetime = self . token . is_lifetime ( ) && self . look_ahead ( 1 , |t| t != & token:: Colon ) ;
872873 let lifetime = has_lifetime. then ( || self . expect_lifetime ( ) ) ; // For recovery, see below.
873874 let ( borrow_kind, mutbl) = self . parse_borrow_modifiers ( lo) ;
875+ let attrs = self . parse_outer_attributes ( ) ?;
874876 let expr = if self . token . is_range_separator ( ) {
875- self . parse_expr_prefix_range ( None )
877+ self . parse_expr_prefix_range ( attrs )
876878 } else {
877- let attrs = self . parse_outer_attributes ( ) ?;
878879 self . parse_expr_prefix ( attrs)
879880 } ?;
880881 let hi = self . interpolated_or_expr_span ( & expr) ;
0 commit comments