]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/associated-types-no-suitable-supertrait.rs
Make RFC 1214 warnings into errors, and rip out the "warn or err"
[rust.git] / src / test / compile-fail / associated-types-no-suitable-supertrait.rs
1 // Copyright 2014 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.
4 //
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.
10
11 // Check that we get an error when you use `<Self as Get>::Value` in
12 // the trait definition but `Self` does not, in fact, implement `Get`.
13 //
14 // See also associated-types-no-suitable-supertrait-2.rs, which checks
15 // that we see the same error if we get around to checking the default
16 // method body.
17 //
18 // See also run-pass/associated-types-projection-to-unrelated-trait.rs,
19 // which checks that the trait interface itself is not considered an
20 // error as long as all impls satisfy the constraint.
21
22 trait Get {
23     type Value;
24 }
25
26 trait Other {
27     fn uhoh<U:Get>(&self, foo: U, bar: <Self as Get>::Value) {}
28     //~^ ERROR the trait `Get` is not implemented for the type `Self`
29 }
30
31 impl<T:Get> Other for T {
32     fn uhoh<U:Get>(&self, foo: U, bar: <(T, U) as Get>::Value) {}
33     //~^ ERROR the trait `Get` is not implemented for the type `(T, U)`
34 }
35
36 fn main() { }