1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 fn get(&self, A: &A) { }
19 impl<T> Foo<T> for [isize;0] {
20 // OK, T is used in `Foo<T>`.
23 impl<T,U> Foo<T> for [isize;1] {
24 //~^ ERROR the type parameter `U` is not constrained
27 impl<T,U> Foo<T> for [isize;2] where T : Bar<Out=U> {
28 // OK, `U` is now constrained by the output type parameter.
31 impl<T:Bar<Out=U>,U> Foo<T> for [isize;3] {
32 // OK, same as above but written differently.
35 impl<T,U> Foo<T> for U {
36 // OK, T, U are used everywhere. Note that the coherence check
37 // hasn't executed yet, so no errors about overlap.
41 //~^ ERROR the type parameter `U` is not constrained
45 // Using `U` in an associated type within the impl is not good enough!
51 //~^^^ ERROR the type parameter `U` is not constrained
53 // This crafty self-referential attempt is still no good.
56 impl<T,U,V> Foo<T> for T
57 where (T,U): Bar<Out=V>
59 //~^^^ ERROR the type parameter `U` is not constrained
60 //~| ERROR the type parameter `V` is not constrained
62 // Here, `V` is bound by an output type parameter, but the inputs
63 // are not themselves constrained.
66 impl<T,U,V> Foo<(T,U)> for T
67 where (T,U): Bar<Out=V>
69 // As above, but both T and U ARE constrained.