racer-rust / racer

Rust Code Completion utility
MIT License
3.36k stars 278 forks source link

Panic on primitive_docs.rs search #1131

Open Leorii opened 3 years ago

Leorii commented 3 years ago

Panic occurs when typing a std module name.

Example

impl Display for MyStruct {
    fn fmt(&self, f: &mut fm

'thread \'searcher\' panicked at \'Failed load file "$HOME/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/std/src/primitive_docs.rs": Os { code: 2, kind: NotFound, message: "No such file or directory" }\', $HOME/.cargo/registry/src/github.com-1ecc6299db9ec823/racer-2.1.38/src/racer/core.rs:816:14\nnote: run with RUST_BACKTRACE=1 environment variable to display a backtrace\n'

Thoughts

I believe this might have something to do with #1130. The completion does still work (it attempts to find the source from the original rust directory layout), but then I think it still tries to find the source from the new layout and fails at that.

Leorii commented 3 years ago

I think I found the source of the bug: https://github.com/racer-rust/racer/pull/1130/files#r489576403

I'm happy to submit a PR for this if anyone would like to tell me if I'm headed in the right direction here.

Leorii commented 3 years ago

I have a temporary fix on my system that I believe also confirms that this is the issue. I have symlinked the $RUST_SRC_PATH/libstd directory to $RUST_SRC_PATH/std/src, and that seems to work fine for now. But I would still be happy to submit a PR if this is a valid issue/concern.

If anyone else wants the temporary fix, do this:

SOURCE_DIR=$(rustc --print sysroot)/lib/rustlib/src/rust/src

mkdir $SOURCE_DIR/std
ln -s $SOURCE_DIR/libstd $SOURCE_DIR/std/src
kngwyu commented 3 years ago

Thanks, I think you're in the right direction as I commented.

Since recently I don't have enough time to maintain this project sufficiently, PR is very welcome.

I think the PR might not be very complicated: we just have to add older locations looking #1130.

Leorii commented 3 years ago

Whoops, forgot about this. I'd be happy to submit a PR for it :D