]> git.lizzy.rs Git - rust.git/blob - src/test/ui/missing-trait-bounds/missing-trait-bounds-for-method-call.stderr
Properly track `ImplObligation`s
[rust.git] / src / test / ui / missing-trait-bounds / missing-trait-bounds-for-method-call.stderr
1 error[E0599]: the method `foo` exists for reference `&Foo<T>`, but its trait bounds were not satisfied
2   --> $DIR/missing-trait-bounds-for-method-call.rs:14:14
3    |
4 LL | struct Foo<T> {
5    | ------------- doesn't satisfy `Foo<T>: Bar`
6 ...
7 LL |         self.foo();
8    |              ^^^ method cannot be called on `&Foo<T>` due to unsatisfied trait bounds
9    |
10 note: trait bound `T: Default` was not satisfied
11   --> $DIR/missing-trait-bounds-for-method-call.rs:10:9
12    |
13 LL | impl<T: Default + Bar> Bar for Foo<T> {}
14    |         ^^^^^^^        ---     ------
15    |         |
16    |         unsatisfied trait bound introduced here
17 note: trait bound `T: Bar` was not satisfied
18   --> $DIR/missing-trait-bounds-for-method-call.rs:10:19
19    |
20 LL | impl<T: Default + Bar> Bar for Foo<T> {}
21    |                   ^^^  ---     ------
22    |                   |
23    |                   unsatisfied trait bound introduced here
24 help: consider restricting the type parameters to satisfy the trait bounds
25    |
26 LL | struct Foo<T> where T: Bar, T: Default {
27    |               ++++++++++++++++++++++++
28
29 error[E0599]: the method `foo` exists for reference `&Fin<T>`, but its trait bounds were not satisfied
30   --> $DIR/missing-trait-bounds-for-method-call.rs:27:14
31    |
32 LL | struct Fin<T> where T: Bar {
33    | -------------------------- doesn't satisfy `Fin<T>: Bar`
34 ...
35 LL |         self.foo();
36    |              ^^^ method cannot be called on `&Fin<T>` due to unsatisfied trait bounds
37    |
38 note: trait bound `T: Default` was not satisfied
39   --> $DIR/missing-trait-bounds-for-method-call.rs:23:9
40    |
41 LL | impl<T: Default + Bar> Bar for Fin<T> {}
42    |         ^^^^^^^        ---     ------
43    |         |
44    |         unsatisfied trait bound introduced here
45 help: consider restricting the type parameter to satisfy the trait bound
46    |
47 LL | struct Fin<T> where T: Bar, T: Default {
48    |                           ++++++++++++
49
50 error: aborting due to 2 previous errors
51
52 For more information about this error, try `rustc --explain E0599`.