summaryrefslogtreecommitdiffstats
path: root/tests/ui/errors/trait-bound-error-spans/blame-trait-error.rs
blob: 0fbd851431ea6c6fa9959856fa3e558a1f0c6f1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
trait T1 {}
trait T2 {}
trait T3 {}
trait T4 {}

impl<B: T2> T1 for Wrapper<B> {}

impl T2 for i32 {}
impl T3 for i32 {}

impl<A: T3> T2 for Burrito<A> {}

struct Wrapper<W> {
    value: W,
}

struct Burrito<F> {
    filling: F,
}

impl<It: Iterator> T1 for Option<It> {}

impl<'a, A: T1> T1 for &'a A {}

fn want<V: T1>(_x: V) {}

enum ExampleTuple<T> {
    ExampleTupleVariant(T),
}
use ExampleDifferentTupleVariantName as ExampleYetAnotherTupleVariantName;
use ExampleTuple as ExampleOtherTuple;
use ExampleTuple::ExampleTupleVariant as ExampleDifferentTupleVariantName;
use ExampleTuple::*;

impl<A> T1 for ExampleTuple<A> where A: T3 {}

enum ExampleStruct<T> {
    ExampleStructVariant { field: T },
}
use ExampleDifferentStructVariantName as ExampleYetAnotherStructVariantName;
use ExampleStruct as ExampleOtherStruct;
use ExampleStruct::ExampleStructVariant as ExampleDifferentStructVariantName;
use ExampleStruct::*;

impl<A> T1 for ExampleStruct<A> where A: T3 {}

struct ExampleActuallyTupleStruct<T>(T, i32);
use ExampleActuallyTupleStruct as ExampleActuallyTupleStructOther;

impl<A> T1 for ExampleActuallyTupleStruct<A> where A: T3 {}

fn example<Q>(q: Q) {
    want(Wrapper { value: Burrito { filling: q } });
    //~^ ERROR the trait bound `Q: T3` is not satisfied [E0277]

    want(Some(()));
    //~^ ERROR `()` is not an iterator [E0277]

    want(Some(q));
    //~^ ERROR `Q` is not an iterator [E0277]

    want(&Some(q));
    //~^ ERROR `Q` is not an iterator [E0277]

    want(&ExampleTuple::ExampleTupleVariant(q));
    //~^ ERROR `Q: T3` is not satisfied [E0277]

    want(&ExampleTupleVariant(q));
    //~^ ERROR `Q: T3` is not satisfied [E0277]

    want(&ExampleOtherTuple::ExampleTupleVariant(q));
    //~^ ERROR `Q: T3` is not satisfied [E0277]

    want(&ExampleDifferentTupleVariantName(q));
    //~^ ERROR `Q: T3` is not satisfied [E0277]

    want(&ExampleYetAnotherTupleVariantName(q));
    //~^ ERROR `Q: T3` is not satisfied [E0277]

    want(&ExampleStruct::ExampleStructVariant { field: q });
    //~^ ERROR `Q: T3` is not satisfied [E0277]

    want(&ExampleStructVariant { field: q });
    //~^ ERROR `Q: T3` is not satisfied [E0277]

    want(&ExampleOtherStruct::ExampleStructVariant { field: q });
    //~^ ERROR `Q: T3` is not satisfied [E0277]

    want(&ExampleDifferentStructVariantName { field: q });
    //~^ ERROR `Q: T3` is not satisfied [E0277]

    want(&ExampleYetAnotherStructVariantName { field: q });
    //~^ ERROR `Q: T3` is not satisfied [E0277]

    want(&ExampleActuallyTupleStruct(q, 0));
    //~^ ERROR `Q: T3` is not satisfied [E0277]

    want(&ExampleActuallyTupleStructOther(q, 0));
    //~^ ERROR `Q: T3` is not satisfied [E0277]
}

fn main() {}