-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.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
This code:
use std::ops::Div;
pub fn f<T>(_: T) -> f64
where
f64: Div<T, Output = f64>,
{
1.0 / 2.0
}
Results in this error:
error[E0308]: mismatched types
--> src/lib.rs:7:11
|
3 | pub fn f<T>(_: T) -> f64
| - this type parameter
...
7 | 1.0 / 2.0
| ^^^ expected type parameter `T`, found floating-point number
|
= note: expected type parameter `T`
found type `{float}`
But I expected it to compile fine, since f64: Div<f64, Output = f64>
also exists unconditionally. It seems that the bound on f64
hides the existing f64: Div<f64>
.
This seems to happen on all versions of Rust since 1.0.
fmease, drHuangMHT and benluelo
Metadata
Metadata
Assignees
Labels
A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.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.