-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Option to use the rustup-provided proc-macro-srv #12855
Comments
This sounds very much wrong, there is no reason for the server to make that path relative to the project workspace... Though maybe this was always meant to be an internal setting so far. Would it be an option (speaking short term at least) to expose a command override that is used to spawn the proc-macro server? Then I imagine you could set it to something like |
There's a couple design considerations there. The command you're looking for, btw, is To start with, I suppose for a start, we can accept that the channel (
That could be a viable step in the right direction! |
(possibly slight topic change but I just went on rustup documentation hunt) That aside I think we should have a proper override command setting instead of just the server path nevertheless (as well as fixing the server path being relative). |
(nit: rust-analyzer is already a component - it just wasn't very useful as a component so far, because ABI breakage, yada yada) Yes, that's another path forward. There's a PR to add a rust-analyzer proxy for rustup: rust-lang/rustup#3022 I think @kinnison is waiting for the go-ahead from more rust-analyzer folks to merge it? After that, the override path can just be Another concern we have in parallel to that, is that now we suddenly can have a mismatch between the |
Okay so to re-iterate then: short term
long term:
Does this capture everything from this issue or am I missing something here (except for the last concern you mentioned now)? |
Yes to everything you said except this part:
This should happen even in the 99% case where the VSCode user is using the "VSCode Marketplace" version of the r-a binary. The proper condition is if the cargo/rustc being used is provided by rustup. (This isn't the case if they're installed via the distribution package manager, for example - another discussion topic for another time). |
Ah okay, ye that makes more sense actually :) So the question there is how to query that, is it enough to just check if With that said, the short term items here are rather easy to fix then, the biggest problem there is getting the proxy component PR merged. (And If I see this right, judging from a quick glance at the source, spawning a proc-macro server per workspace shouldn't be too tough if not hidden problems exist there) |
I'd do
Yeah, I tried leaving encouraging comments on rust-lang/rustup#3022 but I think the concern is that it'll "break someone's workflow" if they've installed their own rust-analyzer binary with As far as I can tell, the "DUP" mechanism is designed exactly for that: it won't override anything you already have in your |
I'll drop a topic in #t-devtools -> https://rust-lang.zulipchat.com/#narrow/stream/301329-t-devtools/topic/Best.20way.20for.20to.20query.20whether.20rustup.20is.20used
From the looks of it there shouldn't be any problems with that, as said the DUP mechanism should fix that problem.
Just went and checked, did a quick implementation and it seems to work fine with multiple servers #12856 |
This PR moves us along the "separate proc-macro-srv binary" path: I've gotten initial positive feedback about shipping it as part of the rustc component, which means it would be installed for all toolchains (past a certain date), even when rustc isn't installed via rustup. |
feat: Spawn a proc-macro-srv instance per workspace cc #12855 The idea is to have each server be spawned with the appropriate toolchain, that way workspaces with differing toolchains shouldn't suffer from proc-macro abi mismatches.
This is now done automatically and should work out of the box starting from rust-analyzer stable 2022-08-01 for rust |
Well, doesn't that bring back memories? 😄 |
Since RA as a subtree looks like it's gonna land soon, I'm looking at next steps.
I'm already happily using it locally with a
rust-toolchain
of:Having installed RA like so:
And having VSCode workspace settings (
.vscode/settings.json
) of:This is very close to something I can tell others to do.
The issue is, as soon as "RA as a subtree" lands and that we have the "
rust-analyzer proc-macro
always works with therustc
from the same toolchain+channel" guarantee, what I want instead is this:There's several issues with that:
rust-analyzer.procMacro.server
wants a path relative to the workspace for some reason, so the actual path it tries to execute is/home/amos/bearcove/some-project/home/amos/.rustup/...
/home/amos
to a shared Git repositoryrust-toolchain.toml
already is.. not very DRY. rust-analyzer already has code to discover the toolchain / various tools, I'd expect it to do the right thing here too.But what is the right thing?
The dream scenario
In my dreams, when expanding a proc-macro, rust-analyzer:
rust-analyzer
component as neededrust-analyzer proc-macro
subcommand and uses that, for this proc macroThere's a bunch of moving pieces there - I don't know how hard the current codebase assumes that we have "a single proc-macro-srv binary" (and then that binary is responsible for handling all possible ABIs).
The short-term win
Because this is all relatively new, we might not want to mess with defaults just yet. Instead, we could add another option, say maybe:
Under the hood, this executes
rustup which rust-analyzer
at the top of the workspace:And attempts
rustup component add rust-analyzer
once if that fails.One alternative is to have a special value for
rust-analyzer.procMacro.server
that's just the "rustup" string, but using an in-band value / picking "rustup" as a niche feels odd.The downside of having an option like
rust-analyzer.procMacro.serverFromRustup
is that we need to decide if it takes precedence overrust-analyzer.procMacro.server
(I think it should).Later on, if we're happy with that behavior, we can change the default to true (and folks can still opt out of it by setting it to
false
explicitly).The text was updated successfully, but these errors were encountered: