Type hinting is broken for non consuming iterator over `Vec`

Viewed 98

In my VSCode IDE (rust + rust-analyzer),

let v = vec![1, 2, 3];
for x in v.iter() {
    println!("{}", x);
}

the above codes can't show Auto-Type Hints correctly (while most other hints work well), but several weeks ago they did. The problems are:

  1. let v = vec![1, 2, 3]; Type hinting doesn't work for v. When the mouse is moved upon v, it shows let v: {unknown}

enter image description here

  1. v.iter() I can't find the method iter() in the autocomplete list after typing v. However, into_iter() exists in the list.

enter image description here

  1. for x in v.iter() Type hinting doesn't work for x, even if I explicitly announce v : Vec<u8> = vec![1,2,3]; Therefore, I can't use the auto-hinted methods for x.

How to fix these problems?

Versions I used are the latest (by 2022-05-17):

code : 1.67.1-1651841865

rust : nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.63.0-nightly (4c5f6e627 2022-05-17)

rust-analyzer : v0.3.1059

0 Answers
Related