-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add clippy::result_as_ref_deref
lint
#13474
base: master
Are you sure you want to change the base?
Add clippy::result_as_ref_deref
lint
#13474
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Jarcho (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
781b3cd
to
e1a8ff9
Compare
Uh. I think I messed something up. I've pulled master branch to be up to date, rebased my working branch on top of it, and now tests don't pass and a whole bunch of code needs to be reformatted. However when I look at the diff between my branch and upstream/master I only see my changes. Help would be appreciated. 😃 EDIT. After some more rebasing and tweaking all seams to work now. I don't know what I did previously wrong, but now CI passes. |
1b386e5
to
0349ca7
Compare
0349ca7
to
afad426
Compare
I was browsing the standard library, and have found one more "similar" pattern. One problem though is that this method is unstable. I've read its tracking issue and if I understand correctly1, its FCP has just finished, so it should be stable pretty soon. If such lint were to be added, would it have to wait until Do you think it would be good to add such a lint? Sorry for writing about it in this PR. I thought it would be better to ask about it here, because it loosely relates to lints that I am working on here. If you believe that this discussion should be moved to separate issue, please tell me so. One way that this would relate to lints that I worked on in this PR is naming. There is already open question in this PR about naming of lints that check for I thing that this is pretty obvious that it should be a separate lint, and not joined with Footnotes
|
I haven't heard back from my assigned reviewer for last 2 weeks, so I took liberty to re-roll reviewer using a fair dice. I hope you won't mind it. 😃 r? @Alexendoo |
@@ -0,0 +1,58 @@ | |||
#![allow(unused, clippy::redundant_clone, clippy::useless_vec)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could you add error markers (//~^
) to lines which are supposed to shown an error? This will then be checked automatically for non-regressions, instead of having to visually inspect changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. Sorry for the delay. Can I generate those comments with uibless
, or do I have to write them manually? I haven't use them, because I have just copied tests/ui/option_as_ref_deref.rs
file and tweaked it, and it already had no such comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those would have to be added manually. The tests haven't all been updated to use them, but they are preferred for anything new. You can add //~ lint_name
on the end of any line that should lint. e.g.
let _ = res.clone().as_ref().map(Deref::deref).map(str::len) //~ result_as_ref_deref
Using //~^ line_name
will let you add it to the following line, but that should only be used for longer lines.
Sorry, this one managed to slip past me. I've been not very active for the past month or so (various issues happening at the same time). A lint can be renamed using Code looks good other than @samueltardieu's comment about error annotations. The version attribute will be fixed when we make the release change log, so it's not the end of the world if it's wrong. |
It's been a week and looks like a rename to |
This comment has been minimized.
This comment has been minimized.
cc6ad43
to
c7da13b
Compare
c7da13b
to
1985acd
Compare
☔ The latest upstream changes (presumably b829d53) made this pull request unmergeable. Please resolve the merge conflicts. |
changelog: added new lint
result_as_ref_deref
closes #13342
I've added new lint
result_as_ref_deref
, which mirrors already existing lintoption_as_ref_deref
and reused its existingcheck
function.Open question is should this be another lint, or should two of them be merged together? I've asked about it in the original issue (proposing
manual_as_ref_deref
name), and @Jarcho suggested the same thing (and proposedmanual_fallible_as_deref
name).I'm not sure what is clippy's policy regarding renaming lint names, so I opted into just adding new lint and waiting for the review.