]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/trait-bounds-on-structs-and-enums.rs
auto merge of #17016 : steveklabnik/rust/fix_diagnostic_codes, r=huonw
[rust.git] / src / test / compile-fail / trait-bounds-on-structs-and-enums.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 trait Trait {}
12
13 struct Foo<T:Trait> {
14     x: T,
15 }
16
17 enum Bar<T:Trait> {
18     ABar(int),
19     BBar(T),
20     CBar(uint),
21 }
22
23 fn explode(x: Foo<uint>) {}
24 //~^ ERROR failed to find an implementation
25 //~^^ ERROR instantiating a type parameter with an incompatible type
26
27 fn kaboom(y: Bar<f32>) {}
28 //~^ ERROR failed to find an implementation
29 //~^^ ERROR instantiating a type parameter with an incompatible type
30
31 impl<T> Foo<T> { //~ ERROR failed to find an implementation
32 //~^ ERROR instantiating a type parameter with an incompatible type
33     fn uhoh() {}
34 }
35
36 struct Baz {
37 //~^ ERROR failed to find an implementation
38 //~^^ ERROR instantiating a type parameter with an incompatible type
39     a: Foo<int>,
40 }
41
42 enum Boo {
43 //~^ ERROR failed to find an implementation
44 //~^^ ERROR instantiating a type parameter with an incompatible type
45     Quux(Bar<uint>),
46 }
47
48 struct Badness<T> {
49 //~^ ERROR failed to find an implementation
50 //~^^ ERROR instantiating a type parameter with an incompatible type
51     b: Foo<T>,
52 }
53
54 enum MoreBadness<T> {
55 //~^ ERROR failed to find an implementation
56 //~^^ ERROR instantiating a type parameter with an incompatible type
57     EvenMoreBadness(Bar<T>),
58 }
59
60 trait PolyTrait<T> {
61     fn whatever() {}
62 }
63
64 struct Struct;
65
66 impl PolyTrait<Foo<uint>> for Struct {
67 //~^ ERROR failed to find an implementation
68 //~^^ ERROR instantiating a type parameter with an incompatible type
69     fn whatever() {}
70 }
71
72 fn main() {
73     let bar: Bar<f64> = return;
74     //~^ ERROR failed to find an implementation
75     //~^^ ERROR instantiating a type parameter with an incompatible type
76     let _ = bar;
77 }
78