-
Notifications
You must be signed in to change notification settings - Fork 1.6k
lint when calling the blanket Into
impl from a From
impl
#12459
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
Conversation
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.
This should have some negative tests. Otherwise Looks good.
added a few more tests I could think of in the last commit, if you have some more concrete ones I can add them. Also removed an unnecessary |
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.
@bors delegate
All looks good. r=me after squashing.
1827791
to
65defdb
Compare
squashed |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Closes #11150
I'm also thinking that we can probably generalize this lint to #11032 at some point (instead of hardcoding a bunch of impls), like how rustc's
unconditional_recursion
works, at least up to one indirect call, but this still seems useful for now :)I've also noticed that we use
fn_def_id
in a bunch of lints and then try to get the node args of the call in a separate step, so I made a helper function that does both in one. I intend to refactor a bunch of uses offn_def_id
to use this laterI can add more test cases, but this is already using much of the same logic that exists for the other impls that this lint looks for (e.g. making sure that there are no conditional returns).
changelog: [
unconditional_recursion
]: emit a warning inside ofFrom::from
when unconditionally calling the blanket.into()
impl