Closed
Description
Consider these two examples:
error[E0271]: type mismatch resolving `<std::slice::Iter<'_, {integer}> as std::iter::Iterator>::Item == i32`
--> src/main.rs:4:5
|
1 | fn consume<I: Iterator<Item = i32>>(_: I) {}
| ------- ---------- required by this bound in `consume`
...
4 | consume([1, 2, 3].into_iter());
| ^^^^^^^ expected reference, found i32
|
= note: expected type `&{integer}`
found type `i32`
error[E0308]: mismatched types
--> src/main.rs:4:13
|
4 | consume(&123);
| ^^^^
| |
| expected i32, found &{integer}
| help: consider removing the borrow: `123`
|
= note: expected type `i32`
found type `&{integer}`
expected
in the first example's error message is related to the call's context, but in the second one, it is related to the function's signature. Is it a bug?
rustc
1.39.0 stable
Metadata
Metadata
Assignees
Labels
No labels