]> git.lizzy.rs Git - rust.git/commitdiff
Patch tests and create new tests related to projection from a HRTB.
authorNiko Matsakis <niko@alum.mit.edu>
Fri, 26 Dec 2014 20:37:56 +0000 (15:37 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 30 Dec 2014 14:36:22 +0000 (09:36 -0500)
24 files changed:
src/test/compile-fail/associated-types-eq-2.rs
src/test/compile-fail/associated-types-eq-3.rs
src/test/compile-fail/associated-types-eq-hr.rs [new file with mode: 0644]
src/test/compile-fail/associated-types-in-ambiguous-context.rs
src/test/compile-fail/associated-types-in-wrong-context.rs [deleted file]
src/test/compile-fail/associated-types-incomplete-object.rs [new file with mode: 0644]
src/test/compile-fail/associated-types-no-suitable-bound.rs [new file with mode: 0644]
src/test/compile-fail/associated-types-no-suitable-supertrait.rs [new file with mode: 0644]
src/test/compile-fail/associated-types-project-from-hrtb-explicit.rs [new file with mode: 0644]
src/test/compile-fail/associated-types-project-from-hrtb-in-fn [new file with mode: 0755]
src/test/compile-fail/associated-types-project-from-hrtb-in-fn-body.rs [new file with mode: 0644]
src/test/compile-fail/associated-types-project-from-hrtb-in-fn.rs [new file with mode: 0644]
src/test/compile-fail/associated-types-project-from-hrtb-in-struct.rs [new file with mode: 0644]
src/test/compile-fail/associated-types-project-from-hrtb-in-trait-method.rs [new file with mode: 0644]
src/test/compile-fail/issue-19081.rs [deleted file]
src/test/compile-fail/issue-19121.rs [deleted file]
src/test/compile-fail/trait-bounds-on-structs-and-enums.rs
src/test/compile-fail/unsized-inherent-impl-self-type.rs [new file with mode: 0644]
src/test/compile-fail/unsized-trait-impl-self-type.rs [new file with mode: 0644]
src/test/compile-fail/unsized-trait-impl-trait-arg.rs [new file with mode: 0644]
src/test/compile-fail/unsized4.rs
src/test/compile-fail/unsized7.rs
src/test/run-pass/issue-19081.rs [new file with mode: 0644]
src/test/run-pass/issue-19121.rs [new file with mode: 0644]

index 652bf4fb57753bf38a6ea1a626e450724539cdbe..b89cdd8c0eed7c233ca1efc07385c85fdf382694 100644 (file)
@@ -25,6 +25,7 @@ impl Foo for int {
     fn boo(&self) -> uint { 42 }
 }
 
-fn baz<I: Foo>(x: &<I as Foo<A=Bar>>::A) {} //~ERROR equality constraints are not allowed in this
+fn baz<I: Foo>(x: &<I as Foo<A=Bar>>::A) {}
+//~^ ERROR associated type bindings are not allowed here
 
 pub fn main() {}
index 880b2e9cc4a77ebf7813e317bd2bc0f4582f27e2..e5974925d7370b6d813962e3cfa8858f6f08c6d6 100644 (file)
@@ -43,6 +43,6 @@ pub fn baz(x: &Foo<A=Bar>) {
 
 pub fn main() {
     let a = 42i;
-    foo1(a); //~ERROR the trait `Foo` is not implemented for the type `int`
-    baz(&a); //~ERROR the trait `Foo` is not implemented for the type `int`
+    foo1(a); //~ERROR expected uint, found struct Bar
+    baz(&a); //~ERROR expected uint, found struct Bar
 }
diff --git a/src/test/compile-fail/associated-types-eq-hr.rs b/src/test/compile-fail/associated-types-eq-hr.rs
new file mode 100644 (file)
index 0000000..aad5574
--- /dev/null
@@ -0,0 +1,72 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Check testing of equality constraints in a higher-ranked context.
+
+#![feature(associated_types)]
+
+pub trait TheTrait<T> {
+    type A;
+
+    fn get(&self, t: T) -> Self::A;
+}
+
+struct IntStruct {
+    x: int
+}
+
+impl<'a> TheTrait<&'a int> for IntStruct {
+    type A = &'a int;
+
+    fn get(&self, t: &'a int) -> &'a int {
+        t
+    }
+}
+
+struct UintStruct {
+    x: int
+}
+
+impl<'a> TheTrait<&'a int> for UintStruct {
+    type A = &'a uint;
+
+    fn get(&self, t: &'a int) -> &'a uint {
+        panic!()
+    }
+}
+
+fn foo<T>()
+    where T : for<'x> TheTrait<&'x int, A = &'x int>
+{
+    // ok for IntStruct, but not UintStruct
+}
+
+fn bar<T>()
+    where T : for<'x> TheTrait<&'x int, A = &'x uint>
+{
+    // ok for UintStruct, but not IntStruct
+}
+
+fn baz<T>()
+    where T : for<'x,'y> TheTrait<&'x int, A = &'y int>
+{
+    // not ok for either struct, due to the use of two lifetimes
+}
+
+pub fn main() {
+    foo::<IntStruct>();
+    foo::<UintStruct>(); //~ ERROR type mismatch
+
+    bar::<IntStruct>(); //~ ERROR type mismatch
+    bar::<UintStruct>();
+
+    baz::<IntStruct>(); //~ ERROR type mismatch
+    baz::<UintStruct>(); //~ ERROR type mismatch
+}
index 24de1fa2f78444ecc6b40426dcf355fab96f8669..fcd3e4d1636468379318c1529e6d177801126726 100644 (file)
@@ -18,16 +18,6 @@ trait Get {
 fn get<T:Get,U:Get>(x: T, y: U) -> Get::Value {}
 //~^ ERROR ambiguous associated type
 
-trait Other {
-    fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
-    //~^ ERROR no suitable bound on `Self`
-}
-
-impl<T:Get> Other for T {
-    fn uhoh<U:Get>(&self, foo: U, bar: <(T, U) as Get>::Value) {}
-    //~^ ERROR currently unsupported
-}
-
 trait Grab {
     type Value;
     fn grab(&self) -> Grab::Value;
diff --git a/src/test/compile-fail/associated-types-in-wrong-context.rs b/src/test/compile-fail/associated-types-in-wrong-context.rs
deleted file mode 100644 (file)
index 28a4ad0..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(associated_types)]
-
-trait Get {
-    type Value;
-    fn get(&self) -> <Self as Get>::Value;
-}
-
-struct Struct {
-    x: int,
-}
-
-impl Struct {
-    fn uhoh<T>(foo: <T as Get>::Value) {}
-    //~^ ERROR no suitable bound on `T`
-}
-
-fn main() {
-}
-
diff --git a/src/test/compile-fail/associated-types-incomplete-object.rs b/src/test/compile-fail/associated-types-incomplete-object.rs
new file mode 100644 (file)
index 0000000..7e4e131
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Check that the user gets an errror if they omit a binding from an
+// object type.
+
+#![feature(associated_types)]
+
+pub trait Foo {
+    type A;
+    type B;
+    fn boo(&self) -> <Self as Foo>::A;
+}
+
+struct Bar;
+
+impl Foo for int {
+    type A = uint;
+    type B = char;
+    fn boo(&self) -> uint {
+        42
+    }
+}
+
+pub fn main() {
+    let a = &42i as &Foo<A=uint, B=char>;
+
+    let b = &42i as &Foo<A=uint>;
+    //~^ ERROR the value of the associated type `B` (from the trait `Foo`) must be specified
+
+    let c = &42i as &Foo<B=char>;
+    //~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified
+
+    let d = &42i as &Foo;
+    //~^ ERROR the value of the associated type `A` (from the trait `Foo`) must be specified
+    //~| ERROR the value of the associated type `B` (from the trait `Foo`) must be specified
+}
diff --git a/src/test/compile-fail/associated-types-no-suitable-bound.rs b/src/test/compile-fail/associated-types-no-suitable-bound.rs
new file mode 100644 (file)
index 0000000..6b85620
--- /dev/null
@@ -0,0 +1,29 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(associated_types)]
+
+trait Get {
+    type Value;
+    fn get(&self) -> <Self as Get>::Value;
+}
+
+struct Struct {
+    x: int,
+}
+
+impl Struct {
+    fn uhoh<T>(foo: <T as Get>::Value) {}
+    //~^ ERROR the trait `Get` is not implemented for the type `T`
+}
+
+fn main() {
+}
+
diff --git a/src/test/compile-fail/associated-types-no-suitable-supertrait.rs b/src/test/compile-fail/associated-types-no-suitable-supertrait.rs
new file mode 100644 (file)
index 0000000..c4110a6
--- /dev/null
@@ -0,0 +1,21 @@
+#![feature(associated_types)]
+
+// Check that we get an error when you use `<Self as Get>::Value` in
+// the trait definition but `Self` does not, in fact, implement `Get`.
+
+trait Get {
+    type Value;
+}
+
+trait Other {
+    fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
+    //~^ ERROR the trait `Get` is not implemented for the type `Self`
+}
+
+impl<T:Get> Other for T {
+    fn uhoh<U:Get>(&self, foo: U, bar: <(T, U) as Get>::Value) {}
+    //~^ ERROR the trait `Get` is not implemented for the type `(T, U)`
+    //~| ERROR the trait `Get` is not implemented for the type `(T, U)`
+}
+
+fn main() { }
diff --git a/src/test/compile-fail/associated-types-project-from-hrtb-explicit.rs b/src/test/compile-fail/associated-types-project-from-hrtb-explicit.rs
new file mode 100644 (file)
index 0000000..1f0f044
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test you can't use a higher-ranked trait bound inside of a qualified
+// path (just won't parse).
+
+#![feature(associated_types)]
+
+pub trait Foo<T> {
+    type A;
+
+    fn get(&self, t: T) -> Self::A;
+}
+
+fn foo2<I>(x: <I as for<'x> Foo<&'x int>>::A)
+    //~^ ERROR expected identifier, found keyword `for`
+    //~| ERROR expected one of `::` or `>`
+{
+}
+
+pub fn main() {}
diff --git a/src/test/compile-fail/associated-types-project-from-hrtb-in-fn b/src/test/compile-fail/associated-types-project-from-hrtb-in-fn
new file mode 100755 (executable)
index 0000000..6d2392c
Binary files /dev/null and b/src/test/compile-fail/associated-types-project-from-hrtb-in-fn differ
diff --git a/src/test/compile-fail/associated-types-project-from-hrtb-in-fn-body.rs b/src/test/compile-fail/associated-types-project-from-hrtb-in-fn-body.rs
new file mode 100644 (file)
index 0000000..8cdca50
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Check projection of an associated type out of a higher-ranked
+// trait-bound in the context of a function body.
+
+#![feature(associated_types)]
+
+pub trait Foo<T> {
+    type A;
+
+    fn get(&self, t: T) -> Self::A;
+}
+
+fn foo<'a, I : for<'x> Foo<&'x int>>(
+    x: <I as Foo<&'a int>>::A)
+{
+    let y: I::A = x;
+}
+
+fn bar<'a, 'b, I : for<'x> Foo<&'x int>>(
+    x: <I as Foo<&'a int>>::A,
+    y: <I as Foo<&'b int>>::A,
+    cond: bool)
+{ //~ ERROR cannot infer
+    // x and y here have two distinct lifetimes:
+    let z: I::A = if cond { x } else { y };
+}
+
+pub fn main() {}
diff --git a/src/test/compile-fail/associated-types-project-from-hrtb-in-fn.rs b/src/test/compile-fail/associated-types-project-from-hrtb-in-fn.rs
new file mode 100644 (file)
index 0000000..0d5c695
--- /dev/null
@@ -0,0 +1,47 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Check projection of an associated type out of a higher-ranked trait-bound
+// in the context of a function signature.
+
+#![feature(associated_types)]
+
+pub trait Foo<T> {
+    type A;
+
+    fn get(&self, t: T) -> Self::A;
+}
+
+fn foo2<I : for<'x> Foo<&'x int>>(
+    x: I::A)
+    //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
+{
+    // This case is illegal because we have to instantiate `'x`, and
+    // we don't know what region to instantiate it with.
+    //
+    // This could perhaps be made equivalent to the examples below,
+    // specifically for fn signatures.
+}
+
+fn foo3<I : for<'x> Foo<&'x int>>(
+    x: <I as Foo<&int>>::A)
+{
+    // OK, in this case we spelled out the precise regions involved, though we left one of
+    // them anonymous.
+}
+
+fn foo4<'a, I : for<'x> Foo<&'x int>>(
+    x: <I as Foo<&'a int>>::A)
+{
+    // OK, in this case we spelled out the precise regions involved.
+}
+
+
+pub fn main() {}
diff --git a/src/test/compile-fail/associated-types-project-from-hrtb-in-struct.rs b/src/test/compile-fail/associated-types-project-from-hrtb-in-struct.rs
new file mode 100644 (file)
index 0000000..5016c64
--- /dev/null
@@ -0,0 +1,36 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Check projection of an associated type out of a higher-ranked trait-bound
+// in the context of a struct definition.
+
+#![feature(associated_types)]
+
+pub trait Foo<T> {
+    type A;
+
+    fn get(&self, t: T) -> Self::A;
+}
+
+struct SomeStruct<I : for<'x> Foo<&'x int>> {
+    field: I::A
+    //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
+}
+
+struct AnotherStruct<I : for<'x> Foo<&'x int>> {
+    field: <I as Foo<&int>>::A
+    //~^ ERROR missing lifetime specifier
+}
+
+struct YetAnotherStruct<'a, I : for<'x> Foo<&'x int>> {
+    field: <I as Foo<&'a int>>::A
+}
+
+pub fn main() {}
diff --git a/src/test/compile-fail/associated-types-project-from-hrtb-in-trait-method.rs b/src/test/compile-fail/associated-types-project-from-hrtb-in-trait-method.rs
new file mode 100644 (file)
index 0000000..a92d4ec
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Check projection of an associated type out of a higher-ranked trait-bound
+// in the context of a method definition in a trait.
+
+#![feature(associated_types)]
+
+pub trait Foo<T> {
+    type A;
+
+    fn get(&self, t: T) -> Self::A;
+}
+
+trait SomeTrait<I : for<'x> Foo<&'x int>> {
+    fn some_method(&self, arg: I::A);
+    //~^ ERROR cannot extract an associated type from a higher-ranked trait bound in this context
+}
+
+trait AnotherTrait<I : for<'x> Foo<&'x int>> {
+    fn some_method(&self, arg: <I as Foo<&int>>::A);
+}
+
+trait YetAnotherTrait<I : for<'x> Foo<&'x int>> {
+    fn some_method<'a>(&self, arg: <I as Foo<&'a int>>::A);
+}
+
+pub fn main() {}
diff --git a/src/test/compile-fail/issue-19081.rs b/src/test/compile-fail/issue-19081.rs
deleted file mode 100644 (file)
index 2f42dbd..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![feature(associated_types)]
-
-pub trait Hasher {
-    type State;
-
-    fn hash<T: Hash<
-        <Self as Hasher>::State //~ ERROR no suitable bound on `Self`
-    >>(&self, value: &T) -> u64;
-}
-
-pub trait Hash<S> {
-    fn hash(&self, state: &mut S);
-}
-
-fn main() {}
diff --git a/src/test/compile-fail/issue-19121.rs b/src/test/compile-fail/issue-19121.rs
deleted file mode 100644 (file)
index 998c6a8..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test that a partially specified trait object with unspecified associated
-// type does not ICE.
-
-#![feature(associated_types)]
-
-trait Foo {
-    type A;
-}
-
-fn bar(x: &Foo) {} //~ERROR missing type for associated type `A`
-
-pub fn main() {}
index 5fe8e435e68067102f7615d47a386e3a05bd8677..c11b5d2287855d9e71fa7a4ee442f375afac07fe 100644 (file)
@@ -41,14 +41,14 @@ enum Boo {
     Quux(Bar<uint>),
 }
 
-struct Badness<T> {
+struct Badness<U> {
 //~^ ERROR not implemented
-    b: Foo<T>,
+    b: Foo<U>,
 }
 
-enum MoreBadness<T> {
+enum MoreBadness<V> {
 //~^ ERROR not implemented
-    EvenMoreBadness(Bar<T>),
+    EvenMoreBadness(Bar<V>),
 }
 
 trait PolyTrait<T> {
diff --git a/src/test/compile-fail/unsized-inherent-impl-self-type.rs b/src/test/compile-fail/unsized-inherent-impl-self-type.rs
new file mode 100644 (file)
index 0000000..2c8a2b3
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test sized-ness checking in substitution in impls.
+
+// impl - struct
+
+struct S5<Y>;
+
+impl<Sized? X> S5<X> { //~ ERROR not implemented
+}
+
+fn main() { }
diff --git a/src/test/compile-fail/unsized-trait-impl-self-type.rs b/src/test/compile-fail/unsized-trait-impl-self-type.rs
new file mode 100644 (file)
index 0000000..0f0a97f
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test sized-ness checking in substitution in impls.
+
+// impl - struct
+trait T3<Sized? Z> {
+}
+
+struct S5<Y>;
+
+impl<Sized? X> T3<X> for S5<X> { //~ ERROR not implemented
+}
+
+fn main() { }
diff --git a/src/test/compile-fail/unsized-trait-impl-trait-arg.rs b/src/test/compile-fail/unsized-trait-impl-trait-arg.rs
new file mode 100644 (file)
index 0000000..bdb652b
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test sized-ness checking in substitution in impls.
+
+// impl - unbounded
+trait T2<Z> {
+}
+struct S4<Sized? Y>;
+impl<Sized? X> T2<X> for S4<X> {
+    //~^ ERROR `core::kinds::Sized` is not implemented for the type `X`
+}
+
+fn main() { }
index 253ec2a84ea5225ef027e5691dfe3a5b7ca11b15..0537fc1f94ad77dfaef5aa2fa7389501da7773e0 100644 (file)
@@ -13,7 +13,7 @@
 trait T {}
 
 fn f<Sized? Y: T>() {
-//~^ERROR incompatible bounds on type parameter `Y`, bound `T` does not allow unsized type
+//~^ERROR incompatible bounds on `Y`, bound `T` does not allow unsized type
 }
 
 pub fn main() {
index fd9dffe00d2d50a28b64e22fffdb246f7707ef5c..c0e6ae1db92c4aacc0a8b914eb81a81fe14b8c38 100644 (file)
@@ -21,23 +21,4 @@ impl<Sized? X: T> T1<X> for S3<X> {
     //~^ ERROR `core::kinds::Sized` is not implemented for the type `X`
 }
 
-// impl - unbounded
-trait T2<Z> {
-}
-struct S4<Sized? Y>;
-impl<Sized? X> T2<X> for S4<X> {
-    //~^ ERROR `core::kinds::Sized` is not implemented for the type `X`
-}
-
-// impl - struct
-trait T3<Sized? Z> {
-}
-struct S5<Y>;
-impl<Sized? X> T3<X> for S5<X> { //~ ERROR not implemented
-}
-
-impl<Sized? X> S5<X> { //~ ERROR not implemented
-}
-
-
 fn main() { }
diff --git a/src/test/run-pass/issue-19081.rs b/src/test/run-pass/issue-19081.rs
new file mode 100644 (file)
index 0000000..aeb1408
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// ignore-pretty -- currently pretty prints as `Hash<<Self as Hasher...` which fails to parse
+
+#![feature(associated_types)]
+
+pub trait Hasher {
+    type State;
+
+    fn hash<T: Hash<
+        <Self as Hasher>::State
+    >>(&self, value: &T) -> u64;
+}
+
+pub trait Hash<S> {
+    fn hash(&self, state: &mut S);
+}
+
+fn main() {}
diff --git a/src/test/run-pass/issue-19121.rs b/src/test/run-pass/issue-19121.rs
new file mode 100644 (file)
index 0000000..79afb85
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that a partially specified trait object with unspecified associated
+// type does not ICE.
+
+#![feature(associated_types)]
+
+trait Foo {
+    type A;
+}
+
+fn bar(x: &Foo) {}
+// FIXME(#19482) -- `Foo` should specify `A`, but this is not
+// currently enforced except at object creation
+
+pub fn main() {}