Fix the order of trait_duplication_in_bounds

* Emit the lint in source order
* Make suggestions with multiple traits be in source order rather than alphabetical
This commit is contained in:
Jason Newcomb 2022-08-30 00:33:56 -04:00
parent 4df6032100
commit 19ef04ff5d
4 changed files with 33 additions and 17 deletions

View file

@ -97,7 +97,7 @@ fn good_generic<T: GenericTrait<u64> + GenericTrait<u32>>(arg0: T) {
unimplemented!();
}
fn bad_generic<T: GenericTrait<u32> + GenericTrait<u64>>(arg0: T) {
fn bad_generic<T: GenericTrait<u64> + GenericTrait<u32>>(arg0: T) {
unimplemented!();
}
@ -105,7 +105,7 @@ mod foo {
pub trait Clone {}
}
fn qualified_path<T: Clone + foo::Clone>(arg0: T) {
fn qualified_path<T: std::clone::Clone + foo::Clone>(arg0: T) {
unimplemented!();
}

View file

@ -44,13 +44,13 @@ error: these bounds contain repeated elements
--> $DIR/trait_duplication_in_bounds.rs:100:19
|
LL | fn bad_generic<T: GenericTrait<u64> + GenericTrait<u32> + GenericTrait<u64>>(arg0: T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `GenericTrait<u32> + GenericTrait<u64>`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `GenericTrait<u64> + GenericTrait<u32>`
error: these bounds contain repeated elements
--> $DIR/trait_duplication_in_bounds.rs:108:22
|
LL | fn qualified_path<T: std::clone::Clone + Clone + foo::Clone>(arg0: T) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Clone + foo::Clone`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::clone::Clone + foo::Clone`
error: aborting due to 8 previous errors

View file

@ -1,8 +1,8 @@
error: this trait bound is already specified in the where clause
--> $DIR/trait_duplication_in_bounds_unfixable.rs:6:23
--> $DIR/trait_duplication_in_bounds_unfixable.rs:6: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_unfixable.rs:1:9
@ -12,10 +12,10 @@ 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_unfixable.rs:6:15
--> $DIR/trait_duplication_in_bounds_unfixable.rs:6:23
|
LL | fn bad_foo<T: Clone + Default, Z: Copy>(arg0: T, arg1: Z)
| ^^^^^
| ^^^^^^^
|
= help: consider removing this trait bound