feat: New lints deprecated_attributes_without_(since|note) - #17609
feat: New lints deprecated_attributes_without_(since|note)#17609hashcatHitman wants to merge 2 commits into
deprecated_attributes_without_(since|note)#17609Conversation
|
Thanks for the pull request. A reviewer will take a look after it receives 2 community reviews. In the meantime, we would highly appreciate if you could try to review any of PRs waiting on community reviews. |
|
Lintcheck changes for 41f2591
This comment will be updated if you push new changes |
a3b3a6a to
c1db3d8
Compare
c1db3d8 to
61a033d
Compare
This comment has been minimized.
This comment has been minimized.
61a033d to
23773e5
Compare
There was a problem hiding this comment.
Community review: Lgtm
Two things that I am iffy about:
- not sure if the "to the end" in the diagnostic can not just be removed. To me it just makes the disgnostid longer, but 🤷♂️
- I am surprised to see the
no-rustfix. I though hasplaceholders cannot auto apply, so--fixdoes not apply this.. you sure this is nessary?
Signed-off-by: hashcatHitman <155700084+hashcatHitman@users.noreply.github.com>
Signed-off-by: hashcatHitman <155700084+hashcatHitman@users.noreply.github.com>
23773e5 to
41f2591
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Yeah, I think that's a fair point. I've dropped that part, it's more concise now.
I was surprised to need it too, but yes, it certainly seems necessary. Without it, running Anyway, thanks for your feedback and help! I think these lints are in a much better condition now. |
View all comments
Adds two new lints:
deprecated_attributes_without_since: Requires filling out thesincefield when using thedeprecatedattribute. This ispedantic, making itallowby default.deprecated_attributes_without_note: Requires filling out thenotefield when using thedeprecatedattribute. This isrestriction, making itallowby default.Why `pedantic` and `restriction`?
When
allow_attributes_without_reasonwas originally added, it was put into therestrictioncategory due to the impact it would have on existing projects. (See: #8504).So taking that into consideration:
deprecated_attributes_without_sinceispedanticbecause it is the easier of the two to satisfy (despite appearing to be the more prevalent issue in the wild at the moment). When deprecating an item, just include the version of your crate you are deprecating it in, or if you don't know what version that will be yet, "TBD" is also accepted by thesincefield. When trying to fix this lint retroactively, any project that still has a git history should be able to find the correct value for this field fairly easily usinggit tag --contains, as was done in chore: add missingsinceversions to#[deprecated]attributes apache/datafusion#24544.deprecated_attributes_without_noteisrestrictionbecause it requires more involvement when fixing. Thenotefield can be used for any information, but it is usually used to inform crate users why an item was deprecated and what they should use instead. Knowing "why" in the moment isn't too difficult, but finding an alternative may be. When trying to fix this lint retroactively, it can be extremely difficult, if not impossible, to determine why a given item was deprecated. Thedeprecatedattribute has always had the ability to document the reason; if a project has been declining to do so, it's entirely possible they haven't been doing a very good job of documenting the reason anywhere at all. Who knows whyfoo()was deprecated 3 years ago? Not me. You can't really fill this field out "incorrectly" since it can be used to store any arbitrary message, but I think we'd generally prefer that people explicitly opt-in to this lint and choose to actually include useful information. The other lint is technically opt-in too, but enablingpedanticas a group is not nearly as uncommon as enablingrestrictionas a group, which we very emphatically tell users not to do. The other lint is also stricter about it's value, which lends itself well to being easier to deal with correctly. There is even an existingcorrectnesslint (clippy::deprecated_semver) which checks that the value in thesincefield is either "TBD" or a valid semantic version.Personally, I think I'd rather both be
pedantic, since I don't thinkdeprecatedis even used that much to begin with (certainly not as much asallowwas). But I suspect the categories chosen here will ultimately be preferred. If I'm wrong, I expect it to come up in the non-community review and/or final comment period.I think the naming conventions might technically prefer names like:
deprecated_attributes_without_since_fieldsdeprecated_attributes_without_notesordeprecated_attributes_without_note_fieldsBut I went against my understanding of the naming conventions because of the very similarly named
allow_attributes_without_reason. If this seems wrong, just let me know which names are preferred.Fixes #17595
changelog: [
deprecated_attributes_without_since]: Newpedanticlint enforcing use of thesincefield ondeprecatedattributeschangelog: [
deprecated_attributes_without_note]: Newrestrictionlint enforcing use of thenotefield ondeprecatedattributes