Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upPoor interaction between int fallback and other flow of type information #23545
Comments
This comment has been minimized.
This comment has been minimized.
aturon
added
the
A-typesystem
label
Mar 20, 2015
This comment has been minimized.
This comment has been minimized.
|
Another example, with the new inherent methods: fn main() {
let _ = 32_u8.count_zeros(); // works
let _ = 32.count_zeros(); // does not work
} |
alexcrichton
referenced
this issue
in alexcrichton/rust
Apr 1, 2015
This comment was marked as resolved.
This comment was marked as resolved.
|
cc me |
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 comment has been minimized.
This comment has been minimized.
|
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` |
This comment has been minimized.
This comment has been minimized.
|
@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 |
SimonSapin
referenced this issue
Jan 5, 2016
Closed
Type inference(?) regression, rand fails to build on nightly 2016-01-04 #30713
This comment has been minimized.
This comment has been minimized.
|
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 |
jethrogb
referenced this issue
Jul 14, 2016
Open
Wrapping<_> implements ShX<usize> but wrapping_shX takes u32 #34809
Mark-Simulacrum
added
A-inference
C-bug
labels
Jul 22, 2017
This comment has been minimized.
This comment has been minimized.
|
Triage: no change |
aturon commentedMar 20, 2015
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/Shrare only implemented onusizeforWrapping<T>.)