Add lint rule for #[deprecated] on re-exports (rebase)#142731
Add lint rule for #[deprecated] on re-exports (rebase)#142731GrigorenkoPV wants to merge 3 commits intorust-lang:mainfrom
#[deprecated] on re-exports (rebase)#142731Conversation
|
rustbot has assigned @WaffleLapkin. Use |
|
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. |
|
☔ The latest upstream changes (presumably #143845) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@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. |
|
@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 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. 🤷🏻 |
|
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. |
|
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. |
This exact sequence of events just happenned to me, except it was thankfully caught in code review: https://github.com/PyO3/pyo3/pull/5642/changes#r2614462301. If there was a lint I would have noticed the issue and written a wrapper function instead. @WaffleLapkin maybe remove the blocked label, given the conclusion you came to in #142731 (comment), that way this can be rebased and merged. |
| #[deprecated( | ||
| since = "1.52.0", | ||
| note = "Name does not follow std convention, use LayoutError", | ||
| suggestion = "LayoutError" | ||
| )] |
| // Deprecation does not work on re-exports, so let's be clear about that. | ||
| // https://github.com/rust-lang/rust/issues/142436 | ||
| #[deprecated] //~ ERROR this `#[deprecated]` annotation has no effect | ||
| pub use inner::Y; |
There was a problem hiding this comment.
This really shouldn't be an error. We want to support this in the future, so this should at most be a lint saying "... this is a long-standing bug"
There was a problem hiding this comment.
Possibly also with suggestions on how to workaround this
| @@ -0,0 +1,12 @@ | |||
| //@ run-rustfix | |||
| #![deny(unused_imports)] | |||
| #![allow(useless_deprecated)] | |||
There was a problem hiding this comment.
| #![allow(useless_deprecated)] | |
| #![expect(useless_deprecated)] |
|
Reminder, once the PR becomes ready for a review, use |
Rebase of #132038
Original description:
Closes #142436 (I think)