-
Notifications
You must be signed in to change notification settings - Fork 279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Racer now uses rustup to find the stdlib source code even when used as a library. #799
Conversation
This helps with, although doesn't eliminate this: #751 |
Oops, tests fail because the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments; most are minor.
Is it possible to include a test for this? I know that the fixtures
directory is pretty out-of-date, so if we can't then that's fine.
src/racer/config.rs
Outdated
@@ -0,0 +1,23 @@ | |||
use std::path::PathBuf; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a generic config.rs
makes me suspicious; it seems likely that it'll become a parking lot for a bunch of unrelated items. Can you make the name for this more specific to file paths?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I can; however, I originally thought that it would be actually good to have a centralised module for reading any needed configuration from the environment and keeping the state. Do you think it would make sense to move this to nameres.rs
where RUST_SRC_PATHS
is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm personally a fan of smaller, purpose-oriented modules, so I'd suggest one that only contained this and have that be used by nameres
. However, I'm fine with it living in nameres.rs
directly for the time-being.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, I'll refactor that.
/// Test if the **path expression** starts with `::`, in which case the path | ||
/// should be checked against the global namespace rather than the items currently | ||
/// in scope. | ||
// Test if the **path expression** starts with `::`, in which case the path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for cleaning these up; it makes me sad to lose the ability to add doc comments to locals and have them show up in completions, but the rustdoc team has spoken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did they actually consider that use case? It might be that they just missed it, and deprecated this as an useless thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They considered it; I asked them about it, which was what prompted the discussion which ended in deprecation.
src/racer/nameres.rs
Outdated
@@ -11,13 +11,9 @@ use matchers::find_doc; | |||
use cargo; | |||
use std::path::{Path, PathBuf}; | |||
use std::{self, vec}; | |||
use std::iter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you combine this with the use
on the previous line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aye.
src/racer/nameres.rs
Outdated
let srcpaths = match std::env::var("RUST_SRC_PATH") { | ||
Ok(paths) => paths, | ||
Err(_) => return out.into_iter() | ||
if config::RUST_SRC_PATHS.is_empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes the comment above inaccurate; can you please update it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
What is the purpose of the fixtures directory? |
Ping @TedDriggs , in case you didn't notice my updates and question. |
I actually don't know, but I got the impression that it was supposed to do something around environment tests like this. |
The fixtures directory has projects for tests. It allows us to test very specific setups; although, it hasn't gotten much use outside of 1-2 tests. |
Since there was a TODO comment that indicated that a more thorough refactoring might be good, I went ahead and did that. It now resolves to a single path using multiple sources (the env var, rustup and default path list) that is verified to contain the stdlib source. Also added tests. |
I'd very much appreciate if, when this gets pulled in, a new version of Racer would be released; updating RLS to use the new version, it would make RLS setup one step easier. |
The Windows build fails the test that uses |
The Windows build seems to work on all but one architecture, so I don't think it's a problem with the AppVeyor config. |
All right, all requested changes are done (Although Github claims otherwise) and tests are passing. |
Friendly ping to @TedDriggs . This PR is waiting for a (hopefylly) final review for merge. |
} | ||
assert!(get_rust_src_path().is_ok()); | ||
|
||
match original { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: You could create a struct, that stores the original RUST_SRC_PATH and implement Drop. If drop is called, you would reset to the original env var. This could reduce some code duplication in the tests :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. If @jwilm is happy then we can go ahead and merge.
Ping @jwilm , is there anything I can do to make this go forward? |
@TedDriggs is there any other maintainers that could approve of this? |
Refactored the
stdlib
source code search a bit: It now stores the path in alazy_static
, and doesn't load it directly from an env var at usage sites. When initializing thelazy_static
, it checks both theRUST_SRC_PATH
env var andrustup
'srust-src
component. It used userustup
only when using Racer as a binary. Now it does it even when used as a library.This allows using RLS without setting
RUST_SRC_PATH
; it suffices thatrustup
is installed. Before, it just used to crash ifRUST_SRC_PATH
wasn't set.Also got rid of the warnings: converted a few
\\\
doc comments that weren't actual item doc comments to\\
normal comments, and got rid of the non-usedextern crates
that were likely left from when the binary and library were not separated.