-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Make deprecated_cfg_attr_crate_type_name a hard error #129670
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,6 @@ declare_lint_pass! { | |
DEAD_CODE, | ||
DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK, | ||
DEPRECATED, | ||
DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME, | ||
DEPRECATED_IN_FUTURE, | ||
DEPRECATED_SAFE_2024, | ||
DEPRECATED_WHERE_CLAUSE_LOCATION, | ||
|
@@ -3143,42 +3142,6 @@ declare_lint! { | |
"detects large moves or copies", | ||
} | ||
|
||
declare_lint! { | ||
/// 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. | ||
/// | ||
/// ### Example | ||
/// | ||
/// ```rust,compile_fail | ||
/// #![cfg_attr(debug_assertions, crate_type = "lib")] | ||
/// ``` | ||
/// | ||
/// {{produces}} | ||
/// | ||
/// | ||
/// ### 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. | ||
/// | ||
/// 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 = "...")]`. | ||
pub DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME, | ||
Deny, | ||
"detects usage of `#![cfg_attr(..., crate_type/crate_name = \"...\")]`", | ||
@future_incompatible = FutureIncompatibleInfo { | ||
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this has not gone through a "report in deps" stage. Fine for me, but I just wanted to call it out for awareness. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think with the low usage it has in the ecosystem, the step can be skipped. |
||
reference: "issue #91632 <https://github.com/rust-lang/rust/issues/91632>", | ||
}; | ||
} | ||
|
||
declare_lint! { | ||
/// The `unexpected_cfgs` lint detects unexpected conditional compilation conditions. | ||
/// | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
error: `crate_type` within an `#![cfg_attr]` attribute is forbidden | ||
--> $DIR/crate-attributes-using-cfg_attr.rs:4:18 | ||
| | ||
LL | #![cfg_attr(foo, crate_type="bin")] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: `crate_name` within an `#![cfg_attr]` attribute is forbidden | ||
--> $DIR/crate-attributes-using-cfg_attr.rs:7:18 | ||
| | ||
LL | #![cfg_attr(foo, crate_name="bar")] | ||
| ^^^^^^^^^^^^^^^^ | ||
|
||
error: `crate_type` within an `#![cfg_attr]` attribute is forbidden | ||
--> $DIR/crate-attributes-using-cfg_attr.rs:4:18 | ||
| | ||
LL | #![cfg_attr(foo, crate_type="bin")] | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: `crate_name` within an `#![cfg_attr]` attribute is forbidden | ||
--> $DIR/crate-attributes-using-cfg_attr.rs:7:18 | ||
| | ||
LL | #![cfg_attr(foo, crate_name="bar")] | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: aborting due to 4 previous errors | ||
|
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.