Skip to content

Commit 7d527fa

Browse files
author
Ulrik Sverdrup
committed
Implement pretty-printing of .. and update tests.
Update tests to change all `&expr[]` to `&expr[..]` to make sure pretty printing passes.
1 parent 7523914 commit 7d527fa

13 files changed

+23
-28
lines changed

src/libsyntax/print/pprust.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1813,9 +1813,7 @@ impl<'a> State<'a> {
18131813
if let &Some(ref e) = start {
18141814
try!(self.print_expr(&**e));
18151815
}
1816-
if start.is_some() || end.is_some() {
1817-
try!(word(&mut self.s, ".."));
1818-
}
1816+
try!(word(&mut self.s, ".."));
18191817
if let &Some(ref e) = end {
18201818
try!(self.print_expr(&**e));
18211819
}

src/test/bench/shootout-fasta-redux.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl<'a, W: Writer> RandomFasta<'a, W> {
180180

181181
fn nextc(&mut self) -> u8 {
182182
let r = self.rng(1.0);
183-
for a in &self.lookup[] {
183+
for a in &self.lookup[..] {
184184
if a.p >= r {
185185
return a.c;
186186
}

src/test/compile-fail/packed-struct-generic-transmute.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ fn main() {
3232
let foo = Foo { bar: [1u8, 2, 3, 4, 5], baz: 10i32 };
3333
unsafe {
3434
let oof: Oof<[u8; 5], i32> = mem::transmute(foo);
35-
println!("{:?} {:?}", &oof.rab[], oof.zab);
35+
println!("{:?} {:?}", &oof.rab[..], oof.zab);
3636
}
3737
}

src/test/run-pass/auto-encode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn test_rbml<'a, 'b, A:
3535
let mut rbml_w = EBwriter::Encoder::new(&mut wr);
3636
a1.encode(&mut rbml_w);
3737

38-
let d: serialize::rbml::Doc<'a> = EBDoc::new(&wr[]);
38+
let d: serialize::rbml::Doc<'a> = EBDoc::new(&wr);
3939
let mut decoder: EBReader::Decoder<'a> = EBreader::Decoder::new(d);
4040
let a2: A = Decodable::decode(&mut decoder);
4141
assert!(*a1 == a2);

src/test/run-pass/coerce-overloaded-autoderef.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@ fn use_slice(_: &[u8]) {}
4747
fn use_slice_mut(_: &mut [u8]) {}
4848

4949
fn use_vec(mut v: Vec<u8>) {
50-
use_slice_mut(&mut v[]); // what you have to write today
51-
use_slice_mut(&mut v); // what you'd be able to write
50+
use_slice_mut(&mut v[..]); // what you have to write today
51+
use_slice_mut(&mut v); // what you'd be able to write
5252
use_slice_mut(&mut &mut &mut v);
5353

54-
use_slice(&v[]); // what you have to write today
54+
use_slice(&v[..]); // what you have to write today
5555
use_slice(&v); // what you'd be able to write
5656
use_slice(&&&&&&v);
5757
use_slice(&mut &&&&&v);
5858
use_slice(&&&mut &&&v);
5959
}
6060

6161
fn use_vec_ref(v: &Vec<u8>) {
62-
use_slice(&v[]); // what you have to write today
62+
use_slice(&v[..]); // what you have to write today
6363
use_slice(v); // what you'd be able to write
6464
use_slice(&&&&&&v);
6565
use_slice(&mut &&&&&v);

src/test/run-pass/deriving-encodable-decodable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn roundtrip<'a, T: Rand + Eq + Encodable<Encoder<'a>> +
5959
let mut w = Vec::new();
6060
let mut e = Encoder::new(&mut w);
6161
obj.encode(&mut e);
62-
let doc = rbml::Doc::new(&w[]);
62+
let doc = rbml::Doc::new(&w);
6363
let mut dec = Decoder::new(doc);
6464
let obj2 = Decodable::decode(&mut dec);
6565
assert!(obj == obj2);

src/test/run-pass/foreach-external-iterators-break.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
pub fn main() {
1212
let x = [1; 100];
1313
let mut y = 0;
14-
for i in &x[] {
14+
for i in &x[..] {
1515
if y > 10 {
1616
break;
1717
}

src/test/run-pass/foreach-external-iterators-nested.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ pub fn main() {
1313
let y = [2; 100];
1414
let mut p = 0;
1515
let mut q = 0;
16-
for i in &x[] {
17-
for j in &y[] {
16+
for i in &x[..] {
17+
for j in &y[..] {
1818
p += *j;
1919
}
2020
q += *i + p;

src/test/run-pass/foreach-external-iterators.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
pub fn main() {
1212
let x = [1; 100];
1313
let mut y = 0;
14-
for i in &x[] {
14+
for i in &x[..] {
1515
y += *i
1616
}
1717
assert!(y == 100);

src/test/run-pass/issue-8898.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ pub fn main() {
1818
let x = [(), ()];
1919
let slice = &x[..1];
2020

21-
assert_repr_eq(&abc[], "[1, 2, 3]".to_string());
22-
assert_repr_eq(&tf[], "[true, false]".to_string());
23-
assert_repr_eq(&x[], "[(), ()]".to_string());
21+
assert_repr_eq(&abc[..], "[1, 2, 3]".to_string());
22+
assert_repr_eq(&tf[..], "[true, false]".to_string());
23+
assert_repr_eq(&x[..], "[(), ()]".to_string());
2424
assert_repr_eq(slice, "[()]".to_string());
25-
assert_repr_eq(&x[], "[(), ()]".to_string());
25+
assert_repr_eq(&x[..], "[(), ()]".to_string());
2626
}

src/test/run-pass/repeated-vector-syntax.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ pub fn main() {
1313
let y = [ 0; 1 ];
1414

1515
print!("[");
16-
for xi in &x[] {
17-
print!("{:?}, ", &xi[]);
16+
for xi in &x[..] {
17+
print!("{:?}, ", &xi[..]);
1818
}
1919
println!("]");
20-
println!("{:?}", &y[]);
20+
println!("{:?}", &y[..]);
2121
}

src/test/run-pass/slice-2.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
fn main() {
1414
let x: &[int] = &[1, 2, 3, 4, 5];
1515
let cmp: &[int] = &[1, 2, 3, 4, 5];
16-
assert!(&x[] == cmp);
1716
assert!(&x[..] == cmp);
1817
let cmp: &[int] = &[3, 4, 5];
1918
assert!(&x[2..] == cmp);
@@ -24,7 +23,7 @@ fn main() {
2423

2524
let x: Vec<int> = vec![1, 2, 3, 4, 5];
2625
let cmp: &[int] = &[1, 2, 3, 4, 5];
27-
assert!(&x[] == cmp);
26+
assert!(&x[..] == cmp);
2827
let cmp: &[int] = &[3, 4, 5];
2928
assert!(&x[2..] == cmp);
3029
let cmp: &[int] = &[1, 2, 3];
@@ -35,7 +34,6 @@ fn main() {
3534
let x: &mut [int] = &mut [1, 2, 3, 4, 5];
3635
{
3736
let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
38-
assert!(&mut x[] == cmp);
3937
assert!(&mut x[..] == cmp);
4038
}
4139
{
@@ -54,7 +52,6 @@ fn main() {
5452
let mut x: Vec<int> = vec![1, 2, 3, 4, 5];
5553
{
5654
let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
57-
assert!(&mut x[] == cmp);
5855
assert!(&mut x[..] == cmp);
5956
}
6057
{

src/test/run-pass/slice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ impl IndexMut<RangeFull> for Foo {
8080

8181
fn main() {
8282
let mut x = Foo;
83-
&x[];
83+
&x[..];
8484
&x[Foo..];
8585
&x[..Foo];
8686
&x[Foo..Foo];
87-
&mut x[];
87+
&mut x[..];
8888
&mut x[Foo..];
8989
&mut x[..Foo];
9090
&mut x[Foo..Foo];

0 commit comments

Comments
 (0)