rust-analyzer
rust-analyzer copied to clipboard
Inlay type hints not so useful in for loop on `impl IntoIterator<Item: Trait>`
rust-analyzer version: 0.4.2069-standalone
rustc version: rustc 1.80.1 (3f5fd8dd4 2024-08-06)
editor or extension: code oss
relevant settings: None
code snippet to reproduce:
pub fn count_bytes(iter: impl IntoIterator<Item: AsRef<[u8]>>) -> usize {
let mut count = 0;
for bytes in iter {
count += bytes.as_ref().len();
}
count
}
screenshot (with inlay hints):
<impl IntoIterator as IntoIterator>::Item this is true for all for loops, in this case impl AsRef<[u8]> would be (more) useful.
I agree with you that we can give more useful information in this inlay hint but impl AsRef might be confusing cause r-a uses impl Trait things for displaying opaque types
I think displaying it as impl AsRef<[u8]> would be pretty natural here. And we already have some heuristics anyway:
Oh, that makes sense