@@ -2784,10 +2784,11 @@ impl<'a> Parser<'a> {
2784
2784
if op. precedence ( ) < min_prec {
2785
2785
break ;
2786
2786
}
2787
- // Warn about deprecated ... syntax (until SNAP)
2788
- if self . token == token:: DotDotDot {
2789
- self . warn_dotdoteq ( self . span ) ;
2787
+ // Check for deprecated ` ...` syntax
2788
+ if self . token == token:: DotDotDot && op == AssocOp :: DotDotEq {
2789
+ self . err_dotdotdot_syntax ( self . span ) ;
2790
2790
}
2791
+
2791
2792
self . bump ( ) ;
2792
2793
if op. is_comparison ( ) {
2793
2794
self . check_no_chained_comparison ( & lhs, & op) ;
@@ -2820,7 +2821,6 @@ impl<'a> Parser<'a> {
2820
2821
//
2821
2822
// We have 2 alternatives here: `x..y`/`x..=y` and `x..`/`x..=` The other
2822
2823
// two variants are handled with `parse_prefix_range_expr` call above.
2823
- // (and `x...y`/`x...` until SNAP)
2824
2824
let rhs = if self . is_at_start_of_range_notation_rhs ( ) {
2825
2825
Some ( self . parse_assoc_expr_with ( op. precedence ( ) + 1 ,
2826
2826
LhsExpr :: NotYetParsed ) ?)
@@ -3008,22 +3008,22 @@ impl<'a> Parser<'a> {
3008
3008
}
3009
3009
}
3010
3010
3011
- /// Parse prefix-forms of range notation: `..expr`, `..`, `..=expr` (and `...expr` until SNAP)
3011
+ /// Parse prefix-forms of range notation: `..expr`, `..`, `..=expr`
3012
3012
fn parse_prefix_range_expr ( & mut self ,
3013
3013
already_parsed_attrs : Option < ThinVec < Attribute > > )
3014
3014
-> PResult < ' a , P < Expr > > {
3015
- // SNAP remove DotDotDot
3015
+ // Check for deprecated `...` syntax
3016
+ if self . token == token:: DotDotDot {
3017
+ self . err_dotdotdot_syntax ( self . span ) ;
3018
+ }
3019
+
3016
3020
debug_assert ! ( [ token:: DotDot , token:: DotDotDot , token:: DotDotEq ] . contains( & self . token) ,
3017
- "parse_prefix_range_expr: token {:?} is not DotDot/DotDotDot/ DotDotEq" ,
3021
+ "parse_prefix_range_expr: token {:?} is not DotDot/DotDotEq" ,
3018
3022
self . token) ;
3019
3023
let tok = self . token . clone ( ) ;
3020
3024
let attrs = self . parse_or_use_outer_attributes ( already_parsed_attrs) ?;
3021
3025
let lo = self . span ;
3022
3026
let mut hi = self . span ;
3023
- // Warn about deprecated ... syntax (until SNAP)
3024
- if tok == token:: DotDotDot {
3025
- self . warn_dotdoteq ( self . span ) ;
3026
- }
3027
3027
self . bump ( ) ;
3028
3028
let opt_end = if self . is_at_start_of_range_notation_rhs ( ) {
3029
3029
// RHS must be parsed with more associativity than the dots.
@@ -4271,9 +4271,13 @@ impl<'a> Parser<'a> {
4271
4271
} ) . emit ( ) ;
4272
4272
}
4273
4273
4274
- fn warn_dotdoteq ( & self , span : Span ) {
4275
- self . diagnostic ( ) . struct_span_warn ( span, {
4276
- "`...` is being replaced by `..=`"
4274
+ fn err_dotdotdot_syntax ( & self , span : Span ) {
4275
+ self . diagnostic ( ) . struct_span_err ( span, {
4276
+ "`...` syntax cannot be used in expressions"
4277
+ } ) . help ( {
4278
+ "Use `..` if you need an exclusive range (a < b)"
4279
+ } ) . help ( {
4280
+ "or `..=` if you need an inclusive range (a <= b)"
4277
4281
} ) . emit ( ) ;
4278
4282
}
4279
4283
0 commit comments