-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.
Description
The following code (playground):
for i in 0..100 {
println!("{}", i.pow(2));
}
fails to compile. The error message correctly points to the problem but the help message's suggestion is a syntax error:
error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}`
--> src/main.rs:3:26
|
3 | println!("{}", i.pow(2));
| ^^^
help: you must specify a type for this binding, like `i32`
|
2 | for i: i32 in 0..100 {
| ^^^^^^
Following the suggestion leads to another compile error (missing 'in' in for loop). Usually the correct solution in this case is to add the type to the range (0i32..100).
Thiez, estebank, pwnorbitals and Taranjot-Singh
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.