-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add option to only run build scripts and compile proc macros #9071
Add option to only run build scripts and compile proc macros #9071
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Eh2406 (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
+1, we need something like this for rust-analyzer. |
I'm personally not entirely sure about what to do with options like this. They feel extremely specialized and while they may solve a use case today, I don't think there's a guarantee it'll solve much more in the future or whether the intended users (IDEs) would continue to use this option in the future (or require tweaks or something like that). You can already effectively emulate this option by setting One of the weaknesses of a feature like this is that it doesn't really have a clear definition. It's pretty ad-hoc and tied to exactly how Cargo implements things today. This means that future changes to Cargo may be difficult to implement an option like this since it may not have a clear mapping into a future refactoring of Cargo. |
I personally am a bit more confident about the general idea :) The feature IDE want is "run all of the I do think this is a part of an IDE end-game package. Even in the glorious future, when rust-analyzer and rustc are one, and Rust has "edit and continue", the IDE would still like to instruct the build system: "please, build all of the proc-macros, so that I can expand them, but don't try to build/check the code, as I am better at showing the error squiggly". But I also agree with your concerns about unclear scope here. This feels analogous to The |
Also, I'd suggest not to have lengthy discussions about the option name because most likely no one will use it, except intellij and ra, and infinite unstable status is ok for us, as well as it's ok if the option will be renamed in the future. |
I suppose we could use the same "run self" trick as in the proc macro server. |
Sorry for the delay in review. Seams like the code is not the controversial part. I put discussing this on the agenda for tuesdays Cargo Meating. |
Can you provide some more information about how the IDE integration works? Do you dlopen the proc-macros and execute them directly? Are you able to analyze a project without the dependencies? Does intellij/ra somehow find all the dependency sources and analyze them directly from source? How does it know how to set Also, to be clear, from an implementation standpoint this is probably not an approach we would like to go with. Overriding the jobs at such a low level is a bit too much of a hack for my taste. Ideally it would only generate a unit graph for the pieces it needs. It would be good to discuss before venturing more into implementation, though. |
Sure. Both intellij and ra analyze a project and dependencies directly from sources. "dependencies" also includes the standard library. Without dependencies/stdlib information IDE lowers to a simple editor. We use Then we need Proc macro dlls are retrieved with the same |
Off-topic: @vlad20012 how do you handle the different proc macro ABI versions? We only support the latest stable one, but figuring out the corresponding compiler versions across beta and stable builds is pretty annoying. |
We're evaluating a @lnicola for now we do it exactly as rust-analyzer does. We even use |
Once every couple of months (2-3 releases), it seems.
Oh 😳. |
6735: Compile only buildscripts and proc macros when fetching build scripts r=undin a=vlad20012 Trying suggestion from rust-lang/cargo#9071 (comment) Co-authored-by: vlad20012 <beskvlad@gmail.com>
☔ The latest upstream changes (presumably #9161) made this pull request unmergeable. Please resolve the merge conflicts. |
This is needed for IDEs
I'm gonna close this due to inactivity. Generally we prefer new features to have some level of discussion before moving directly to a PR. It is not entirely clear how this should work, and looks like it needs more consideration than can be handled on a PR. More information about the process of adding new features can be found at https://doc.crates.io/contrib/process/index.html. Thanks! |
FWIW this is what IDEs do now and it leads to all sorts of problems. :/ I think some sort of help from cargo will be needed here, the crude hacks that are used to work around the absence of cargo support are falling apart quickly. |
Add option to
cargo check
to only run build scripts and compile proc macros. This is needed for IDEs to e.g. obtain features defined by build scripts. See #7178 for detailsThis option can be used on stable Rust like this: