Auto merge of #8252 - dswij:8229, r=xFrednet

cover trait for `trait_duplication_in_bounds`

closes #8229

changelog: [`trait_duplication_in_bounds`] covers trait functions with `Self` bounds
This commit is contained in:
bors 2022-01-10 10:31:59 +00:00
commit 88cfd70100
3 changed files with 139 additions and 3 deletions

View file

@ -28,4 +28,49 @@ where
unimplemented!();
}
trait T: Default {
fn f()
where
Self: Default;
}
trait U: Default {
fn f()
where
Self: Clone;
}
trait ZZ: Default {
fn g();
fn h();
fn f()
where
Self: Default + Clone;
}
trait BadTrait: Default + Clone {
fn f()
where
Self: Default + Clone;
fn g()
where
Self: Default;
fn h()
where
Self: Copy;
}
#[derive(Default, Clone)]
struct Life {}
impl T for Life {
// this should not warn
fn f() {}
}
impl U for Life {
// this should not warn
fn f() {}
}
fn main() {}

View file

@ -19,5 +19,45 @@ 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
error: this trait bound is already specified in trait declaration
--> $DIR/trait_duplication_in_bounds.rs:34:15
|
LL | Self: Default;
| ^^^^^^^
|
= help: consider removing this trait bound
error: this trait bound is already specified in trait declaration
--> $DIR/trait_duplication_in_bounds.rs:48:15
|
LL | Self: Default + Clone;
| ^^^^^^^
|
= help: consider removing this trait bound
error: this trait bound is already specified in trait declaration
--> $DIR/trait_duplication_in_bounds.rs:54:15
|
LL | Self: Default + Clone;
| ^^^^^^^
|
= help: consider removing this trait bound
error: this trait bound is already specified in trait declaration
--> $DIR/trait_duplication_in_bounds.rs:54:25
|
LL | Self: Default + Clone;
| ^^^^^
|
= help: consider removing this trait bound
error: this trait bound is already specified in trait declaration
--> $DIR/trait_duplication_in_bounds.rs:57:15
|
LL | Self: Default;
| ^^^^^^^
|
= help: consider removing this trait bound
error: aborting due to 7 previous errors