Warn when crate_type
attribute is ignored because of --crate-type
#43987
Labels
A-attributes
Area: Attributes (`#[…]`, `#![…]`)
A-CLI
Area: Command-line interface (CLI) to the compiler
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I just learned the hard way (i.e. after lots of scratching my head) that the
crate_type
attribute is entirely ignored when Cargo is used. This is hinted at in https://doc.rust-lang.org/nightly/reference/linkage.html, but only if you know that cargo always passes--crate-type
. The first hit when I search for the attribute is https://rustbyexample.com/attribute/crate.html which doesn't mention this at all.Those sites should probably be fixed, but moreover, I think the compiler shouldn't just silently ignore these attributes. It should tell me. That would have saved me lots of time.
(There may be other attributes which are similarly ignored.
crate_name
comes to my mind. But I don't know for sure.)The text was updated successfully, but these errors were encountered: