Hey all!
I have a couple of questions:
- Is it expected that in a code base where with Cargo you would have many
Cargo.toml files spread across multiple folders, you only use one rust-project.json?
- Is there a way to give some info on what file we want to "cargo check" (i.e. what file triggered the invocation of
checkOnSave.overrideCommand)? For example, passing it as an argument to checkOnSave.overrideCommand.
My personal investigation has reached "yes, you should have only one rust-project.json" for 1.:
- in
rust-project.json you reference deps with their index in the array for the same rust-project.json file, and I don't know how this could be compatible with multiple rust-project.jsons
- trying to run
rust-analyzer with multiple rust-project.jsons doesn't work - e.g. cross rust-project.json goto def doesn't work
and "no" for 2.:
- it seems that nothing dynamic is passed to the executable when it's run (in the source code) - only the presupplied args and the environment from
checkOnSave.extraEnv are passed, which both appear to be static
This combination is very unfortunate, because now, there is no way for the tool that's going to be used instead of cargo check to know what it should be building - in a huge repo, this is not viable.
I assume that when we're using cargo this "what should I build" issue is resolved by the fact that cargo check is run in the root of the workspace, which is determined by a Cargo.toml file. However, in the rust-project.json, this is no longer a solution, because we can have only one rust-project.json file, hence in order to be correct, the only thing checkOnSave.overrideCommand could do is build everything in the workspace.
My proposed solutions are to do one of
- "fix" 2. so that we pass some info to
checkOnSave.overrideCommand (seems to be much easier)
- "fix" 1. to allow autodiscovery and combining of
rust-project.json files - seems to be much more difficult to implement, but perhaps it's a better approach in the long run, so that the assumptions made for cargo based projects are also valid for rust-project.json based ones?
I would be happy to implement some version of "fix" 2., if we could come to an agreement on what that would be.
Context:
I'm trying to implement diagnostics support for rust-analyzer+rules_rust, which relies on checkOnSave.overrideCommand/cargo check.
Hey all!
I have a couple of questions:
Cargo.tomlfiles spread across multiple folders, you only use onerust-project.json?checkOnSave.overrideCommand)? For example, passing it as an argument tocheckOnSave.overrideCommand.My personal investigation has reached "yes, you should have only one rust-project.json" for 1.:
rust-project.jsonyou reference deps with their index in the array for the samerust-project.jsonfile, and I don't know how this could be compatible with multiplerust-project.jsonsrust-analyzerwith multiplerust-project.jsons doesn't work - e.g. crossrust-project.jsongoto def doesn't workand "no" for 2.:
checkOnSave.extraEnvare passed, which both appear to be staticThis combination is very unfortunate, because now, there is no way for the tool that's going to be used instead of
cargo checkto know what it should be building - in a huge repo, this is not viable.I assume that when we're using
cargothis "what should I build" issue is resolved by the fact thatcargo checkis run in the root of the workspace, which is determined by aCargo.tomlfile. However, in therust-project.json, this is no longer a solution, because we can have only onerust-project.jsonfile, hence in order to be correct, the only thingcheckOnSave.overrideCommandcould do is build everything in the workspace.My proposed solutions are to do one of
checkOnSave.overrideCommand(seems to be much easier)rust-project.jsonfiles - seems to be much more difficult to implement, but perhaps it's a better approach in the long run, so that the assumptions made for cargo based projects are also valid forrust-project.jsonbased ones?I would be happy to implement some version of "fix" 2., if we could come to an agreement on what that would be.
Context:
I'm trying to implement diagnostics support for
rust-analyzer+rules_rust, which relies oncheckOnSave.overrideCommand/cargo check.