-
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
New lint: [self_named_constructor
]
#7403
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Manishearth (or someone else) soon. Please see the contribution instructions for more information. |
Lint name idea: |
That's a better name, I will update the diff. |
☔ The latest upstream changes (presumably #7400) made this pull request unmergeable. Please resolve the merge conflicts. |
impl_item.span, | ||
&format!("constructor `{}` has the same name as the type", impl_item.ident.name), | ||
|diag| { | ||
diag.span_help(impl_item.span, &format!("consider renaming `{}()` to `new()`", impl_item.ident.name)); |
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 message will be bogus if the new
method is already present in the implementation.
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.
I got rid of it for now, since it felt like the action needed to resolve the lint was pretty self explanatory. Let me know if it is better to leave a message, and to check for the existence of new
first.
2481835
to
06e94a2
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 apart from a couple of nits. Great job 👍
@Manishearth, what will you say? |
☔ The latest upstream changes (presumably #7243) made this pull request unmergeable. Please resolve the merge conflicts. |
7cc863b
to
357a8f0
Compare
redundant_method_names
]self_named_constructor
]
@bors r+ sorry about the delay! |
📌 Commit 357a8f0 has been approved by |
New lint: [`self_named_constructor`] Adds the `self_named_constructor` lint for detecting when an implemented method has the same name as the type it is implemented for. changelog: [`self_named_constructor`] closes: #7142
💔 Test failed - checks-action_test |
No worries! Just ran |
@bors r+ |
📌 Commit e9e10d2 has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Adds the
self_named_constructor
lint for detecting when an implemented method has the same name as the type it is implemented for.changelog: [
self_named_constructor
]closes: #7142