-
Notifications
You must be signed in to change notification settings - Fork 13k
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
--crate-type metadata overrides binary-ness of crates #38273
Comments
Hm this is indeed unfortunate! I'd probably be a fan of looking for a |
I don't like the idea of looking for main - what if the user wants it to be a binary and mis-types main? Then we get the wrong errors. We'd also have to take into account A few ideas:
cc @rust-lang/compiler @rust-lang/tools |
But the compiler already has a pass for gathering this information, so that would not be an obstacle. |
I'd like to avoid adding two crate types for this at all costs if possible (plus it's already landed so it'd be difficult to change). This basically only deals with lint warnings, so I think @michaelwoerister has a good point that we can just, if compiling metadata, consider the start function, if any, used. I agree that it shouldn't be too difficult to implement in the compiler as well. |
@alexcrichton what do you think of this idea, I think it is my favourite, although the semantics are a little bit non-obvious:
|
@nrc to clarify, that's for special casing when the compiler has two crate types requested, one for metadata and one for a binary? If that's true, wouldn't that not solve the |
I agree it's easy to implement, but I'm not sure it's the right thing. If I understand the context correctly, @nrc is using this in the RLS. This means that if you are building a library and you have dead-code relating to a |
@nikomatsakis that is indeed a very good point. The only solution I see to that is indeed having a metadata-lib and a metadata-bin crate type. Or just considering |
Please triage and add a P-tag. This seems important since it involves a recently-added stable interface. |
I vote for p-high given it affects stability and we'll need to uplift to beta. I'm working on a fix. |
I believe this is no longer an issue since we moved to |
If you make a crate metadata, then it treats the crate as a library in all cases. This causes problems because the compiler will think that any non-public code is dead and issue warnings.
I'm not exactly sure the fix here - I don't want to always silence these warnings because they are valid for library crates. OTOH, I don't really want metadata-bin as another crate type, that might be the best thing to do though.
cc @alexcrichton
The text was updated successfully, but these errors were encountered: