Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Rust code completion not working in my Visual Studio 2015?

I'm using Visual Studio 2015 v14 with VisualRust 0.1.2

Under Tools -> Options -> Text Editor -> Visual Rust statement completion is greyed out and cannot be enabled.

Under Tools -> Options -> Visual Rust I have selected Use bundled racer and Read rust sources from environment variable

The racer that came bundled with VisualRust works correctly when called manually, that is racer-120e98b.exe complete std::io:: returns the relevant results.

In Visual Studio, writing let e = std::io:: and then pressing CTRL + Space to trigger autocompletion will only return a list of the reserved keywords (such as if, while, struct, etc).

I'm guessing that the problem is that statement completion can't be turned on. How do I solve this?

like image 202
A.B. Avatar asked Nov 08 '22 08:11

A.B.


1 Answers

I run Visual Studio 2015 Community, and this is how I did it:

Download the racer and the rust sources via

cargo install racer
rustup component add rust-src

However, the RUST_SRC_PATH variable is not yet set, and I do not know who is supposed to set it. The following batch script will set the variable to its correct value, see this issue on github.

@ECHO OFF
FOR /F "tokens=* USEBACKQ" %%P IN (`rustc --print sysroot`) DO SET RS=%%P
SETX RUST_SRC_PATH "%RS%\lib\rustlib\src\rust\src"

After this, I still had to specify the path to racer.exe manually instead of the Use bundled racer option. By default, you can find it here:

%USERPROFILE%\.cargo\bin\racer.exe

Hope it helps!

like image 124
Jesko Hüttenhain Avatar answered Jan 04 '23 02:01

Jesko Hüttenhain