Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

Intellisense/autocompletion not working for extenral crates with optional features #637

Open
spamwax opened this issue Aug 5, 2019 · 15 comments

Comments

@spamwax
Copy link

spamwax commented Aug 5, 2019

Although this may seem like a duplicate, I believe it's slightly different than other issues.

TLDR

Main issue is that Intellisense works for external crate's very top module but not anything within its submodules. Meanwhile hovering & documentation pop-ups work for everything!!!
I believe this is related to the fact that the dependency has optional features.

Detail

In the minimal example provided in this repo, you can see that external crate has a feature that needs to be enabled for unix platforms: socket2 = { version = "*", features = ["unix"] }

It seems that auto-completion for top-level modules/structs is working:

ext_module

but the inner impl or methods fails to appear in completion list:

ext_module_methods

What makes it more interesting is that

  • hovering
  • documentation
  • Goto Definition
    for those inner impl or methods actually work & shows their full definition and documentation, hinting that rls/racer is aware of them but for some reason can't show them in auto-completion:

hover_method

ezgif-2-cd840908acb7

I have encountered similar issues in my other projects where either external crates or my own crate has some optional features that seems to confuse rls/racer.

The above test is on a fresh installation of vscode that only has Rust extension installed with following noteworthy settings:

{
    "rust-client.channel": "stable",
    "rust.all_features": false,
    "rust.racer_completion": true,
    "rust.all_targets": true,
    "rust.features": [],
}

(I tried to play with some of those settings but didn't help!)

I am using

rls 1.36.0 (9692ca8 2019-05-18)
rustup 1.18.3 (435397f48 2019-05-22)
cargo 1.36.0 (c4fcfb725 2019-05-15)

(on x86_64 GNU/Linux)

Please let me know if more info is needed.

@chriskuech
Copy link

Is the rls-vscode team able to repro this issue? This bug makes the extension unbeneficial for anyone trying to use Rust WASM, as the web-sys crate containing all the DOM bindings relies extensively on features.

@dmilford
Copy link

I'm also having troubles, and the web-sys crate is particularly difficult to use without intellisense. I'm creating a tutorial video on 3D graphics in the browser, and it's quite embarrassing to not have intellisense working properly. I have to know precisely what I'm typing, which is very difficult for some of the longer names.

I would appreciate any hints as to how I can make this work correctly as the current situation really diminishes the value of Rust altogether.

@Sorrien
Copy link

Sorrien commented Jan 21, 2020

I'm having the same problem. Is there any update on this?

@darman96
Copy link

Still no news/reaction? :(

@cleak
Copy link

cleak commented Mar 26, 2020

My understanding is that the bug (likely multiple bugs) is either in RLS (https://github.com/rust-lang/rls) or in Racer (https://github.com/racer-rust/racer).

Specifically for WASM, RLS has an issue tracking it: rust-lang/rls#1489

@chriskuech
Copy link

I haven't tried with web-sys specifically, but I have disabled the RLS extension and added the rust-analyzer extension in its place and it has been working much smoother so far.

@bergkvist
Copy link

bergkvist commented May 9, 2020

I'm using roxmltree=0.11.0 and I think I have the same problem.

I do sometimes get hints/docs about how a function within the library is used if I write the name (without being helped by intellisense along the way). I also get a red line below if I try to use something that doesn't exist. But no autocomplete.

Here I get autocomplete:
image

No autocomplete:
image

And yet I get a hint when I write parse correctly:
image

@AntBlo
Copy link

AntBlo commented May 13, 2020

I haven't tried with web-sys specifically, but I have disabled the RLS extension and added the rust-analyzer extension in its place and it has been working much smoother so far.

I just encountered this issue with rust-analyzer myself.
image

You can see that even annotating it as being a Window struct, it still gives an {unknown}
image

@Xanewok
Copy link
Member

Xanewok commented May 13, 2020

(As a side note, you can set "rust-client.engine": "rust-analyzer" and use it directly from the same extension)

@JeremyAube
Copy link

(As a side note, you can set "rust-client.engine": "rust-analyzer" and use it directly from the same extension)

I had the same problem, after setting rust-client.engine I restarted vs code and I got a prompt to install the nightly build of rust-analyzer. Everything works as expected now!

@bmhatfield
Copy link

Working through the rust book right now, and VSCode wasn't autocompleting gen_range in the Guessing Game tutorial. Switching to rust-analyzer as above fixes autocomplete for me. As a new user, it is very confusing if the functions used in the tutorial in the book don't autocomplete.

@johnshew
Copy link

johnshew commented Aug 7, 2020

VSCode wasn't autocompleting. Switching to rust-analyzer as above fixes autocomplete for me. Also had to set rust auto update before it installed.

@visuallization
Copy link

Thanks for the hint. :)
I have experienced an issue though.

Switching to rust-analyzer works for me and auto-completes e.g. gen_range but now warnings and errors will only be displayed in VSCode after manually building the project. It works automatically with the standard engine (which is rls, I guess). Any ideas how to fix this?

@lnicola
Copy link
Member

lnicola commented Aug 17, 2020

@visuallization it's a known limitation of rust-analyzer, but you don't have to build the project manually since it runs cargo check on save. Moreso, you can use the auto-save feature of Code.

@mleonhard
Copy link

If the rust-analyzer download doesn't work, open VSCode Settings and set Rust-analyzer: Release Tag to 2020-08-31. Note that stable and beta don't work. See #847.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests