Warn that #[deprecated] does not work on re-exports (original) (raw)

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

@rustbot label +L-deprecated