Skip to content

Warn that #[deprecated] does not work on re-exports #142436

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

Open
kpreid opened this issue Jun 12, 2025 · 1 comment
Open

Warn that #[deprecated] does not work on re-exports #142436

kpreid opened this issue Jun 12, 2025 · 1 comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-diagnostics Area: Messages for errors, warnings, and lints L-deprecated Lint: deprecated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@kpreid
Copy link
Contributor

kpreid commented Jun 12, 2025

Code

#![allow(unused)]

mod library {
    pub struct Foo;
    
    #[deprecated] // this doesn't work
    pub use Foo as DeprFooUse;
    
    #[deprecated] // this works
    pub type DeprFooAlias = Foo;
}

mod user {
    #[expect(deprecated)]
    use super::library::DeprFooUse as _;

    #[expect(deprecated)]
    use super::library::DeprFooAlias as _;
}

Current output

warning: this lint expectation is unfulfilled
  --> src/lib.rs:14:14
   |
14 |     #[expect(deprecated)]
   |              ^^^^^^^^^^
   |
   = note: `#[warn(unfulfilled_lint_expectations)]` on by default

Desired output

warning: #[deprecated] currently has no effect on `use` items
  --> src/lib.rs:6
  ...

warning: this lint expectation is unfulfilled
  --> src/lib.rs:14:14
  ...

Rationale and extra context

Per #30827, deprecating a re-export is a desired feature. But, that will require substantial work. We can fix a footgun now by warning that #[deprecated] has no effect when applied to use.

Rust Version

1.87.0

@rustbot label +L-deprecated

@kpreid kpreid added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 12, 2025
@rustbot rustbot added the L-deprecated Lint: deprecated label Jun 12, 2025
@fmease fmease added the A-attributes Area: Attributes (`#[…]`, `#![…]`) label Jun 12, 2025
@cyrgani
Copy link
Contributor

cyrgani commented Jun 12, 2025

note: this was previously attempted in PR #132038

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-diagnostics Area: Messages for errors, warnings, and lints L-deprecated Lint: deprecated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants