-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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. |
e1a8ff9
to
1b386e5
Compare
1b386e5
to
0349ca7
Compare
let target = 'target: { | ||
let target_ty = cx.typeck_results().expr_ty(as_ref_recv); | ||
if is_type_diagnostic_item(cx, target_ty, sym::Option) { | ||
break 'target Target::Option; | ||
} | ||
if is_type_diagnostic_item(cx, target_ty, sym::Result) { | ||
break 'target Target::Result; | ||
} | ||
return; | ||
}; | ||
|
||
if target == Target::Option && !msrv.meets(msrvs::OPTION_AS_DEREF) { | ||
return; | ||
} | ||
if target == Target::Result && !msrv.meets(msrvs::RESULT_AS_DEREF) { | ||
return; | ||
} |
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.
Using get_type_diagnostic_name()
would let you simplify this part:
let target_ty = cx.typeck_results().expr_ty(as_ref_recv);
let target = match get_type_diagnostic_name(cx, target_ty) {
Some(sym::Option) if msrv.meets(msrvs::OPTION_AS_DEREF) => Target::Option,
Some(sym::Result) if msrv.meets(msrvs::RESULT_AS_DEREF) =>Target::Result,
_ => return,
};
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.