Skip to content

Automatically derived trait implementations on #[deprecated] items emit warnings #110374

Open
@MrGunflame

Description

@MrGunflame

When using the #[automatically_derived] attribute on deprecated items, deprecation warnings are not omitted for that item. This does not affect macros from the stdlib.

The following code will not compile under these conditions:

#![deny(deprecated)]

#[deprecated]
struct DeprecatedItem;

trait MyTrait {}

// Imagine this block was derived.
#[automatically_derived]
impl MyTrait for DeprecatedItem {}

It would be possible to use #[allow(deprecated)] on the derived impl block to omit the warnings, but that affects the entire block instead of only DeprecatedItem. This will also not work if the #![forbid(deprecated)] lint is enabled.

I expected to see this happen: The code should compile despite and ignore the use of DeprecatedItem when within the [#automatically_derived] attribute.

Instead, this happened: The code does not compile.

Meta

rustc --version --verbose:

rustc 1.70.0-nightly (84dd17b56 2023-04-14)
binary: rustc
commit-hash: 84dd17b56a931a631a23dfd5ef2018fd3ef49108
commit-date: 2023-04-14
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 16.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.L-deprecatedLint: deprecatedT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions