Vscode-rust: GoTo Definition always fails

Created on 4 Nov 2017  ·  24Comments  ·  Source: rust-lang/vscode-rust

Rust: rustc 1.23.0-nightly (59d484575 2017-11-03)
Rust rls: 0.3.1
OS: Windows 10 Pro 64 bit latest

It always fails. But it is able to show symbol names in tooltips.

extern crate rand;

use std::io;
use std::cmp::Ordering;
use rand::Rng;

fn hello(){ println!("{}", "Hello!")}

fn main () {
    println!("Guess the number!");
    let secret_number = rand::thread_rng().gen_range(1, 100);
    println!("Please input your guess.");
    let mut guess = String::new();
    io::stdin().read_line(&mut guess).expect("Failed to read line");
    println!("You guessed: {}", guess);
    let num : u32 = guess.trim().parse().expect("Please type a number!");
    match num.cmp(&secret_number) {
        Ordering::Less => println!{"Too small!"},
        Ordering::Greater => println!("Too big!"),
        Ordering::Equal => println!("You win!")
    }
    hello();
}

Most helpful comment

There was an error trying to build, RLS features will be limited. Try running cargo check for more information.

I've been landing a bunch of patches to help here. They're currently on master but not yet in nightly. I have one more bigger thing to land and will then update the rustup nightlies. Unfortunately that process takes a while so it might be a few days to a week before the nightly reflects the improvements.

All 24 comments

Also there is the constantly-rolling circle in the left-bottom corner (RLS: working).

That the spinner is still going suggests that analysis has not copleted which is why goto def is not working. Could try enabling logging to try and some more information about what is going wrong please? Instructions are in debugging.md.

@nrc I updated the nightly rust, reinstalled the extension (0.3.2) and found in the log

thread '' panicked at 'need to specify SYSROOT or RUSTC env vars, or rustc must be in PATH', src\libcore\option.rs:839:4
note: Run with RUST_BACKTRACE=1 for a backtrace.

But the "rustc --version" command runs successfully in both Windows' cmd and PowerShell.

@AnyCPU can you try a rustup update to get the latest RLS and then re-open VSCode and see if that helps?

Just tried it, and still does not work :(

 nightly-x86_64-pc-windows-gnu updated - rustc 1.23.0-nightly (79cfce3d3 2017-11-12)
 nightly-x86_64-pc-windows-msvc updated - rustc 1.23.0-nightly (79cfce3d3 2017-11-12)
thread '<unnamed>' panicked at 'could not run cargo: CargoError(Msg("failed to run `rustc` to learn about target-specific information"), State { next_error: Some(CargoError(ProcessErrorKind(ProcessError { desc: "process didn\'t exit successfully: `rustc - --crate-name ___ --print=file-names --error-format=json -Zcontinue-parse-after-error -Zsave-analysis -Zunstable-options --target x86_64-pc-windows-msvc --crate-type bin --crate-type proc-macro --crate-type rlib` (exit code: 101)\n--- stderr\nerror: the option `Z` is only accepted on the nightly compiler\n\n", exit: Some(ExitStatus(ExitStatus(101))), output: Some(Output { status: ExitStatus(ExitStatus(101)), stdout: "", stderr: "error: the option `Z` is only accepted on the nightly compiler\n\n" }) }), State { next_error: None, backtrace: None })), backtrace: None })', src\libcore\result.rs:906:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.

@akappel I have updated the nightly up to rustc 1.23.0-nightly (e21df8020 2017-11-13). I found this error was fixed, but I filed another one, please see https://github.com/rust-lang-nursery/rls-vscode/issues/189

I still have the error even with rustc 1.23.0-nightly (e21df8020 2017-11-13)
I tried to rustup default nightly and restart VSCode but it seems it is still using stable if I understand the Z flag error. How do I tell Rust (rls) plugin to use nightly?

@Geobert I use the latest versions of Windows 10 Pro 64 bit, VS Code, Rust (rls) extensions, Visual Studio build tools. It works.
Maybe did you make changes in VS Code configuration?

Do I need to be on nightly toolchain for that? I'll check my options when back home. Thanks!

@Geobert Being on the nightly is recommended now.

You were right, stuck in the middle of the config file, stable was specified

nightly-x86_64-pc-windows-msvc unchanged - rustc 1.25.0-nightly (bacb5c58d 2018-01-26)
The issue occurs again

@Geobert
the latest ms c++ build tools and "nightly-x86_64-pc-windows-msvc unchanged - rustc 1.25.0-nightly (7d6e5b9da 2018-01-27)" work well.

updated to 01-27, still not working, I'm using MS C++ build tools 2015

with nightly-x86_64-pc-windows-msvc updated - rustc 1.25.0-nightly (27a046e93 2018-02-18)
I got VSCode that pop a message bar:

There was an error trying to build, RLS features will be limited. Try running cargo check for more information.

But I've run cargo +nightly check with no error on https://github.com/cobalt-org/cobalt.rs

@Geobert
i have exact same message on OSX.

its a new laptop and with rustup and vscode only

There was an error trying to build, RLS features will be limited. Try running cargo check for more information.

I've been landing a bunch of patches to help here. They're currently on master but not yet in nightly. I have one more bigger thing to land and will then update the rustup nightlies. Unfortunately that process takes a while so it might be a few days to a week before the nightly reflects the improvements.

@nrc I updated nightly. Some cases are repaired, but not all.

let a = Arc::new(5);
let b = a.clone();

Definition of "Arc" and "new" is found, but definition of "clone" isn't because of wrong path.

Still broken with nightly-x86_64-pc-windows-msvc unchanged - rustc 1.26.0-nightly (2789b067d 2018-03-06)

cobalt.rs project does not have any code navigation.

Does anybody has any workaround on this, I can't use RLS since end of january :(

Just find out about RUST_LOG=rls=debug

Not much of a help, I'm afraid: https://gist.github.com/Geobert/07ccc3d6dbb429305f3f1793cc1d66f9

Seen a new nightly but still broken :( (still cobalt.rs project)

nightly-x86_64-pc-windows-msvc updated - rustc 1.26.0-nightly (521d91c6b 2018-03-14)

https://gist.github.com/Geobert/892ef0dbec18e22c482ca1fbd3999ca1

OMG, found why by reinstalling my system (unrelated issue to solve).

In order to build cobalt, in the terminal I need to call 'C:\Program Files (x86)\Microsoft Visual Studio\2017BuildTools\VCAuxiliaryBuild\vcvars64.bat' otherwise it will not build because of onig-sys

If I launch VSCode in a bat file:

@echo off
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
start "" code

it works!

Thanks to @alexheretic the RLS will report an error squiggle in case a dependency cannot be built by Cargo. I believe this is not an issue so will close this but feel free to reopen/comment if that's still the case!

Was this page helpful?
0 / 5 - 0 ratings