-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: project json runnable kind bin substitution #20396
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
base: master
Are you sure you want to change the base?
Conversation
b3b3d93 to
4e74df9
Compare
|
I am not sure this is a fix, as the old behavior was not a bug, but documented: rust-analyzer/docs/book/src/non_cargo_based_projects.md Lines 203 to 207 in 3d2c40d
Though we have another comment that suggests this might be a bug: rust-analyzer/crates/project-model/src/project_json.rs Lines 316 to 319 in 3d2c40d
I am all for something like this change. I would propose to introduce a new "binOne" similar to "testOne" where this substitution applies. |
|
I added the I'm not necessarily opposed to applying the substitution on all runnables, but we should update the non_cargo_based_projects.md accordingly. |
|
On the comment about other runnable types, currently there is only TestOne and Run. The Check type is not used anywhere in the code see #20367 |
|
Honestly I would prefer if we go with a solution I have on my fork. See #20359 (comment) By adding the runnables to the crate itself instead of having a global runnables. The global runnables in my opinion were not well thought out since it's very likely in the case of external build systems that you have different targets for different runnables on the same crate. With the current design you can't really do this because we only have one label to substitute. |
I'd actually argue that's a compelling case for global runnables! :) By having a single command that rust-analyzer runs when you modify foo.rs, you can do nice things like merge duplicate build warnings (having a foo-proj and foo-proj-unittest is common in both buck and cargo). It also makes the JSON much smaller. |
|
I'm not sure I follow, I am referring to a single crate that has different labels depending on the runnable. Right now in the bazel implementation we always prioritize the test target to allow for the It seems buck2 does something similar here https://github.com/facebook/buck2/blob/5a565c288858a249e7043a27c2e271c92daf35bd/integrations/rust-project/src/buck.rs#L368-L373. There are only 2 runnables that work, It also makes the JSON much smaller.I don't believe this is an issue at all. This json is not being added to the VCS and if you use the discover command is simply piped and does not even write to disk. The argument that "larger json slower parse times" isnt really true. This file does not get nearly large enough for that to matter. In my case its just under 1MB (pretty-printed). I am writing it out because I want to debug the generated file when using discover command. These runnables are only added to the workspace crates not all dependencies. |
fixes a bug related to substitution in project json bin not correctly
replacing the `{label}` tag with the label of the current item.
4be202f to
2f064dd
Compare
|
Yeah, so test crates are tricky. In rust-project we don't just take the test crate, instead we attempt to merge the dependencies between the Being able to say "I've modified foo.rs, what command should I run?" is easier when you have a single check command. If you have N crates that include foo.rs and they each have a check command, what should rust-analyzer do? Can it run them all, can they be run in parallel, and how do you merge the results? FWIW cargo deduplicates errors across crates as of Rust 1.55 and we have similar logic in a and you get a squiggle complaining that your import isn't always used. Regarding JSON size, I agree it's not a big deal. I've seen rust-project.json files up to ~20 MiB in the last week, which isn't a huge problem. Adding a lot of redundancy to the file format would make reading the files during debugging slightly more annoying, but that's all. |
It is largely the same in the bazel implementation.
I largely agree that having the same file be apart of multiple crates is problematic when deciding which commands to run. However this PR is specifically related to the run binary type. I do want to also bring in my changes on my RA fork which include changes to complete the implementation for #20367. -- That being said, I am still unclear on what exactly is wrong with this PR particularly. Most of the arguments in this PR are related to changes which I intent to bring forward as a more general solution to #20359 so perhaps we should better move those discussions there? |
|
#18043 incorporated this change and has been merged, so this is done. |
fixes a bug related to substitution in project json bin not correctly replacing the
{label}tag with the label of the current item.