Repository navigation
Add must_use_without_reason lint - #16592
Conversation
|
Lintcheck changes for f1289a9
This comment will be updated if you push new changes |
This comment has been minimized.
This comment has been minimized.
dd76a0b to
3a164cc
Compare
|
r? @dswij rustbot has assigned @dswij. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
3a164cc to
0aca2f3
Compare
This comment has been minimized.
This comment has been minimized.
20eeb87 to
7354069
Compare
|
@dswij Hello! Would you be able to review my PR, or should I choose another reviewer? |
|
r? @Jarcho |
| "add the attribute", | ||
| format!("#[must_use]\n{indent}"), | ||
| Applicability::MachineApplicable, | ||
| format!("#[must_use = \"/* reason */\"] \n{indent}"), |
There was a problem hiding this comment.
This shouldn't be suggesting to add a reason in general. You can check if the new lint is enabled using is_lint_allowed and only suggest when it's needed.
|
Reminder, once the PR becomes ready for a review, use |
|
@rustbot label lint-nominated |
|
This lint has been nominated for inclusion. |
This comment has been minimized.
This comment has been minimized.
|
Ping @skatromb. Do you plan to continue working on this? |
|
Hi, @Jarcho! I was bit stuck in another project, but will return to this PR in August, if this feels ok for you. |
681cced to
16290b8
Compare
|
@rustbot ready |
This comment has been minimized.
This comment has been minimized.
16290b8 to
f3a4a6e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
f3a4a6e to
78e11b1
Compare
This comment has been minimized.
This comment has been minimized.
|
@samueltardieu @Jarcho Rebased on main, fixed your comments, please take a look |
This comment has been minimized.
This comment has been minimized.
Warns on `#[must_use]` attributes with no accompanying message.
78e11b1 to
f1289a9
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. |
|
@samueltardieu @Jarcho Can you look at PR and approve if everything looks ok for you? |
|
Thank you! ❤️ |
View all comments
PR addresses proposal for adding a lint that warns about a
#[must_use]attribute that lacks a reason.Fixes #16466
Updated after review
Rebased onto current master and addressed all review feedback. The branch is now a single commit.
style→restriction— the lint is opinionated and restricts an otherwise valid attribute.must_use_without_note→must_use_without_reason, matchingallow_attributes_without_reason. Diagnostic wording uses "reason" throughout.#[must_use = "<REASON>"]instead of"/* reason */".must_use_candidatenow suggests a message based onis_lint_allowed. By default it is unchanged from master — plain#[must_use],MachineApplicable. Only whenmust_use_without_reasonis enabled at that node does it suggest#[must_use = "<REASON>"], so applying the fix does not immediately trip the other lint. Covered by a scoped module intests/ui/must_use_candidates.rs, which keeps the existing cases and their.fixedoutput untouched.in_external_macroguard moved after the item-kind check in all three entry points.changelog: [
must_use_without_reason]: add a lint that warns on#[must_use]attributes without a reason