- Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceArea: Type inferenceA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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`.
isaacg1
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceArea: Type inferenceA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.Diagnostics: Too much output caused by a single piece of incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.