Description
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
- Deprecate crate_type and crate_name nested inside #![cfg_attr] #83744 introduces the
deprecated_cfg_attr_crate_type_name
lint as warn-by-default - Make forward compatibility lint deprecated_cfg_attr_crate_type_name deny by default #99784 makes the
deprecated_cfg_attr_crate_type_name
lint deny-by-default - PR Make deprecated_cfg_attr_crate_type_name a hard error #129670 makes the
deprecated_cfg_attr_crate_type_name
lint a hard error
Metadata
Metadata
Assignees
Labels
Type
Projects
Status