rust/src/test/ui/issues/issue-13853.stderr
Esteban Küber 3a795fba03 On type mismatch involving associated type, suggest constraint
When an associated type is found when a specific type was expected, if
possible provide a structured suggestion constraining the associated
type in a bound.

```
error[E0271]: type mismatch resolving `<T as Foo>::Y == i32`
  --> $DIR/associated-types-multiple-types-one-trait.rs:13:5
   |
LL |     want_y(t);
   |     ^^^^^^ expected `i32`, found associated type
...
LL | fn want_y<T:Foo<Y=i32>>(t: &T) { }
   |                 ----- required by this bound in `want_y`
   |
   = note:         expected type `i32`
           found associated type `<T as Foo>::Y`
help: consider constraining the associated type `<T as Foo>::Y` to `i32`
   |
LL | fn have_x_want_y<T:Foo<X=u32, Y = i32>>(t: &T)
   |                             ^^^^^^^^^
```

```
error[E0308]: mismatched types
  --> $DIR/trait-with-missing-associated-type-restriction.rs:12:9
   |
LL |     qux(x.func())
   |         ^^^^^^^^ expected `usize`, found associated type
   |
   = note:         expected type `usize`
           found associated type `<impl Trait as Trait>::A`
help: consider constraining the associated type `<impl Trait as Trait>::A` to `usize`
   |
LL | fn foo(x: impl Trait<A = usize>) {
   |                     ^^^^^^^^^^
```
2020-05-02 18:23:46 -07:00

35 lines
1.1 KiB
Plaintext

error[E0308]: mismatched types
--> $DIR/issue-13853.rs:14:9
|
LL | fn nodes<'a, I: Iterator<Item=&'a N>>(&self) -> I
| - this type parameter - expected `I` because of return type
...
LL | self.iter()
| ^^^^^^^^^^^ expected type parameter `I`, found struct `std::slice::Iter`
|
= note: expected type parameter `I`
found struct `std::slice::Iter<'_, N>`
error[E0599]: no method named `iter` found for reference `&G` in the current scope
--> $DIR/issue-13853.rs:27:23
|
LL | for node in graph.iter() {
| ^^^^ method not found in `&G`
error[E0308]: mismatched types
--> $DIR/issue-13853.rs:37:13
|
LL | iterate(graph);
| ^^^^^
| |
| expected reference, found struct `std::vec::Vec`
| help: consider borrowing here: `&graph`
|
= note: expected reference `&_`
found struct `std::vec::Vec<Stuff>`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0308, E0599.
For more information about an error, try `rustc --explain E0308`.