Closed
Description
Given the following code (playground):
fn main() {
let length = <&[u32]>::len;
assert_eq!(length(&[1,3]), 2);
}
The current output is:
error[E0599]: the function or associated item `len` exists for reference `&[u32]`, but its trait bounds were not satisfied
--> src/main.rs:2:28
|
2 | let length = <&[u32]>::len;
| ^^^ function or associated item cannot be called on `&[u32]` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`&[u32]: ExactSizeIterator`
which is required by `&mut &[u32]: ExactSizeIterator`
help: the function `len` is implemented on `[u32]`
|
2 | let length = <<[u32]>>::len;
| ~~~~~~~
This suggestion is on the right track, but unfortunately it introduces a parse error. It should be:
help: the function `len` is implemented on `[u32]`
|
2 | let length = <[u32]>::len;
| ~~~~~
This suggestion is in check_for_deref_method. It suggests adding <>
around the type because the type is a slice, but I already have <>
in my program (and the span doesn't include the existing <>
).