]> git.lizzy.rs Git - rust.git/commitdiff
fix rpass/cfail tests
authorJorge Aparicio <japaricious@gmail.com>
Sat, 3 Jan 2015 15:40:36 +0000 (10:40 -0500)
committerJorge Aparicio <japaricious@gmail.com>
Sat, 3 Jan 2015 21:30:49 +0000 (16:30 -0500)
src/test/compile-fail/borrowck-overloaded-index-2.rs
src/test/compile-fail/borrowck-overloaded-index-autoderef.rs
src/test/compile-fail/borrowck-overloaded-index.rs
src/test/compile-fail/dst-index.rs
src/test/run-pass/dst-index.rs
src/test/run-pass/issue-15734.rs
src/test/run-pass/operator-overloading.rs
src/test/run-pass/overloaded-index-assoc-list.rs
src/test/run-pass/overloaded-index-autoderef.rs
src/test/run-pass/overloaded-index-in-field.rs
src/test/run-pass/overloaded-index.rs

index 01afe405d5e12828589d383b9bdc252ed173f7bb..87e647d16ddf84861910671b4391c30cb41d4647 100644 (file)
@@ -8,13 +8,17 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(associated_types)]
+
 use std::ops::Index;
 
 struct MyVec<T> {
     data: Vec<T>,
 }
 
-impl<T> Index<uint, T> for MyVec<T> {
+impl<T> Index<uint> for MyVec<T> {
+    type Output = T;
+
     fn index(&self, &i: &uint) -> &T {
         &self.data[i]
     }
index e8949d4b30befd55320d2672a994b0d14d3343cc..e7bd7cdf0b79de2be624f24f04589d85aea334f1 100644 (file)
@@ -11,6 +11,8 @@
 // Test that we still see borrowck errors of various kinds when using
 // indexing and autoderef in combination.
 
+#![feature(associated_types)]
+
 use std::ops::{Index, IndexMut};
 
 struct Foo {
@@ -18,7 +20,9 @@ struct Foo {
     y: int,
 }
 
-impl Index<String,int> for Foo {
+impl Index<String> for Foo {
+    type Output = int;
+
     fn index<'a>(&'a self, z: &String) -> &'a int {
         if z.as_slice() == "x" {
             &self.x
@@ -28,7 +32,9 @@ fn index<'a>(&'a self, z: &String) -> &'a int {
     }
 }
 
-impl IndexMut<String,int> for Foo {
+impl IndexMut<String> for Foo {
+    type Output = int;
+
     fn index_mut<'a>(&'a mut self, z: &String) -> &'a mut int {
         if z.as_slice() == "x" {
             &mut self.x
index 933d0f15e4e7064219432bc368abcf2390750120..532f32ce770a6bbe280ee2e051c626c32d9d96ee 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(associated_types)]
+
 use std::ops::{Index, IndexMut};
 
 struct Foo {
@@ -15,7 +17,9 @@ struct Foo {
     y: int,
 }
 
-impl Index<String,int> for Foo {
+impl Index<String> for Foo {
+    type Output = int;
+
     fn index<'a>(&'a self, z: &String) -> &'a int {
         if z.as_slice() == "x" {
             &self.x
@@ -25,7 +29,9 @@ fn index<'a>(&'a self, z: &String) -> &'a int {
     }
 }
 
-impl IndexMut<String,int> for Foo {
+impl IndexMut<String> for Foo {
+    type Output = int;
+
     fn index_mut<'a>(&'a mut self, z: &String) -> &'a mut int {
         if z.as_slice() == "x" {
             &mut self.x
@@ -39,7 +45,9 @@ struct Bar {
     x: int,
 }
 
-impl Index<int,int> for Bar {
+impl Index<int> for Bar {
+    type Output = int;
+
     fn index<'a>(&'a self, z: &int) -> &'a int {
         &self.x
     }
index af97c864dc81a9b88a2bbbc060b4cbff3b555d07..06d20c3361bc96e17c2d2e16383eeac183cc69e9 100644 (file)
@@ -11,6 +11,8 @@
 // Test that overloaded index expressions with DST result types
 // can't be used as rvalues
 
+#![feature(associated_types)]
+
 use std::ops::Index;
 use std::fmt::Show;
 
@@ -18,7 +20,9 @@
 
 impl Copy for S {}
 
-impl Index<uint, str> for S {
+impl Index<uint> for S {
+    type Output = str;
+
     fn index<'a>(&'a self, _: &uint) -> &'a str {
         "hello"
     }
@@ -28,7 +32,9 @@ fn index<'a>(&'a self, _: &uint) -> &'a str {
 
 impl Copy for T {}
 
-impl Index<uint, Show + 'static> for T {
+impl Index<uint> for T {
+    type Output = Show + 'static;
+
     fn index<'a>(&'a self, idx: &uint) -> &'a (Show + 'static) {
         static x: uint = 42;
         &x
index eaf7131e1d878a36261f57ec9c8f354b7c4e5273..6a69bfc248f16ec5794a31073657ebb1487f326c 100644 (file)
 // Test that overloaded index expressions with DST result types
 // work and don't ICE.
 
+#![feature(associated_types)]
+
 use std::ops::Index;
 use std::fmt::Show;
 
 struct S;
 
-impl Index<uint, str> for S {
+impl Index<uint> for S {
+    type Output = str;
+
     fn index<'a>(&'a self, _: &uint) -> &'a str {
         "hello"
     }
@@ -24,7 +28,9 @@ fn index<'a>(&'a self, _: &uint) -> &'a str {
 
 struct T;
 
-impl Index<uint, Show + 'static> for T {
+impl Index<uint> for T {
+    type Output = Show + 'static;
+
     fn index<'a>(&'a self, idx: &uint) -> &'a (Show + 'static) {
         static x: uint = 42;
         &x
index e99b1dc5befb00fdf1d2e11d80cc847b0516fe7c..f261098f5381137e684f3faa8ca21af40a4b08bb 100644 (file)
@@ -10,7 +10,8 @@
 
 // If `Index` used an associated type for its output, this test would
 // work more smoothly.
-#![feature(old_orphan_check)]
+
+#![feature(associated_types, old_orphan_check)]
 
 use std::ops::Index;
 
@@ -25,13 +26,17 @@ fn row<'a>(&'a self, row: uint) -> Row<&'a Mat<T>> {
     }
 }
 
-impl<T> Index<(uint, uint), T> for Mat<T> {
+impl<T> Index<(uint, uint)> for Mat<T> {
+    type Output = T;
+
     fn index<'a>(&'a self, &(row, col): &(uint, uint)) -> &'a T {
         &self.data[row * self.cols + col]
     }
 }
 
-impl<'a, T> Index<(uint, uint), T> for &'a Mat<T> {
+impl<'a, T> Index<(uint, uint)> for &'a Mat<T> {
+    type Output = T;
+
     fn index<'b>(&'b self, index: &(uint, uint)) -> &'b T {
         (*self).index(index)
     }
@@ -39,7 +44,9 @@ fn index<'b>(&'b self, index: &(uint, uint)) -> &'b T {
 
 struct Row<M> { mat: M, row: uint, }
 
-impl<T, M: Index<(uint, uint), T>> Index<uint, T> for Row<M> {
+impl<T, M: Index<(uint, uint), Output=T>> Index<uint> for Row<M> {
+    type Output = T;
+
     fn index<'a>(&'a self, col: &uint) -> &'a T {
         &self.mat[(self.row, *col)]
     }
index 58c433e570e76fff9361ad409ef3dfeacc648839..41e7586f1e3db33fbe45341dea110152dbb7ccbd 100644 (file)
@@ -51,7 +51,9 @@ fn not(self) -> Point {
     }
 }
 
-impl ops::Index<bool,int> for Point {
+impl ops::Index<bool> for Point {
+    type Output = int;
+
     fn index(&self, x: &bool) -> &int {
         if *x {
             &self.x
index 0347f8a29df28b3e739f2917b39c592b7ceea16a..77bb981cfd9b9a3f0fe06d389a9402c4cd4a1197 100644 (file)
@@ -11,6 +11,8 @@
 // Test overloading of the `[]` operator.  In particular test that it
 // takes its argument *by reference*.
 
+#![feature(associated_types)]
+
 use std::ops::Index;
 
 struct AssociationList<K,V> {
@@ -28,7 +30,9 @@ fn push(&mut self, key: K, value: V) {
     }
 }
 
-impl<K: PartialEq + std::fmt::Show, V:Clone> Index<K,V> for AssociationList<K,V> {
+impl<K: PartialEq + std::fmt::Show, V:Clone> Index<K> for AssociationList<K,V> {
+    type Output = V;
+
     fn index<'a>(&'a self, index: &K) -> &'a V {
         for pair in self.pairs.iter() {
             if pair.key == *index {
index dcb0c40c6088a95eecc651f32359efe8839ada78..d141234287d13e8e4452485329b144d22647b29a 100644 (file)
@@ -10,6 +10,8 @@
 
 // Test overloaded indexing combined with autoderef.
 
+#![feature(associated_types)]
+
 use std::ops::{Index, IndexMut};
 
 struct Foo {
@@ -17,7 +19,9 @@ struct Foo {
     y: int,
 }
 
-impl Index<int,int> for Foo {
+impl Index<int> for Foo {
+    type Output = int;
+
     fn index(&self, z: &int) -> &int {
         if *z == 0 {
             &self.x
@@ -27,7 +31,9 @@ fn index(&self, z: &int) -> &int {
     }
 }
 
-impl IndexMut<int,int> for Foo {
+impl IndexMut<int> for Foo {
+    type Output = int;
+
     fn index_mut(&mut self, z: &int) -> &mut int {
         if *z == 0 {
             &mut self.x
index 1c06ed64fc7b8a6112ad6d8e778869b857403d85..9c6afc0912d0630a471b30bcfb782c30f08fedd9 100644 (file)
@@ -11,6 +11,8 @@
 // Test using overloaded indexing when the "map" is stored in a
 // field. This caused problems at some point.
 
+#![feature(associated_types)]
+
 use std::ops::Index;
 
 struct Foo {
@@ -22,7 +24,9 @@ struct Bar {
     foo: Foo
 }
 
-impl Index<int,int> for Foo {
+impl Index<int> for Foo {
+    type Output = int;
+
     fn index(&self, z: &int) -> &int {
         if *z == 0 {
             &self.x
index fdf7e7e2cbb13760197f4687aa5163aba340945a..fe09b47cf0a789bbb707b2c16d0baf15be8e6ecc 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(associated_types)]
+
 use std::ops::{Index, IndexMut};
 
 struct Foo {
@@ -15,7 +17,9 @@ struct Foo {
     y: int,
 }
 
-impl Index<int,int> for Foo {
+impl Index<int> for Foo {
+    type Output = int;
+
     fn index(&self, z: &int) -> &int {
         if *z == 0 {
             &self.x
@@ -25,7 +29,9 @@ fn index(&self, z: &int) -> &int {
     }
 }
 
-impl IndexMut<int,int> for Foo {
+impl IndexMut<int> for Foo {
+    type Output = int;
+
     fn index_mut(&mut self, z: &int) -> &mut int {
         if *z == 0 {
             &mut self.x