Skip to content

Conversation

GrigorenkoPV
Copy link
Contributor

@GrigorenkoPV GrigorenkoPV commented Jun 19, 2025

Rebase of #132038

Original description:

As reported in #30827 and #84584, marking a re-export (pub use) with #[deprecated] does not produce a warning for consumers. In fact, there are instances of this in the core and std crates (see past issue #82080 where this caused some confusion).

This change modifies the stability annotation visitor to mark #[deprecated] annotations on use statements with AnnotationKind::DeprecationProhibited so that library developers are aware that the annotation is not warning their users as expected.

#[deprecated]
pub use a_module::ActiveType;
error: this `#[deprecated]` annotation has no effect
  --> $DIR/deprecated_use.rs:6:1
   |
LL | #[deprecated]
   | ^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute
   |
   = note: `#[deny(useless_deprecated)]` on by default

error: aborting due to 1 previous error

Closes #142436 (I think)

@rustbot
Copy link
Collaborator

rustbot commented Jun 19, 2025

r? @WaffleLapkin

rustbot has assigned @WaffleLapkin.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 19, 2025
@WaffleLapkin
Copy link
Member

I strongly believe that this should just work. You should be able to deprecate reexports. I've talked with @jdonszelmann and we came up with a "plan" on how to implement that.

I'm marking this as blocked. Either until this is properly supported and the lint is not needed, or until we decide that we can't support it and the list is needed.

@WaffleLapkin WaffleLapkin added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 25, 2025
@bors
Copy link
Collaborator

bors commented Jul 18, 2025

☔ The latest upstream changes (presumably #143845) made this pull request unmergeable. Please resolve the merge conflicts.

@epage
Copy link
Contributor

epage commented Aug 21, 2025

@WaffleLapkin if there is enough of a gap before a solution, would it make sense to go ahead and report that it has no effect until then so people know they are writing deprecated messages that will be ignored? The lint is literally describing the current behavior and it seems like it would be fine to later remove that lint when there is an effect.

@WaffleLapkin
Copy link
Member

@epage I'm not sure. I feel like adding a lint adds too much friction -- the warning will make people either remove the deprecation, or add an #[allow], both of which will need to be reverted eventually...

At the same time it will be some time before Jana and I can work on this and it will take some time to make a fix... So maybe a warning makes sense. 🤷🏻

@epage
Copy link
Contributor

epage commented Aug 22, 2025

In case this is relevant, the reason I thought it might be worthwhile is as a library author, I assume my deprecation messages show up and write my library and my changelog assuming that. As a recent example (but with #47237), I had someone complaining about unspecified breaking changes in a library of mine because I had thought my umbrella statement "deprecated items were removed" was sufficient when in reality, they existed only in the code and users never saw them. If I had known about #47237, I would have worked around it by writing wrapper functions where possible like I do for #30827 which I mostly know of because of the number of times it has bitten me.

@WaffleLapkin
Copy link
Member

I see your point. I agree, for users who don't know about this footgun (I assume most users don't), it would be nice to warn them. After I thought about it for a couple days, I think I'd be in favor of adding this warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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