-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Type inference for indexing #21649
Labels
A-typesystem
Area: The type system
Comments
The following works: fn main() {
let array = [true, false];
for i in range(0, 1) { // you mean range(0, 2) right?
println!("{}", array[i]);
}
} So this could be a dup of #21672. |
I think I've ran into this as well: pub fn main() {
let mut x = [[0f64; 3]; 3];
for i in 0..3 {
x[i][0] = 1.0; // the type of this value must be known in this context
}
} |
Should have been fixed in #21806. |
edwardw
added a commit
to edwardw/rust
that referenced
this issue
Feb 1, 2015
The new `::ops::Range` has separated implementations for each of the numeric types, while the old `::iter::Range` has one for type `Int`. However, we do not take output bindings into account when selecting traits. So it confuses `typeck` and makes the new range does not work as good as the old one when it comes to type inference. This patch implements `Iterator` for the new range for one type `Int`. This limitation could be lifted, however, if we ever reconsider the output types' role in type inference. Closes rust-lang#21595 Closes rust-lang#21649 Closes rust-lang#21672
bors
added a commit
that referenced
this issue
Feb 1, 2015
The new `::ops::Range` has separated implementations for each of the numeric types, while the old `::iter::Range` has one for type `Int`. However, we do not take output bindings into account when selecting traits. So it confuses `typeck` and makes the new range does not work as good as the old one when it comes to type inference. This patch implements `Iterator` for the new range for one type `Int`. This limitation could be lifted, however, if we ever reconsider the output types' role in type inference. Closes #21595 Closes #21649 Closes #21672
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This example used to work:
Recently you'll get the error:
error: the trait``core::ops::Index<i32>``is not implemented for the type``[bool]``[E0277]
The text was updated successfully, but these errors were encountered: