-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Poor interaction between int fallback and other flow of type information #23545
Comments
Another example, with the new inherent methods: fn main() {
let _ = 32_u8.count_zeros(); // works
let _ = 32.count_zeros(); // does not work
} |
This comment has been minimized.
This comment has been minimized.
These examples so far seem to be "working as designed". That is, we do not do fallback early in the cycle, but only after we've gotten to the end, and we currently do require some type-directed actions (like field access) to have resolved types, for better or worse. We could do work on the type system to make it less... eager. In other words, it should generate deferred constraints and try to solve them. That is sort of the general fix to this problem I guess. |
This code says let x = 1.;
let y = x.min(2.); // error: type `_` does not implement any method in scope named `min` The last line puzzled me the most here. I went about to tell Rust a type to use, still no dice. [1., 2., 3.].iter().fold(1./0., |acc, &x| f32::min(acc, x)); // OK
[1., 2., 3.].iter().fold(1./0., |acc, &x| acc.min(x)); // error: type `_` does not implement any method in scope named `min`
[1.0_f32, 2., 3.].iter().fold(1./0., |acc, &x| acc.min(x)); // error: type `_` does not implement any method in scope named `min` |
@nikomatsakis The interesting thing about Couldn't we do something similar for an inherent method present on multiple integer types? I guess we would need a way to represent |
On Tue, Jan 05, 2016 at 02:27:31PM -0800, Eduard-Mihai Burtescu wrote:
Possibly, but it'd be very hard-coded.
Yes. I suspect this is eminently doable. I've been thinking about it |
Triage: no change |
A reduced example:
generates the following error:
I suspect what is happening here is that the fallback isn't being triggered early enough -- in particular, before the projection is generating the error. Note that the same problem occurs with a normal struct.
(This may be one reason that
Shl
/Shr
are only implemented onusize
forWrapping<T>
.)The text was updated successfully, but these errors were encountered: