Skip to content
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

Automatically detect the rustc-src directory (fixes #3517) #7643

Merged
merged 1 commit into from
Feb 14, 2021

Conversation

bnjbvr
Copy link
Contributor

@bnjbvr bnjbvr commented Feb 11, 2021

If the configured rustcSource was not set, then try to automatically
detect a source for the sysroot rustc directory.

I wasn't sure how to do it in the case of the project.json file, though.

@bnjbvr bnjbvr changed the title Automatically detect the rustc-src directory (fixes #3517). Automatically detect the rustc-src directory (fixes #3517) Feb 11, 2021
@bnjbvr
Copy link
Contributor Author

bnjbvr commented Feb 11, 2021

Fwiw, this is blocked by rust-lang/rust#81997 so it works properly.

@matklad
Copy link
Member

matklad commented Feb 11, 2021

rustcSource is intentionally not auto-discovered. This is needed only when you work with #![rusc_private], which is not an officially supported use case.

@bnjbvr
Copy link
Contributor Author

bnjbvr commented Feb 11, 2021

I didn't know this, ok then. May I add that it can be useful in some cases, e.g. when a rustc version is pinned to a specific nightly, as may be done in alternative rustc compiler backends? (it's the case for rust-gpu right now)
Or would you advise having a project-specific LSP settings.json in this specific case?

@matklad
Copy link
Member

matklad commented Feb 11, 2021

Yeah, I'd probably advice to commint settings.json to git. What we might do as well is so have opt-in auto-discovery. Ie, if the settings explicitly contain "rustSrc": "discover", we run this logic. What we need to avoid is adding rustSrc to all the users.

@bnjbvr
Copy link
Contributor Author

bnjbvr commented Feb 11, 2021

Cool idea; do you mean rustcSource could be set to discover? I'm happy to try it here.

@bnjbvr
Copy link
Contributor Author

bnjbvr commented Feb 11, 2021

I've now implemented this. It's a bit convoluted so that we're able to keep feature parity, namely the possibility to indicate a path relative to the root path; please let me know what you think of it!

crates/project_model/src/sysroot.rs Outdated Show resolved Hide resolved
crates/project_model/src/cargo_workspace.rs Outdated Show resolved Hide resolved
).

If the configured rustcSource is set to "discover", try to automatically
detect a source from the sysroot rustc directory.
@bnjbvr
Copy link
Contributor Author

bnjbvr commented Feb 13, 2021

Thanks for the review! The new version is much simpler 👍

@matklad
Copy link
Member

matklad commented Feb 14, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented Feb 14, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants