about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libsyntax/parse/parser.rs33
-rw-r--r--src/libsyntax/print/pprust.rs4
-rw-r--r--src/test/bench/shootout-fasta-redux.rs2
-rw-r--r--src/test/compile-fail/packed-struct-generic-transmute.rs2
-rw-r--r--src/test/compile-fail/slice-1.rs9
-rw-r--r--src/test/compile-fail/slice-2.rs2
-rw-r--r--src/test/run-pass/auto-encode.rs2
-rw-r--r--src/test/run-pass/coerce-overloaded-autoderef.rs8
-rw-r--r--src/test/run-pass/deriving-encodable-decodable.rs2
-rw-r--r--src/test/run-pass/foreach-external-iterators-break.rs2
-rw-r--r--src/test/run-pass/foreach-external-iterators-nested.rs4
-rw-r--r--src/test/run-pass/foreach-external-iterators.rs2
-rw-r--r--src/test/run-pass/issue-8898.rs8
-rw-r--r--src/test/run-pass/range.rs1
-rw-r--r--src/test/run-pass/ranges-precedence.rs3
-rw-r--r--src/test/run-pass/repeated-vector-syntax.rs6
-rw-r--r--src/test/run-pass/slice-2.rs8
-rw-r--r--src/test/run-pass/slice.rs4
18 files changed, 51 insertions, 51 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 22174494458..cae23c5a2cc 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2527,16 +2527,7 @@ impl<'a> Parser<'a> {
                 let bracket_pos = self.span.lo;
                 self.bump();
 
-                let mut found_dotdot = false;
-                if self.token == token::DotDot &&
-                   self.look_ahead(1, |t| t == &token::CloseDelim(token::Bracket)) {
-                    // Using expr[..], which is a mistake, should be expr[]
-                    self.bump();
-                    self.bump();
-                    found_dotdot = true;
-                }
-
-                if found_dotdot || self.eat(&token::CloseDelim(token::Bracket)) {
+                if self.eat(&token::CloseDelim(token::Bracket)) {
                     // No expression, expand to a RangeFull
                     // FIXME(#20516) It would be better to use a lang item or
                     // something for RangeFull.
@@ -2560,7 +2551,11 @@ impl<'a> Parser<'a> {
                     let range = ExprStruct(path, vec![], None);
                     let ix = self.mk_expr(bracket_pos, hi, range);
                     let index = self.mk_index(e, ix);
-                    e = self.mk_expr(lo, hi, index)
+                    e = self.mk_expr(lo, hi, index);
+                    // Enable after snapshot.
+                    // self.span_warn(e.span, "deprecated slicing syntax: `[]`");
+                    // self.span_note(e.span,
+                    //               "use `&expr[..]` to construct a slice of the whole of expr");
                 } else {
                     let ix = self.parse_expr();
                     hi = self.span.hi;
@@ -2569,11 +2564,6 @@ impl<'a> Parser<'a> {
                     e = self.mk_expr(lo, hi, index)
                 }
 
-                if found_dotdot {
-                    self.span_err(e.span, "incorrect slicing expression: `[..]`");
-                    self.span_note(e.span,
-                                   "use `&expr[]` to construct a slice of the whole of expr");
-                }
               }
               _ => return e
             }
@@ -2934,9 +2924,14 @@ impl<'a> Parser<'a> {
             // with the postfix-form 'expr..'
             let lo = self.span.lo;
             self.bump();
-            let rhs = self.parse_binops();
-            let hi = rhs.span.hi;
-            let ex = self.mk_range(None, Some(rhs));
+            let opt_end = if self.is_at_start_of_range_notation_rhs() {
+                let end = self.parse_binops();
+                Some(end)
+            } else {
+                None
+            };
+            let hi = self.span.hi;
+            let ex = self.mk_range(None, opt_end);
             self.mk_expr(lo, hi, ex)
           }
           _ => {
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index fa41b0f7eef..542cc41c950 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -1811,9 +1811,7 @@ impl<'a> State<'a> {
                 if let &Some(ref e) = start {
                     try!(self.print_expr(&**e));
                 }
-                if start.is_some() || end.is_some() {
-                    try!(word(&mut self.s, ".."));
-                }
+                try!(word(&mut self.s, ".."));
                 if let &Some(ref e) = end {
                     try!(self.print_expr(&**e));
                 }
diff --git a/src/test/bench/shootout-fasta-redux.rs b/src/test/bench/shootout-fasta-redux.rs
index 954bd5b2f79..d91031b8401 100644
--- a/src/test/bench/shootout-fasta-redux.rs
+++ b/src/test/bench/shootout-fasta-redux.rs
@@ -180,7 +180,7 @@ impl<'a, W: Writer> RandomFasta<'a, W> {
 
     fn nextc(&mut self) -> u8 {
         let r = self.rng(1.0);
-        for a in &self.lookup[] {
+        for a in &self.lookup[..] {
             if a.p >= r {
                 return a.c;
             }
diff --git a/src/test/compile-fail/packed-struct-generic-transmute.rs b/src/test/compile-fail/packed-struct-generic-transmute.rs
index 6b6ab3f2970..82425d2c227 100644
--- a/src/test/compile-fail/packed-struct-generic-transmute.rs
+++ b/src/test/compile-fail/packed-struct-generic-transmute.rs
@@ -32,6 +32,6 @@ fn main() {
     let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 };
     unsafe {
         let oof: Oof<[u8; 5], i32> = mem::transmute(foo);
-        println!("{:?} {:?}", &oof.rab[], oof.zab);
+        println!("{:?} {:?}", &oof.rab[..], oof.zab);
     }
 }
diff --git a/src/test/compile-fail/slice-1.rs b/src/test/compile-fail/slice-1.rs
index 903760caf1a..23ad5b09950 100644
--- a/src/test/compile-fail/slice-1.rs
+++ b/src/test/compile-fail/slice-1.rs
@@ -8,12 +8,15 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// Test slicing expr[..] is an error and gives a helpful error message.
+// Test slicing &expr[] is deprecated and gives a helpful error message.
+//
+// ignore-test
 
 struct Foo;
 
 fn main() {
     let x = Foo;
-    &x[..]; //~ ERROR incorrect slicing expression: `[..]`
-    //~^ NOTE use `&expr[]` to construct a slice of the whole of expr
+    &x[]; //~ WARNING deprecated slicing syntax: `[]`
+          //~^ NOTE use `&expr[..]` to construct a slice of the whole of expr
+          //~^^ ERROR cannot index a value of type `Foo`
 }
diff --git a/src/test/compile-fail/slice-2.rs b/src/test/compile-fail/slice-2.rs
index 07162293565..99dc3e68c8f 100644
--- a/src/test/compile-fail/slice-2.rs
+++ b/src/test/compile-fail/slice-2.rs
@@ -14,7 +14,7 @@ struct Foo;
 
 fn main() {
     let x = Foo;
-    &x[]; //~ ERROR cannot index a value of type `Foo`
+    &x[..]; //~ ERROR cannot index a value of type `Foo`
     &x[Foo..]; //~ ERROR cannot index a value of type `Foo`
     &x[..Foo]; //~ ERROR cannot index a value of type `Foo`
     &x[Foo..Foo]; //~ ERROR cannot index a value of type `Foo`
diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs
index 9b030de9983..1fcbae833dc 100644
--- a/src/test/run-pass/auto-encode.rs
+++ b/src/test/run-pass/auto-encode.rs
@@ -35,7 +35,7 @@ fn test_rbml<'a, 'b, A:
     let mut rbml_w = EBwriter::Encoder::new(&mut wr);
     a1.encode(&mut rbml_w);
 
-    let d: serialize::rbml::Doc<'a> = EBDoc::new(&wr[]);
+    let d: serialize::rbml::Doc<'a> = EBDoc::new(&wr);
     let mut decoder: EBReader::Decoder<'a> = EBreader::Decoder::new(d);
     let a2: A = Decodable::decode(&mut decoder);
     assert!(*a1 == a2);
diff --git a/src/test/run-pass/coerce-overloaded-autoderef.rs b/src/test/run-pass/coerce-overloaded-autoderef.rs
index ae4db404115..ec8d58616dc 100644
--- a/src/test/run-pass/coerce-overloaded-autoderef.rs
+++ b/src/test/run-pass/coerce-overloaded-autoderef.rs
@@ -47,11 +47,11 @@ fn use_slice(_: &[u8]) {}
 fn use_slice_mut(_: &mut [u8]) {}
 
 fn use_vec(mut v: Vec<u8>) {
-    use_slice_mut(&mut v[]); // what you have to write today
-    use_slice_mut(&mut v);   // what you'd be able to write
+    use_slice_mut(&mut v[..]); // what you have to write today
+    use_slice_mut(&mut v);     // what you'd be able to write
     use_slice_mut(&mut &mut &mut v);
 
-    use_slice(&v[]);    // what you have to write today
+    use_slice(&v[..]);  // what you have to write today
     use_slice(&v);      // what you'd be able to write
     use_slice(&&&&&&v);
     use_slice(&mut &&&&&v);
@@ -59,7 +59,7 @@ fn use_vec(mut v: Vec<u8>) {
 }
 
 fn use_vec_ref(v: &Vec<u8>) {
-    use_slice(&v[]);    // what you have to write today
+    use_slice(&v[..]);  // what you have to write today
     use_slice(v);       // what you'd be able to write
     use_slice(&&&&&&v);
     use_slice(&mut &&&&&v);
diff --git a/src/test/run-pass/deriving-encodable-decodable.rs b/src/test/run-pass/deriving-encodable-decodable.rs
index 8c93f1ec78d..ea43163775c 100644
--- a/src/test/run-pass/deriving-encodable-decodable.rs
+++ b/src/test/run-pass/deriving-encodable-decodable.rs
@@ -59,7 +59,7 @@ fn roundtrip<'a, T: Rand + Eq + Encodable<Encoder<'a>> +
     let mut w = Vec::new();
     let mut e = Encoder::new(&mut w);
     obj.encode(&mut e);
-    let doc = rbml::Doc::new(&w[]);
+    let doc = rbml::Doc::new(&w);
     let mut dec = Decoder::new(doc);
     let obj2 = Decodable::decode(&mut dec);
     assert!(obj == obj2);
diff --git a/src/test/run-pass/foreach-external-iterators-break.rs b/src/test/run-pass/foreach-external-iterators-break.rs
index e9e8c3f0929..25d625e27f6 100644
--- a/src/test/run-pass/foreach-external-iterators-break.rs
+++ b/src/test/run-pass/foreach-external-iterators-break.rs
@@ -11,7 +11,7 @@
 pub fn main() {
     let x = [1; 100];
     let mut y = 0;
-    for i in &x[] {
+    for i in &x[..] {
         if y > 10 {
             break;
         }
diff --git a/src/test/run-pass/foreach-external-iterators-nested.rs b/src/test/run-pass/foreach-external-iterators-nested.rs
index 6acfbc95317..3817e1b0eda 100644
--- a/src/test/run-pass/foreach-external-iterators-nested.rs
+++ b/src/test/run-pass/foreach-external-iterators-nested.rs
@@ -13,8 +13,8 @@ pub fn main() {
     let y = [2; 100];
     let mut p = 0;
     let mut q = 0;
-    for i in &x[] {
-        for j in &y[] {
+    for i in &x[..] {
+        for j in &y[..] {
             p += *j;
         }
         q += *i + p;
diff --git a/src/test/run-pass/foreach-external-iterators.rs b/src/test/run-pass/foreach-external-iterators.rs
index 2f154be659d..8403a1669ff 100644
--- a/src/test/run-pass/foreach-external-iterators.rs
+++ b/src/test/run-pass/foreach-external-iterators.rs
@@ -11,7 +11,7 @@
 pub fn main() {
     let x = [1; 100];
     let mut y = 0;
-    for i in &x[] {
+    for i in &x[..] {
         y += *i
     }
     assert!(y == 100);
diff --git a/src/test/run-pass/issue-8898.rs b/src/test/run-pass/issue-8898.rs
index 379b8f7700e..b1c443dd0c5 100644
--- a/src/test/run-pass/issue-8898.rs
+++ b/src/test/run-pass/issue-8898.rs
@@ -18,9 +18,9 @@ pub fn main() {
     let x  = [(), ()];
     let slice = &x[..1];
 
-    assert_repr_eq(&abc[], "[1, 2, 3]".to_string());
-    assert_repr_eq(&tf[], "[true, false]".to_string());
-    assert_repr_eq(&x[], "[(), ()]".to_string());
+    assert_repr_eq(&abc[..], "[1, 2, 3]".to_string());
+    assert_repr_eq(&tf[..], "[true, false]".to_string());
+    assert_repr_eq(&x[..], "[(), ()]".to_string());
     assert_repr_eq(slice, "[()]".to_string());
-    assert_repr_eq(&x[], "[(), ()]".to_string());
+    assert_repr_eq(&x[..], "[(), ()]".to_string());
 }
diff --git a/src/test/run-pass/range.rs b/src/test/run-pass/range.rs
index 11e8bfa48f6..5d2337e3819 100644
--- a/src/test/run-pass/range.rs
+++ b/src/test/run-pass/range.rs
@@ -14,6 +14,7 @@ fn foo() -> int { 42 }
 
 // Test that range syntax works in return statements
 fn return_range_to() -> ::std::ops::RangeTo<i32> { return ..1; }
+fn return_full_range() -> ::std::ops::RangeFull { return ..; }
 
 pub fn main() {
     let mut count = 0;
diff --git a/src/test/run-pass/ranges-precedence.rs b/src/test/run-pass/ranges-precedence.rs
index c947220f1f8..cd490948516 100644
--- a/src/test/run-pass/ranges-precedence.rs
+++ b/src/test/run-pass/ranges-precedence.rs
@@ -55,5 +55,8 @@ fn main() {
 
     let x = [1]..[2];
     assert!(x == (([1])..([2])));
+
+    let y = ..;
+    assert!(y == (..));
 }
 
diff --git a/src/test/run-pass/repeated-vector-syntax.rs b/src/test/run-pass/repeated-vector-syntax.rs
index 6a1384ff933..6d72e9774dc 100644
--- a/src/test/run-pass/repeated-vector-syntax.rs
+++ b/src/test/run-pass/repeated-vector-syntax.rs
@@ -13,9 +13,9 @@ pub fn main() {
     let y = [ 0; 1 ];
 
     print!("[");
-    for xi in &x[] {
-        print!("{:?}, ", &xi[]);
+    for xi in &x[..] {
+        print!("{:?}, ", &xi[..]);
     }
     println!("]");
-    println!("{:?}", &y[]);
+    println!("{:?}", &y[..]);
 }
diff --git a/src/test/run-pass/slice-2.rs b/src/test/run-pass/slice-2.rs
index 43e517404cb..6e256be69da 100644
--- a/src/test/run-pass/slice-2.rs
+++ b/src/test/run-pass/slice-2.rs
@@ -13,7 +13,7 @@
 fn main() {
     let x: &[int] = &[1, 2, 3, 4, 5];
     let cmp: &[int] = &[1, 2, 3, 4, 5];
-    assert!(&x[] == cmp);
+    assert!(&x[..] == cmp);
     let cmp: &[int] = &[3, 4, 5];
     assert!(&x[2..] == cmp);
     let cmp: &[int] = &[1, 2, 3];
@@ -23,7 +23,7 @@ fn main() {
 
     let x: Vec<int> = vec![1, 2, 3, 4, 5];
     let cmp: &[int] = &[1, 2, 3, 4, 5];
-    assert!(&x[] == cmp);
+    assert!(&x[..] == cmp);
     let cmp: &[int] = &[3, 4, 5];
     assert!(&x[2..] == cmp);
     let cmp: &[int] = &[1, 2, 3];
@@ -34,7 +34,7 @@ fn main() {
     let x: &mut [int] = &mut [1, 2, 3, 4, 5];
     {
         let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
-        assert!(&mut x[] == cmp);
+        assert!(&mut x[..] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [3, 4, 5];
@@ -52,7 +52,7 @@ fn main() {
     let mut x: Vec<int> = vec![1, 2, 3, 4, 5];
     {
         let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
-        assert!(&mut x[] == cmp);
+        assert!(&mut x[..] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [3, 4, 5];
diff --git a/src/test/run-pass/slice.rs b/src/test/run-pass/slice.rs
index 81db525db28..59fb24ffc02 100644
--- a/src/test/run-pass/slice.rs
+++ b/src/test/run-pass/slice.rs
@@ -80,11 +80,11 @@ impl IndexMut<RangeFull> for Foo {
 
 fn main() {
     let mut x = Foo;
-    &x[];
+    &x[..];
     &x[Foo..];
     &x[..Foo];
     &x[Foo..Foo];
-    &mut x[];
+    &mut x[..];
     &mut x[Foo..];
     &mut x[..Foo];
     &mut x[Foo..Foo];