-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lints
Description
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)
}
}
ronnodas and vidhanio
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints