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

New lint: trait_not_impl #11570

Closed
PyroTechniac opened this issue Sep 26, 2023 · 0 comments · Fixed by #13322
Closed

New lint: trait_not_impl #11570

PyroTechniac opened this issue Sep 26, 2023 · 0 comments · Fixed by #13322
Labels
A-lint Area: New lints

Comments

@PyroTechniac
Copy link
Contributor

What it does

Lints for warnings where traits are only imported for their methods, not to be implemented on a type

Suggestion: rename traits to _.

Advantage

Remove potential name conflicts when importing multiple traits, such as io::Write and fmt::Write

Drawbacks

Would need to be named if multiple traits have the same named methods and one needs selected

Example

use std::fmt::{Display, Formatter, Result, Write};

struct Foo(char);

impl Display for Foo {
	fn fmt(&self, f: &mut Formatter<'_>) -> Result {
		f.write_char(self.0)
	}
}

Could be written as:

use std::fmt::{Display, Formatter, Result, Write as _};

struct Foo(char);

impl Display for Foo {
	fn fmt(&self, f: &mut Formatter<'_>) -> Result {
		f.write_char(self.0)
	}
}
@PyroTechniac PyroTechniac added the A-lint Area: New lints label Sep 26, 2023
@y21 y21 linked a pull request Sep 2, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant