-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Tracking issue for future-incompatibility lint deprecated_cfg_attr_crate_type_name #91632
Copy link
Copy link
Closed
Closed
Copy link
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-future-incompatibilityCategory: Future-incompatibility lintsCategory: Future-incompatibility lintsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-future-incompatibilityCategory: Future-incompatibility lintsCategory: Future-incompatibility lintsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
Status
Idea
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