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