-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Binary operations involving &1.0 always infer f64 #57447
Comments
OK, it took me a minute to remember this, but indeed there is a built-in rule that favors floating point values: rust/src/librustc_typeck/check/op.rs Lines 81 to 100 in 6ecad33
It basically encodes in the inference scheme the idea that rust/src/librustc_typeck/check/op.rs Lines 702 to 706 in 6ecad33
Certainly it is possible that we could generalize this to accept |
Originally posted as a comment on #36549, but in hindsight this may be a different issue. (in that
#36549
very clearly looks like a bug, whereas this one is in a potential gray area)Relevant URLO thread.
In the latter 3 cases, the type of
&1.
is apparently defaulted to&f64
:To a mortal like me, it seems that the only reason the first line works is because the compiler must have a special case for binary operations between two unconstrained "floating-point flavored" type inference variables. Can the compiler not just special case the latter three examples in the same way it special cases the first?
The text was updated successfully, but these errors were encountered: