-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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
Code
(0..10).filter(|&v| v.pow(2) > 0);
Current output
error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}`
--> src/lib.rs:2:27
|
2 | (0..10).filter(|&v| v.pow(2) > 0);
| - ^^^
| |
| you must specify a type for this binding, like `i32`
Desired output
There are two changes I'd like to see:
- Show the exact place to put the type
- Show the correct type, with the reference
error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}`
--> src/lib.rs:2:27
|
2 | (0..10).filter(|&v| v.pow(2) > 0);
| - ^^^
| |
| you must specify a type for this binding
help: specify the type in the closure argument list
|
2 | (0..10).filter(|&v: &i32| v.pow(2) > 0);
| ++++++
Rust Version
rustc 1.92.0-nightly (5c7ae0c7e 2025-10-02)
binary: rustc
commit-hash: 5c7ae0c7ed184c603e5224604a9f33ca0e8e0b36
commit-date: 2025-10-02
host: aarch64-apple-darwin
release: 1.92.0-nightly
LLVM version: 21.1.2
Anything else?
Discovered while giving training to newcomers to Rust.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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.