Skip to content
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

Warn if function name default() is used without implementing the Default trait #8550

Closed
kamulos opened this issue Mar 16, 2022 · 3 comments · Fixed by #9546
Closed

Warn if function name default() is used without implementing the Default trait #8550

kamulos opened this issue Mar 16, 2022 · 3 comments · Fixed by #9546
Assignees

Comments

@kamulos
Copy link

kamulos commented Mar 16, 2022

Description

Just stumbled on this in a code review. Would it make sense to check the naming of a member function? If a default() function is used (especially as a constructor) I would expect, that the Default trait is implemented.

Not sure if this would be it's own lint or integrated in an existing one

Version

No response

Additional Labels

No response

@smoelius
Copy link
Contributor

Personally, I would generalize this to: any inherent method decalartion whose name matches a std trait method name.

There may be reasons why this is too general, but I can't think of any offhand.

@smoelius
Copy link
Contributor

Today, I noticed this:

// FIXME: default doesn't work

Apparently, should_implement_trait has been around for a while. This seems to be the PR that introduced it: #228

@kraktus
Copy link
Contributor

kraktus commented Sep 24, 2022

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants