Closed
Description
fn foo() -> u64 {
[1_u64].iter().sum() + 1
}
fn main() {}
Gives (rustc 1.60.0-nightly 08df8b8 2022-01-30):
error[E0283]: type annotations needed
--> ...\test.rs:2:20
|
2 | [1_u64].iter().sum() + 1
| ^^^ cannot infer type for type parameter `S` declared on the associated function `sum`
|
= note: cannot satisfy `_: Sum<&u64>`
note: required by a bound in `std::iter::Iterator::sum`
help: consider specifying the type argument in the method call
|
2 | [1_u64].iter().sum::<S>() + 1
| +++++
help: consider specifying the type argument in the function call
|
2 | [1_u64].iter().sum::<S>() + 1
| +++++
error: aborting due to previous error
For more information about this error, try `rustc --explain E0283`.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Type inferenceArea: Suggestions generated by the compiler applied by `cargo fix`Diagnostics: A structured suggestion resulting in incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.Relevant to the compiler team, which will review and decide on the PR/issue.