Skip to content

Using deprecated items within the crate that deprecated them issues warnings #47219

Open
@CasualX

Description

@CasualX

When deprecating an item, you typically still want the helper methods supporting it to work without the compiler whining that the item is deprecated.

I tried this code: playground

#[deprecated]
pub struct Foo;

impl Foo {
    fn foo() -> Foo { Foo }
}

I expected to see this happen: The code compiles without deprecation warnings.

Instead, this happened: Litterally every usage of Foo gets a use of deprecated item Foo warning.

The fact that I'm deprecating an item doesn't mean the crate itself should now be spammed with deprecation warnings. Working around it by either a global #![allow(deprecated)] will swallow legitimate deprecation warnings or require all uses to be tagged with it.

Meta

Playground, all channels (how do you get the version info from the playground?)

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-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