-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Restrict use_self
on nested items
#3640
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
f99f785
to
ff191a8
Compare
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.
LGTM. Just another test would be nice, to make sure, to keep the (correct) old behavior with nested items.
@bors r+ Thanks! |
@bors r=flip1995 |
📌 Commit 466cd07 has been approved by |
Restrict `use_self` on nested items Fixes #3637 Fixes #3463 These changes make it so that nested items aren't visited any more by the `use_self` lint. I think visiting nested items should be possible (so that it uses a different `item_path` for the nested item), but I'm not sure whether it's viable and what the best approach would be. - Can `item_path` be changed to a new `Self` path before visiting the item, and then changing it back afterwards? - Alternatively, could a new visitor be created, re-using `check_trait_method_impl_decl`?
☀️ Test successful - status-appveyor, status-travis |
Fix `use_self` false positive on nested functions Related to #3640 The current `use_self` warns the following code. ```rust #![warn(clippy::use_self)] struct Foo {} impl Foo { fn bar() { fn baz() -> Foo { //^ warning: unnecessary structure name repetition Foo {} //^ warning: unnecessary structure name repetition } } } ```
Fixes #3637
Fixes #3463
These changes make it so that nested items aren't visited any more by the
use_self
lint.I think visiting nested items should be possible (so that it uses a different
item_path
for the nested item), but I'm not sure whether it's viable and what the best approach would be.item_path
be changed to a newSelf
path before visiting the item, and then changing it back afterwards?check_trait_method_impl_decl
?