Vscode-rust: Cannot goto definition for std library types/functions

Created on 7 Aug 2017  ·  8Comments  ·  Source: rust-lang/vscode-rust

Given the following:

use std::fs::File;
use std::path::Path;

fn main() {
    let ref mut fout = File::create(&Path::new("out.png")).unwrap();
}

Ctrl-click on File or Path in the main function simply does nothing, while ctrl-click on create or new produces a popup error in VS Code:

Unable to open 'fs.rs': File not found (c:\Program Files (x86)\Microsoft VS Code\src\libstd\fs.rs).

Or:

Unable to open 'path.rs': File not found (c:\Program Files (x86)\Microsoft VS Code\src\libstd\path.rs).

I have no user settings defined in VS Code for rust.

rustc 1.21.0-nightly (ba1d065ff 2017-08-06)

bug

Most helpful comment

Having the same issue.

All 8 comments

I have this same issue too with Windows 10 & rustc 1.21.0-nightly (f14249953 2017-08-09), with these errors (using the example with File and Path):

Error: File not found (c:\Program Files\Microsoft VS Code\src\libstd\fs.rs)        index.js:44 
    at new t (files.ts:507)
    at fileService.ts:293
    at Object.g [as _notify] (winjs.base.raw.js:1170)
    at Object.enter (winjs.base.raw.js:852)
    at n.Class.derive._oncancel._run (winjs.base.raw.js:1068)
    at n.Class.derive._oncancel._completed (winjs.base.raw.js:1036)
    at FSReqWrap.cb [as oncomplete] (original-fs.js:240)
onError @ index.js:44
(anonymous) @ index.js:110
emitOne @ events.js:96
emit @ events.js:188
window.onerror @ C:\Program Files\Microsoft VS Code\resources\electron.asar\renderer\init.js:124
i.globals.onerror @ errorTelemetry.ts:64
Uncaught Error: File not found (c:\Program Files\Microsoft VS Code\src\libstd\fs.rs)        files.ts:507
    at new t (files.ts:507)
    at fileService.ts:293
    at Object.g [as _notify] (winjs.base.raw.js:1170)
    at Object.enter (winjs.base.raw.js:852)
    at n.Class.derive._oncancel._run (winjs.base.raw.js:1068)
    at n.Class.derive._oncancel._completed (winjs.base.raw.js:1036)
    at FSReqWrap.cb [as oncomplete] (original-fs.js:240)



md5-b00964861143e91b801154bc6035404a



File not found (c:\Program Files\Microsoft VS Code\src\libstd\fs.rs): Error: File not found (c:\Program Files\Microsoft VS Code\src\libstd\fs.rs)        shell.ts:423
    at new t (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:28:1088739)
    at file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:28:2407100
    at Object.g [as _notify] (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:28:52362)
    at Object.enter (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:28:55927)
    at n.Class.derive._oncancel._run (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:28:57755)
    at n.Class.derive._oncancel._completed (file:///C:/Program Files/Microsoft VS Code/resources/app/out/vs/workbench/workbench.main.js:28:57196)
    at FSReqWrap.cb [as oncomplete] (original-fs.js:240:19)

Of course, it works fine with the racer fallback setting turned on

Happens on linux too.

macOS 10.13 (beta) as well

Same here with Debian 9 and rustc 1.20.0 (stable). RUST_SRC_PATH is already set.

The popup error shows (for example) Unable to open file “mod.rs”: File not found (/checkout/src/libcore/fmt/mod.rs). I am curious about the checkout in the path. What is that?

However, it works for libraries installed by cargo. The issue only happens for std libraries.

On my windows machine it's looking for error.rs in:

c:\Program Files\Microsoft VS Code\src\libstd instead of
c:\Users\jkolb\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libstd

Having the same issue.

Me too

Was this page helpful?
0 / 5 - 0 ratings