Skip to content

Commit

Permalink
Rollup merge of rust-lang#99784 - est31:deny_cfg_attr_crate_type_name…
Browse files Browse the repository at this point in the history
…, r=Mark-Simulacrum

Make forward compatibility lint deprecated_cfg_attr_crate_type_name deny by default

Turns the forward compatibility lint added by rust-lang#83744 to deprecate `cfg_attr` usage with `#![crate_type]` and `#![crate_name]` attributes into deny by default. Copying the example from rust-lang#83744:

```Rust
#![crate_type = "lib"] // remains working
#![cfg_attr(foo, crate_type = "bin")] // will stop working
```

Over 8 months have passed since rust-lang#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 rust-lang#83744 also didn't show up anything.

cc rust-lang#91632 - tracking issue for the lint
  • Loading branch information
JohnTitor authored Aug 27, 2022
2 parents 539e408 + 152c851 commit 134cc2d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3094,7 +3094,7 @@ declare_lint! {
///
/// ### Example
///
/// ```rust
/// ```rust,compile_fail
/// #![cfg_attr(debug_assertions, crate_type = "lib")]
/// ```
///
Expand All @@ -3114,7 +3114,7 @@ declare_lint! {
/// rustc instead of `#![cfg_attr(..., crate_type = "...")]` and
/// `--crate-name` instead of `#![cfg_attr(..., crate_name = "...")]`.
pub DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME,
Warn,
Deny,
"detects usage of `#![cfg_attr(..., crate_type/crate_name = \"...\")]`",
@future_incompatible = FutureIncompatibleInfo {
reference: "issue #91632 <https://github.com/rust-lang/rust/issues/91632>",
Expand Down
5 changes: 2 additions & 3 deletions src/test/codegen/external-no-mangle-statics.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// revisions: lib staticlib
// ignore-emscripten default visibility is hidden
// compile-flags: -O
// [lib] compile-flags: --crate-type lib
// [staticlib] compile-flags: --crate-type staticlib
// `#[no_mangle]`d static variables always have external linkage, i.e., no `internal` in their
// definitions

#![cfg_attr(lib, crate_type = "lib")]
#![cfg_attr(staticlib, crate_type = "staticlib")]

// CHECK: @A = local_unnamed_addr constant
#[no_mangle]
static A: u8 = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// check-fail
// compile-flags:--cfg foo

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

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

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

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

0 comments on commit 134cc2d

Please sign in to comment.