Skip to content

Commit 134cc2d

Browse files
authored
Rollup merge of #99784 - est31:deny_cfg_attr_crate_type_name, r=Mark-Simulacrum
Make forward compatibility lint deprecated_cfg_attr_crate_type_name deny by default Turns the forward compatibility lint added by #83744 to deprecate `cfg_attr` usage with `#![crate_type]` and `#![crate_name]` attributes into deny by default. Copying the example from #83744: ```Rust #![crate_type = "lib"] // remains working #![cfg_attr(foo, crate_type = "bin")] // will stop working ``` Over 8 months have passed since #83744 was merged so I'd say this gives ample time for people to have been warned, so we can make the warning stronger. No usage was found via grep.app except for one, which was in an unmaintained code base that didn't seem to be used in the open source eco system. The crater run conducted in #83744 also didn't show up anything. cc #91632 - tracking issue for the lint
2 parents 539e408 + 152c851 commit 134cc2d

4 files changed

+9
-16
lines changed

compiler/rustc_lint_defs/src/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3094,7 +3094,7 @@ declare_lint! {
30943094
///
30953095
/// ### Example
30963096
///
3097-
/// ```rust
3097+
/// ```rust,compile_fail
30983098
/// #![cfg_attr(debug_assertions, crate_type = "lib")]
30993099
/// ```
31003100
///
@@ -3114,7 +3114,7 @@ declare_lint! {
31143114
/// rustc instead of `#![cfg_attr(..., crate_type = "...")]` and
31153115
/// `--crate-name` instead of `#![cfg_attr(..., crate_name = "...")]`.
31163116
pub DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME,
3117-
Warn,
3117+
Deny,
31183118
"detects usage of `#![cfg_attr(..., crate_type/crate_name = \"...\")]`",
31193119
@future_incompatible = FutureIncompatibleInfo {
31203120
reference: "issue #91632 <https://github.com/rust-lang/rust/issues/91632>",

src/test/codegen/external-no-mangle-statics.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// revisions: lib staticlib
22
// ignore-emscripten default visibility is hidden
33
// compile-flags: -O
4+
// [lib] compile-flags: --crate-type lib
5+
// [staticlib] compile-flags: --crate-type staticlib
46
// `#[no_mangle]`d static variables always have external linkage, i.e., no `internal` in their
57
// definitions
68

7-
#![cfg_attr(lib, crate_type = "lib")]
8-
#![cfg_attr(staticlib, crate_type = "staticlib")]
9-
109
// CHECK: @A = local_unnamed_addr constant
1110
#[no_mangle]
1211
static A: u8 = 0;

src/test/ui/cfg/future-compat-crate-attributes-using-cfg_attr.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// check-fail
22
// compile-flags:--cfg foo
33

4-
#![deny(warnings)]
54
#![cfg_attr(foo, crate_type="bin")]
65
//~^ERROR `crate_type` within
76
//~| WARN this was previously accepted

src/test/ui/cfg/future-compat-crate-attributes-using-cfg_attr.stderr

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
error: `crate_type` within an `#![cfg_attr] attribute is deprecated`
2-
--> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:5:18
2+
--> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:4:18
33
|
44
LL | #![cfg_attr(foo, crate_type="bin")]
55
| ^^^^^^^^^^^^^^^^
66
|
7-
note: the lint level is defined here
8-
--> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:4:9
9-
|
10-
LL | #![deny(warnings)]
11-
| ^^^^^^^^
12-
= note: `#[deny(deprecated_cfg_attr_crate_type_name)]` implied by `#[deny(warnings)]`
7+
= note: `#[deny(deprecated_cfg_attr_crate_type_name)]` on by default
138
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
149
= note: for more information, see issue #91632 <https://github.com/rust-lang/rust/issues/91632>
1510

1611
error: `crate_name` within an `#![cfg_attr] attribute is deprecated`
17-
--> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:10:18
12+
--> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:9:18
1813
|
1914
LL | #![cfg_attr(foo, crate_name="bar")]
2015
| ^^^^^^^^^^^^^^^^
@@ -23,7 +18,7 @@ LL | #![cfg_attr(foo, crate_name="bar")]
2318
= note: for more information, see issue #91632 <https://github.com/rust-lang/rust/issues/91632>
2419

2520
error: `crate_type` within an `#![cfg_attr] attribute is deprecated`
26-
--> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:5:18
21+
--> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:4:18
2722
|
2823
LL | #![cfg_attr(foo, crate_type="bin")]
2924
| ^^^^^^^^^^^^^^^^
@@ -32,7 +27,7 @@ LL | #![cfg_attr(foo, crate_type="bin")]
3227
= note: for more information, see issue #91632 <https://github.com/rust-lang/rust/issues/91632>
3328

3429
error: `crate_name` within an `#![cfg_attr] attribute is deprecated`
35-
--> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:10:18
30+
--> $DIR/future-compat-crate-attributes-using-cfg_attr.rs:9:18
3631
|
3732
LL | #![cfg_attr(foo, crate_name="bar")]
3833
| ^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)