-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-inferenceArea: Type inferenceArea: Type inferenceC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
fn do_pow(n: i32) -> f64 {
0.95.powi(n)
}
error[E0689]: can't call method `powi` on ambiguous numeric type `{float}`
--> mail/mail-common/src/mailbox/attachments.rs:335:18
|
335 | 0.95.powi(n)
| ^^^^
|
help: you must specify a concrete type for this numeric value, like `f32`
|
335 | 0.95_f32.powi(n)
| ~~~~~~~~
Why can't the compiler infer that if it's being expected to produce a f64 the type should be an f64?
I can't think of any other cases outside of pow where the inference fails.
Metadata
Metadata
Assignees
Labels
A-inferenceArea: Type inferenceArea: Type inferenceC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.