racer-rust / emacs-racer

Racer support for Emacs
398 stars 48 forks source link

racer-rust-src-path defaults to rustup source directory #72

Closed ghost closed 7 years ago

ghost commented 7 years ago

Fixes issue #54. Works for both old and new versions of racer.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 66.106% when pulling c843e09fb13e5d0c326864ee32aa9363323f14cc on jonves:master into 485b827cfaca5e4e204e5529912d7999bc29bde7 on racer-rust:master.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 66.106% when pulling c843e09fb13e5d0c326864ee32aa9363323f14cc on jonves:master into 485b827cfaca5e4e204e5529912d7999bc29bde7 on racer-rust:master.

Wilfred commented 7 years ago

Thanks for your contribution! This is definitely a worthwhile improvement.

This code currently assumes that rustc is on path, which leads to:

ELISP> (concat (shell-command-to-string "rustc --print sysroot") "/lib/rustlib/src/rust/src")
"zsh:1: command not found: rustc\n/lib/rustlib/src/rust/src"

I suggest we use (executable-find "rustc") to confirm that rustc is on path first.

In the spirit of not breaking people's setups, I think we should still fall back to "/usr/local/src/rust/src". Users might be depending on that.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 66.106% when pulling 495249147e7956ef52cbc8e2b44e63419f31718d on jonves:master into 485b827cfaca5e4e204e5529912d7999bc29bde7 on racer-rust:master.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 66.106% when pulling 495249147e7956ef52cbc8e2b44e63419f31718d on jonves:master into 485b827cfaca5e4e204e5529912d7999bc29bde7 on racer-rust:master.

ghost commented 7 years ago

Updated pull request.

racer-rust-src-path will now verify that rustc is in path, and if so, will check if the rust source has been installed via rustup. If present, use it, otherwise fall back to "/usr/local/src/rust/src" as default.

I think this would allow users of rustup to safely ignore racer-rust-src-path, while remaining backwards compatible with current users.

Wilfred commented 7 years ago

Thanks! :)