Closed
Description
I tried this code:
use serde_json::to_string;
pub fn some_function() {
assert_eq!(3_u32, (0..3).sum());
}
I expected this to compile, but a type inference error was emitted.
error[E0283]: type annotations needed
--> src/lib.rs:4:30
|
4 | assert_eq!(3_u32, (0..3).sum());
| ^^^ cannot infer type for type parameter `S` declared on the associated function `sum`
|
= note: cannot satisfy `_: Sum<i32>`
help: consider specifying the type argument in the method call
|
4 | assert_eq!(3_u32, (0..3).sum::<S>());
| ^^^^^
If the import of serde_json::to_string
is removed the code compiles just fine.
Meta
It fails on all stable, beta and nightly.