Warn that `#[deprecated]` does not work on re-exports
Open
Nobody has claimed this yet.
A-attributes
A-diagnostics
L-deprecated
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Rust reproducer showing #[deprecated] on a re-export and #[expect(deprecated)] on its use. Trace the compiler handling for deprecated attributes on use items; done means the re-export emits the requested warning while the existing alias behavior and unfulfilled-expectation diagnostic remain clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100