forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#9167 - aldhsu:fix-trait-duplication-false-pos…
…, r=flip1995 Fixes [`trait_duplication_in_bounds`] false positives Fixes rust-lang#9076 rust-lang#9151 rust-lang#8757. Partially fixes rust-lang#8771. changelog: [`trait_duplication_in_bounds`]: Reduce number of false positives.
- Loading branch information
Showing
7 changed files
with
481 additions
and
334 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// run-rustfix | ||
#![deny(clippy::trait_duplication_in_bounds)] | ||
#![allow(unused)] | ||
|
||
fn bad_foo<T: Clone + Copy, U: Clone + Copy>(arg0: T, argo1: U) { | ||
unimplemented!(); | ||
} | ||
|
||
fn bad_bar<T, U>(arg0: T, arg1: U) | ||
where | ||
T: Clone + Copy, | ||
U: Clone + Copy, | ||
{ | ||
unimplemented!(); | ||
} | ||
|
||
fn good_bar<T: Clone + Copy, U: Clone + Copy>(arg0: T, arg1: U) { | ||
unimplemented!(); | ||
} | ||
|
||
fn good_foo<T, U>(arg0: T, arg1: U) | ||
where | ||
T: Clone + Copy, | ||
U: Clone + Copy, | ||
{ | ||
unimplemented!(); | ||
} | ||
|
||
trait GoodSelfTraitBound: Clone + Copy { | ||
fn f(); | ||
} | ||
|
||
trait GoodSelfWhereClause { | ||
fn f() | ||
where | ||
Self: Clone + Copy; | ||
} | ||
|
||
trait BadSelfTraitBound: Clone { | ||
fn f(); | ||
} | ||
|
||
trait BadSelfWhereClause { | ||
fn f() | ||
where | ||
Self: Clone; | ||
} | ||
|
||
trait GoodTraitBound<T: Clone + Copy, U: Clone + Copy> { | ||
fn f(); | ||
} | ||
|
||
trait GoodWhereClause<T, U> { | ||
fn f() | ||
where | ||
T: Clone + Copy, | ||
U: Clone + Copy; | ||
} | ||
|
||
trait BadTraitBound<T: Clone + Copy, U: Clone + Copy> { | ||
fn f(); | ||
} | ||
|
||
trait BadWhereClause<T, U> { | ||
fn f() | ||
where | ||
T: Clone + Copy, | ||
U: Clone + Copy; | ||
} | ||
|
||
struct GoodStructBound<T: Clone + Copy, U: Clone + Copy> { | ||
t: T, | ||
u: U, | ||
} | ||
|
||
impl<T: Clone + Copy, U: Clone + Copy> GoodTraitBound<T, U> for GoodStructBound<T, U> { | ||
// this should not warn | ||
fn f() {} | ||
} | ||
|
||
struct GoodStructWhereClause; | ||
|
||
impl<T, U> GoodTraitBound<T, U> for GoodStructWhereClause | ||
where | ||
T: Clone + Copy, | ||
U: Clone + Copy, | ||
{ | ||
// this should not warn | ||
fn f() {} | ||
} | ||
|
||
fn no_error_separate_arg_bounds(program: impl AsRef<()>, dir: impl AsRef<()>, args: &[impl AsRef<()>]) {} | ||
|
||
trait GenericTrait<T> {} | ||
|
||
fn good_generic<T: GenericTrait<u64> + GenericTrait<u32>>(arg0: T) { | ||
unimplemented!(); | ||
} | ||
|
||
fn bad_generic<T: GenericTrait<u32> + GenericTrait<u64>>(arg0: T) { | ||
unimplemented!(); | ||
} | ||
|
||
mod foo { | ||
pub trait Clone {} | ||
} | ||
|
||
fn qualified_path<T: Clone + foo::Clone>(arg0: T) { | ||
unimplemented!(); | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.