-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lint duplicate methods of trait bounds
Fixes #5777
- Loading branch information
Showing
6 changed files
with
154 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|