@@ -2524,16 +2524,7 @@ impl<'a> Parser<'a> {
25242524 let bracket_pos = self . span . lo ;
25252525 self . bump ( ) ;
25262526
2527- let mut found_dotdot = false ;
2528- if self . token == token:: DotDot &&
2529- self . look_ahead ( 1 , |t| t == & token:: CloseDelim ( token:: Bracket ) ) {
2530- // Using expr[..], which is a mistake, should be expr[]
2531- self . bump ( ) ;
2532- self . bump ( ) ;
2533- found_dotdot = true ;
2534- }
2535-
2536- if found_dotdot || self . eat ( & token:: CloseDelim ( token:: Bracket ) ) {
2527+ if self . eat ( & token:: CloseDelim ( token:: Bracket ) ) {
25372528 // No expression, expand to a RangeFull
25382529 // FIXME(#20516) It would be better to use a lang item or
25392530 // something for RangeFull.
@@ -2557,7 +2548,11 @@ impl<'a> Parser<'a> {
25572548 let range = ExprStruct ( path, vec ! [ ] , None ) ;
25582549 let ix = self . mk_expr ( bracket_pos, hi, range) ;
25592550 let index = self . mk_index ( e, ix) ;
2560- e = self . mk_expr ( lo, hi, index)
2551+ e = self . mk_expr ( lo, hi, index) ;
2552+ // Enable after snapshot.
2553+ // self.span_warn(e.span, "deprecated slicing syntax: `[]`");
2554+ // self.span_note(e.span,
2555+ // "use `&expr[..]` to construct a slice of the whole of expr");
25612556 } else {
25622557 let ix = self . parse_expr ( ) ;
25632558 hi = self . span . hi ;
@@ -2566,11 +2561,6 @@ impl<'a> Parser<'a> {
25662561 e = self . mk_expr ( lo, hi, index)
25672562 }
25682563
2569- if found_dotdot {
2570- self . span_err ( e. span , "incorrect slicing expression: `[..]`" ) ;
2571- self . span_note ( e. span ,
2572- "use `&expr[]` to construct a slice of the whole of expr" ) ;
2573- }
25742564 }
25752565 _ => return e
25762566 }
@@ -2931,9 +2921,14 @@ impl<'a> Parser<'a> {
29312921 // with the postfix-form 'expr..'
29322922 let lo = self . span . lo ;
29332923 self . bump ( ) ;
2934- let rhs = self . parse_binops ( ) ;
2935- let hi = rhs. span . hi ;
2936- let ex = self . mk_range ( None , Some ( rhs) ) ;
2924+ let opt_end = if self . is_at_start_of_range_notation_rhs ( ) {
2925+ let end = self . parse_binops ( ) ;
2926+ Some ( end)
2927+ } else {
2928+ None
2929+ } ;
2930+ let hi = self . span . hi ;
2931+ let ex = self . mk_range ( None , opt_end) ;
29372932 self . mk_expr ( lo, hi, ex)
29382933 }
29392934 _ => {
0 commit comments