Rust-analyzer can barely import anything

Hi, I'm helping someone learn Rust. They are currently going through the book and they are complaining about how annoying it is that you need to write out the imports all the time. At which point I told them that their rust-analyzer should be doing that automatically... And apparently all of rust-analyzer is working for them, except any auto importing. Neither the code lens that lets r-a auto import an item nor the extended auto completions that do the auto importing seem to appear:

They tried commenting out all their VSCode settings and it still doesn't seem to work.

Have they installed r-a through rustup or their editor? I know there was an issue a little bit ago regarding imports, which could plausibly still be around on rustup.

This is most likely due to the println usage in that code. There was a bug with macros in scope regarding this which got fixed yesterday, see https://github.com/rust-analyzer/rust-analyzer/issues/8519 and https://github.com/rust-analyzer/rust-analyzer/pull/8587. This should be fixed on the current RA nightly/next stable.

Thanks that seemed to be it. :slight_smile:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.