Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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!

).

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

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

Successfully merging this pull request may close these issues.

2 participants