about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/compile-fail/borrowck-overloaded-index-2.rs6
-rw-r--r--src/test/compile-fail/borrowck-overloaded-index-autoderef.rs10
-rw-r--r--src/test/compile-fail/borrowck-overloaded-index.rs14
-rw-r--r--src/test/compile-fail/dst-index.rs10
-rw-r--r--src/test/run-pass/dst-index.rs10
-rw-r--r--src/test/run-pass/issue-15734.rs15
-rw-r--r--src/test/run-pass/operator-overloading.rs4
-rw-r--r--src/test/run-pass/overloaded-index-assoc-list.rs6
-rw-r--r--src/test/run-pass/overloaded-index-autoderef.rs10
-rw-r--r--src/test/run-pass/overloaded-index-in-field.rs6
-rw-r--r--src/test/run-pass/overloaded-index.rs10
11 files changed, 80 insertions, 21 deletions
diff --git a/src/test/compile-fail/borrowck-overloaded-index-2.rs b/src/test/compile-fail/borrowck-overloaded-index-2.rs
index 01afe405d5e..87e647d16dd 100644
--- a/src/test/compile-fail/borrowck-overloaded-index-2.rs
+++ b/src/test/compile-fail/borrowck-overloaded-index-2.rs
@@ -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]
     }
diff --git a/src/test/compile-fail/borrowck-overloaded-index-autoderef.rs b/src/test/compile-fail/borrowck-overloaded-index-autoderef.rs
index e8949d4b30b..e7bd7cdf0b7 100644
--- a/src/test/compile-fail/borrowck-overloaded-index-autoderef.rs
+++ b/src/test/compile-fail/borrowck-overloaded-index-autoderef.rs
@@ -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 @@ impl Index<String,int> for Foo {
     }
 }
 
-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
diff --git a/src/test/compile-fail/borrowck-overloaded-index.rs b/src/test/compile-fail/borrowck-overloaded-index.rs
index 933d0f15e4e..532f32ce770 100644
--- a/src/test/compile-fail/borrowck-overloaded-index.rs
+++ b/src/test/compile-fail/borrowck-overloaded-index.rs
@@ -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 @@ impl Index<String,int> for Foo {
     }
 }
 
-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
     }
diff --git a/src/test/compile-fail/dst-index.rs b/src/test/compile-fail/dst-index.rs
index af97c864dc8..06d20c3361b 100644
--- a/src/test/compile-fail/dst-index.rs
+++ b/src/test/compile-fail/dst-index.rs
@@ -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 @@ struct S;
 
 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 @@ struct T;
 
 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
diff --git a/src/test/run-pass/dst-index.rs b/src/test/run-pass/dst-index.rs
index eaf7131e1d8..6a69bfc248f 100644
--- a/src/test/run-pass/dst-index.rs
+++ b/src/test/run-pass/dst-index.rs
@@ -11,12 +11,16 @@
 // 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 @@ impl Index<uint, str> for S {
 
 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
diff --git a/src/test/run-pass/issue-15734.rs b/src/test/run-pass/issue-15734.rs
index e99b1dc5bef..f261098f538 100644
--- a/src/test/run-pass/issue-15734.rs
+++ b/src/test/run-pass/issue-15734.rs
@@ -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 @@ impl<T> 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 @@ impl<'a, T> Index<(uint, uint), T> for &'a Mat<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)]
     }
diff --git a/src/test/run-pass/operator-overloading.rs b/src/test/run-pass/operator-overloading.rs
index 58c433e570e..41e7586f1e3 100644
--- a/src/test/run-pass/operator-overloading.rs
+++ b/src/test/run-pass/operator-overloading.rs
@@ -51,7 +51,9 @@ impl ops::Not for 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
diff --git a/src/test/run-pass/overloaded-index-assoc-list.rs b/src/test/run-pass/overloaded-index-assoc-list.rs
index 0347f8a29df..77bb981cfd9 100644
--- a/src/test/run-pass/overloaded-index-assoc-list.rs
+++ b/src/test/run-pass/overloaded-index-assoc-list.rs
@@ -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 @@ impl<K,V> AssociationList<K,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 {
diff --git a/src/test/run-pass/overloaded-index-autoderef.rs b/src/test/run-pass/overloaded-index-autoderef.rs
index dcb0c40c608..d141234287d 100644
--- a/src/test/run-pass/overloaded-index-autoderef.rs
+++ b/src/test/run-pass/overloaded-index-autoderef.rs
@@ -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 @@ impl Index<int,int> for Foo {
     }
 }
 
-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
diff --git a/src/test/run-pass/overloaded-index-in-field.rs b/src/test/run-pass/overloaded-index-in-field.rs
index 1c06ed64fc7..9c6afc0912d 100644
--- a/src/test/run-pass/overloaded-index-in-field.rs
+++ b/src/test/run-pass/overloaded-index-in-field.rs
@@ -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
diff --git a/src/test/run-pass/overloaded-index.rs b/src/test/run-pass/overloaded-index.rs
index fdf7e7e2cbb..fe09b47cf0a 100644
--- a/src/test/run-pass/overloaded-index.rs
+++ b/src/test/run-pass/overloaded-index.rs
@@ -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 @@ impl Index<int,int> for Foo {
     }
 }
 
-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