racer-rust / emacs-racer

Racer support for Emacs
399 stars 48 forks source link

Fixed issues related to RUST_SRC_PATH #144

Closed xuyizhe closed 3 years ago

xuyizhe commented 3 years ago

I just fixed some issues related to rust-src, maybe it works for you.

$ rustc --version
rustc 1.48.0-nightly (0da580074 2020-09-22)

$ racer --version
racer 2.1.39

1. Racer

~/.spacemacs.env for spacemacs user. (Replace username and rust version)

RUST_SRC_PATH=/Users//.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library


- ### You prefer the path to be found automatically
I fixed it in master https://github.com/racer-rust/racer/commit/3bcf543f3d0237e5fa545c56b2d51f91207ee500. You can manually compile before the next release version.

## 2. Emacs
I created a PR #143 to fix. Or you can do a quick fix:
```elisp
(setq racer-rust-src-path
      (let* ((sysroot (string-trim
                       (shell-command-to-string "rustc --print sysroot")))
             (lib-path (concat sysroot "/lib/rustlib/src/rust/library"))
              (src-path (concat sysroot "/lib/rustlib/src/rust/src")))
        (or (when (file-exists-p lib-path) lib-path)
            (when (file-exists-p src-path) src-path))))