about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorggomez <guillaume1.gomez@gmail.com>2016-05-03 17:03:00 +0200
committerggomez <guillaume1.gomez@gmail.com>2016-05-11 13:24:22 +0200
commit61e6169ffeb00461be77c87675d5ce250f99d503 (patch)
treedb0ae35476ed77afb1b7d98bbc23ffc48a045d77 /src/test
parentb8fad79a07ef287a80959ec8c4f82e7e6803b053 (diff)
downloadrust-61e6169ffeb00461be77c87675d5ce250f99d503.tar.gz
rust-61e6169ffeb00461be77c87675d5ce250f99d503.zip
Improve weight algorithm and tests
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/check_on_unimplemented.rs1
-rw-r--r--src/test/compile-fail/on_unimplemented.rs34
2 files changed, 27 insertions, 8 deletions
diff --git a/src/test/compile-fail/check_on_unimplemented.rs b/src/test/compile-fail/check_on_unimplemented.rs
index 042fdb070f4..4471b625d79 100644
--- a/src/test/compile-fail/check_on_unimplemented.rs
+++ b/src/test/compile-fail/check_on_unimplemented.rs
@@ -31,4 +31,5 @@ impl Index<usize> for [i32] {
 fn main() {
     Index::<u32>::index(&[1, 2, 3] as &[i32], 2u32); //~ ERROR E0277
                                                      //~| NOTE a usize is required
+                                                     //~| NOTE required by
 }
diff --git a/src/test/compile-fail/on_unimplemented.rs b/src/test/compile-fail/on_unimplemented.rs
index beba3bd04c1..1a5b5ff206a 100644
--- a/src/test/compile-fail/on_unimplemented.rs
+++ b/src/test/compile-fail/on_unimplemented.rs
@@ -19,15 +19,11 @@ trait Index<Idx: ?Sized> {
     fn index(&self, index: Idx) -> &Self::Output;
 }
 
-struct Foo {
-    i: usize,
-}
-
-#[rustc_on_unimplemented = "a Foo is required to index into a slice"]
-impl Index<Foo> for [i32] {
+#[rustc_on_unimplemented = "a isize is required to index into a slice"]
+impl Index<isize> for [i32] {
     type Output = i32;
-    fn index(&self, index: Foo) -> &i32 {
-        &self[index.i]
+    fn index(&self, index: isize) -> &i32 {
+        &self[index as usize]
     }
 }
 
@@ -39,8 +35,30 @@ impl Index<usize> for [i32] {
     }
 }
 
+trait Foo<A, B> {
+    fn f(&self, a: &A, b: &B);
+}
+
+#[rustc_on_unimplemented = "two i32 Foo trait takes"]
+impl Foo<i32, i32> for [i32] {
+    fn f(&self, a: &i32, b: &i32) {}
+}
+
+#[rustc_on_unimplemented = "two u32 Foo trait takes"]
+impl Foo<u32, u32> for [i32] {
+    fn f(&self, a: &u32, b: &u32) {}
+}
+
 #[rustc_error]
 fn main() {
     Index::<u32>::index(&[1, 2, 3] as &[i32], 2u32); //~ ERROR E0277
                                                      //~| NOTE a usize is required
+                                                     //~| NOTE required by
+    Index::<i32>::index(&[1, 2, 3] as &[i32], 2i32); //~ ERROR E0277
+                                                     //~| NOTE a isize is required
+                                                     //~| NOTE required by
+
+    Foo::<usize, usize>::f(&[1, 2, 3] as &[i32], &2usize, &2usize); //~ ERROR E0277
+                                                                    //~| NOTE two u32 Foo trait
+                                                                    //~| NOTE required by
 }