What is this lint about
The deprecated_cfg_attr_crate_type_name lint detects uses of the #![cfg_attr(..., crate_type = "...")] and #![cfg_attr(..., crate_name = "...")] attributes to conditionally specify the crate type and name in the source code. For example:
#![cfg_attr(debug_assertions, crate_type = "lib")]
Explanation
The #![crate_type] and #![crate_name] attributes require a hack in the compiler to be able to change the used crate type and crate name after macros have been expanded. Neither attribute works in combination with Cargo as it explicitly passes --crate-type and --crate-name on the commandline. These values must match the value used in the source code to prevent an error.
How to fix this warning/error
To fix the warning use --crate-type on the commandline when running rustc instead of #![cfg_attr(..., crate_type = "...")] and --crate-name instead of #![cfg_attr(..., crate_name = "...")].
We are interested to hear about any/all use cases for conditional #![crate_type] and #![crate_name] attributes.
Current status
What is this lint about
The
deprecated_cfg_attr_crate_type_namelint detects uses of the#![cfg_attr(..., crate_type = "...")]and#![cfg_attr(..., crate_name = "...")]attributes to conditionally specify the crate type and name in the source code. For example:#![cfg_attr(debug_assertions, crate_type = "lib")]Explanation
The
#![crate_type]and#![crate_name]attributes require a hack in the compiler to be able to change the used crate type and crate name after macros have been expanded. Neither attribute works in combination with Cargo as it explicitly passes--crate-typeand--crate-nameon the commandline. These values must match the value used in the source code to prevent an error.How to fix this warning/error
To fix the warning use
--crate-typeon the commandline when running rustc instead of#![cfg_attr(..., crate_type = "...")]and--crate-nameinstead of#![cfg_attr(..., crate_name = "...")].We are interested to hear about any/all use cases for conditional
#![crate_type]and#![crate_name]attributes.Current status
deprecated_cfg_attr_crate_type_namelint as warn-by-defaultdeprecated_cfg_attr_crate_type_namelint deny-by-defaultdeprecated_cfg_attr_crate_type_namelint a hard error