WIP
This commit is contained in:
parent
478555d468
commit
1eff408ca4
@ -195,13 +195,14 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds {
|
||||
let already_seen = !seen_def_ids.insert(def_id);
|
||||
|
||||
if already_seen {
|
||||
span_lint_and_help(
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
TRAIT_DUPLICATION_IN_BOUNDS,
|
||||
bound.span,
|
||||
"this trait bound is already specified in trait declaration",
|
||||
None,
|
||||
"consider removing this trait bound",
|
||||
"".to_string(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
#![deny(clippy::trait_duplication_in_bounds)]
|
||||
#![allow(unused)]
|
||||
|
||||
use std::any::Any;
|
||||
|
||||
fn bad_foo<T: Clone + Copy, U: Clone + Copy>(arg0: T, argo1: U) {
|
||||
unimplemented!();
|
||||
}
|
||||
@ -109,4 +111,12 @@ fn qualified_path<T: std::clone::Clone + foo::Clone>(arg0: T) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn good_trait_object(arg0: &(dyn Any + Send)) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn bad_trait_object(arg0: &(dyn Any + Send)) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -2,6 +2,8 @@
|
||||
#![deny(clippy::trait_duplication_in_bounds)]
|
||||
#![allow(unused)]
|
||||
|
||||
use std::any::Any;
|
||||
|
||||
fn bad_foo<T: Clone + Clone + Clone + Copy, U: Clone + Copy>(arg0: T, argo1: U) {
|
||||
unimplemented!();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: these bounds contain repeated elements
|
||||
--> $DIR/trait_duplication_in_bounds.rs:5:15
|
||||
--> $DIR/trait_duplication_in_bounds.rs:7:15
|
||||
|
|
||||
LL | fn bad_foo<T: Clone + Clone + Clone + Copy, U: Clone + Copy>(arg0: T, argo1: U) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy`
|
||||
@ -11,46 +11,53 @@ LL | #![deny(clippy::trait_duplication_in_bounds)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: these where clauses contain repeated elements
|
||||
--> $DIR/trait_duplication_in_bounds.rs:11:8
|
||||
--> $DIR/trait_duplication_in_bounds.rs:13:8
|
||||
|
|
||||
LL | T: Clone + Clone + Clone + Copy,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy`
|
||||
|
||||
error: these bounds contain repeated elements
|
||||
--> $DIR/trait_duplication_in_bounds.rs:39:26
|
||||
--> $DIR/trait_duplication_in_bounds.rs:41:26
|
||||
|
|
||||
LL | trait BadSelfTraitBound: Clone + Clone + Clone {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone`
|
||||
|
||||
error: these where clauses contain repeated elements
|
||||
--> $DIR/trait_duplication_in_bounds.rs:46:15
|
||||
--> $DIR/trait_duplication_in_bounds.rs:48:15
|
||||
|
|
||||
LL | Self: Clone + Clone + Clone;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone`
|
||||
|
||||
error: these bounds contain repeated elements
|
||||
--> $DIR/trait_duplication_in_bounds.rs:60:24
|
||||
--> $DIR/trait_duplication_in_bounds.rs:62:24
|
||||
|
|
||||
LL | trait BadTraitBound<T: Clone + Clone + Clone + Copy, U: Clone + Copy> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy`
|
||||
|
||||
error: these where clauses contain repeated elements
|
||||
--> $DIR/trait_duplication_in_bounds.rs:67:12
|
||||
--> $DIR/trait_duplication_in_bounds.rs:69:12
|
||||
|
|
||||
LL | T: Clone + Clone + Clone + Copy,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + Copy`
|
||||
|
||||
error: these bounds contain repeated elements
|
||||
--> $DIR/trait_duplication_in_bounds.rs:100:19
|
||||
--> $DIR/trait_duplication_in_bounds.rs:102:19
|
||||
|
|
||||
LL | fn bad_generic<T: GenericTrait<u64> + GenericTrait<u32> + GenericTrait<u64>>(arg0: T) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `GenericTrait<u64> + GenericTrait<u32>`
|
||||
|
||||
error: these bounds contain repeated elements
|
||||
--> $DIR/trait_duplication_in_bounds.rs:108:22
|
||||
--> $DIR/trait_duplication_in_bounds.rs:110:22
|
||||
|
|
||||
LL | fn qualified_path<T: std::clone::Clone + Clone + foo::Clone>(arg0: T) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::clone::Clone + foo::Clone`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error: this trait bound is already specified in trait declaration
|
||||
--> $DIR/trait_duplication_in_bounds.rs:118:46
|
||||
|
|
||||
LL | fn bad_trait_object(arg0: &(dyn Any + Send + Send)) {
|
||||
| ^^^^ help: consider removing this trait bound
|
||||
|
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user