about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs11
-rw-r--r--src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs6
-rw-r--r--src/test/compile-fail/wrong-mul-method-signature.rs12
3 files changed, 22 insertions, 7 deletions
diff --git a/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs b/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs
index 1e9fd035f44..000e42b9703 100644
--- a/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs
+++ b/src/test/auxiliary/regions-bounded-method-type-parameters-cross-crate-lib.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 // Check that method bounds declared on traits/impls in a cross-crate
-// scenario work. This is the libary portion of the test.
+// scenario work. This is the library portion of the test.
 
 pub enum MaybeOwned<'a> {
     Owned(int),
@@ -24,10 +24,19 @@ pub struct Inv<'a> { // invariant w/r/t 'a
 // trait, so I'll use that as the template for this test.
 pub trait IntoMaybeOwned<'a> {
     fn into_maybe_owned(self) -> MaybeOwned<'a>;
+
+    // Note: without this `into_inv` method, the trait is
+    // contravariant w/r/t `'a`, since if you look strictly at the
+    // interface, it only returns `'a`. This complicates the
+    // downstream test since it wants invariance to force an error.
+    // Hence we add this method.
+    fn into_inv(self) -> Inv<'a>;
+
     fn bigger_region<'b:'a>(self, b: Inv<'b>);
 }
 
 impl<'a> IntoMaybeOwned<'a> for Inv<'a> {
     fn into_maybe_owned(self) -> MaybeOwned<'a> { fail!() }
+    fn into_inv(self) -> Inv<'a> { fail!() }
     fn bigger_region<'b:'a>(self, b: Inv<'b>) { fail!() }
 }
diff --git a/src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs b/src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs
index 06f26800b50..1705cfec6e2 100644
--- a/src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs
+++ b/src/test/compile-fail/regions-bounded-method-type-parameters-cross-crate.rs
@@ -18,15 +18,15 @@ use lib::Inv;
 use lib::MaybeOwned;
 use lib::IntoMaybeOwned;
 
-fn call_into_maybe_owned<'a,F:IntoMaybeOwned<'a>>(f: F) {
+fn call_into_maybe_owned<'x,F:IntoMaybeOwned<'x>>(f: F) {
     // Exercise a code path I found to be buggy. We were not encoding
     // the region parameters from the receiver correctly on trait
     // methods.
     f.into_maybe_owned();
 }
 
-fn call_bigger_region<'a, 'b>(a: Inv<'a>, b: Inv<'b>) {
-    // Here the value provided for 'y is 'b, and hence 'b:'a does not hold.
+fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) {
+    // Here the value provided for 'y is 'y, and hence 'y:'x does not hold.
     a.bigger_region(b) //~ ERROR cannot infer
 }
 
diff --git a/src/test/compile-fail/wrong-mul-method-signature.rs b/src/test/compile-fail/wrong-mul-method-signature.rs
index e3aed148a23..aead739d3e0 100644
--- a/src/test/compile-fail/wrong-mul-method-signature.rs
+++ b/src/test/compile-fail/wrong-mul-method-signature.rs
@@ -58,7 +58,13 @@ impl Mul<f64, i32> for Vec3 {
 }
 
 pub fn main() {
-    Vec1 { x: 1.0 } * 2.0;
-    Vec2 { x: 1.0, y: 2.0 } * 2.0;
-    Vec3 { x: 1.0, y: 2.0, z: 3.0 } * 2.0;
+    // Check that the usage goes from the trait declaration:
+
+    let x: Vec1 = Vec1 { x: 1.0 } * 2.0; // this is OK
+
+    let x: Vec2 = Vec2 { x: 1.0, y: 2.0 } * 2.0; // trait had reversed order
+    //~^ ERROR mismatched types
+    //~^^ ERROR mismatched types
+
+    let x: i32 = Vec3 { x: 1.0, y: 2.0, z: 3.0 } * 2.0;
 }