-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Reinstate CARGO_PRIMARY_PACKAGE #7205
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. |
This was added a long time ago in #5824 for |
It's for when you have a |
Hm yes that was the old purpose of this env var but can you elaborate what the specific use cases you're thinking of are? The idea of a "primary package" is pretty fuzzy and changes quite a bit over time as we add features and fix things, so it's not clear that there's something we could commit to stabilizing. |
Sorry, let me be less vague. My specific use case is to generate something akin to protobuf from the types and As far as I can tell, Clippy used it similarly to ensure that users don't get errors and warnings from code they didn't write. In my mind, a primary package is a stable concept:
Strictly speaking, this can be worked around--even somewhat stably by reading the Cargo.toml---but it's unfortunate to re-implement what the compiler is already determining for itself. Maybe the right answer isn't to put back CARGO_PRIMARY_PACKAGE, but at least here's a vote for something like it. There probably aren't enough users of |
Egad sorry for the delay @nhynes! Can you also clarify how you're overriding rustc to see this? That seems like it would be difficult to do from crates.io as a dependency. In terms of an unstable concept what I'm thinking about is things like what do we do with workspaces, what do we do with multiple I'm not necessarily saying we can't have a stable concept of a primary package, what I'm saying is that we probably shouldn't just take exactly what's there today and call it stable. Rather we should probably sit down and think about this and see if it's the right thing to stabilize. |
Hey no worries! You've only got, what? The entire rest of the Rust ecosystem to look at :)
Oh, it's just a RUSTC_WRAPPER that uses
That's a great point. The idea of "primary package" is application specific. In the case of bins and libs, it's fairly straightforward: whatever is (implicitly) passed to From a rustc_wrapper implementer's point of view, the only difficult thing to detect is the lib specified by Ideally, one would parse the result of In any case, I'll close this for now and hope that someone else with a similar problem comes along someday :) Thanks! |
#7069 removed
CARGO_PRIMARY_PACKAGE
since it's no longer needed by Clippy. It is, however, useful for other rustc wrappers. It'd be great to have this back.