Rollup merge of #5852 - wiomoc:feature/lint-duplicate-trait, r=Manishearth
Add lint for duplicate methods of trait bounds rel: #5777 changelog: Add [`trait_duplication_in_bounds`] lint
This commit is contained in:
commit
84455b211f
6 changed files with 156 additions and 2 deletions
31
tests/ui/trait_duplication_in_bounds.rs
Normal file
31
tests/ui/trait_duplication_in_bounds.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#![deny(clippy::trait_duplication_in_bounds)]
|
||||
|
||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
|
||||
|
||||
fn bad_foo<T: Clone + Default, Z: Copy>(arg0: T, arg1: Z)
|
||||
where
|
||||
T: Clone,
|
||||
T: Default,
|
||||
{
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn good_bar<T: Clone + Default>(arg: T) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn good_foo<T>(arg: T)
|
||||
where
|
||||
T: Clone + Default,
|
||||
{
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn good_foobar<T: Default>(arg: T)
|
||||
where
|
||||
T: Clone,
|
||||
{
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
23
tests/ui/trait_duplication_in_bounds.stderr
Normal file
23
tests/ui/trait_duplication_in_bounds.stderr
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
error: this trait bound is already specified in the where clause
|
||||
--> $DIR/trait_duplication_in_bounds.rs:5:15
|
||||
|
|
||||
LL | fn bad_foo<T: Clone + Default, Z: Copy>(arg0: T, arg1: Z)
|
||||
| ^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/trait_duplication_in_bounds.rs:1:9
|
||||
|
|
||||
LL | #![deny(clippy::trait_duplication_in_bounds)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= help: consider removing this trait bound
|
||||
|
||||
error: this trait bound is already specified in the where clause
|
||||
--> $DIR/trait_duplication_in_bounds.rs:5:23
|
||||
|
|
||||
LL | fn bad_foo<T: Clone + Default, Z: Copy>(arg0: T, arg1: Z)
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: consider removing this trait bound
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue