-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generic float inference type is unified with f64 prematurely #14382
Labels
A-type-system
Area: Type system
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Comments
Inference is totally different now, does this issue still persist, @pnkfelix ? |
The following compiles successfully now: #[derive(Debug)]
pub struct Matrix4<S>(S);
pub trait POrd<S> {}
pub fn translate<S: POrd<S>>(_: S) -> Matrix4<S> { unimplemented!() }
impl POrd<f32> for f32 {}
impl POrd<f64> for f64 {}
fn main() {
let x = 1.0;
let m : Matrix4<f32> = translate(x);
println!("m: {:?}", m);
} |
Merged
steveklabnik
added a commit
to steveklabnik/rust
that referenced
this issue
Jul 21, 2015
steveklabnik
added a commit
to steveklabnik/rust
that referenced
this issue
Jul 21, 2015
steveklabnik
added a commit
to steveklabnik/rust
that referenced
this issue
Jul 21, 2015
steveklabnik
added a commit
to steveklabnik/rust
that referenced
this issue
Jul 22, 2015
steveklabnik
added a commit
to steveklabnik/rust
that referenced
this issue
Jul 22, 2015
steveklabnik
added a commit
to steveklabnik/rust
that referenced
this issue
Jul 22, 2015
steveklabnik
added a commit
to steveklabnik/rust
that referenced
this issue
Jul 22, 2015
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Jun 5, 2023
minor: sync from downstream
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-type-system
Area: Type system
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
I don't exactly know what terminology to use to describe this bug; feel free to update the title to reflect reality...
This was something I encountered while using bjz's cgmath library ; this test is derived from that library (but independent of it).
Transcript of compilation attempt:
f32
to the type ofx
, since I do not see any reason for the generic float type to be constrained tof64
. (Note that if you add a: f32
type annotation to thelet x
then compilation terminates successfully.)Note also that the
impl POrd<f64> for f64 {}
is necessary to reproduce the poor-quality error message given here. If you remove it, you get this instead:error: failed to find an implementation of trait POrd<<generic float #0>> for <generic float #0>
(which also is not great, but at least then I have a hint that my problem originates with some use of a generic float literal somewhere in my code.The text was updated successfully, but these errors were encountered: