diff --git a/tests/ui/multiple_bound_locations.rs b/tests/ui/multiple_bound_locations.rs new file mode 100644 index 00000000000..9f03db2c801 --- /dev/null +++ b/tests/ui/multiple_bound_locations.rs @@ -0,0 +1,59 @@ +#![warn(clippy::multiple_bound_locations)] + +fn ty(a: F) +//~^ ERROR: bound is defined in more than one place +where + F: Sized, +{ +} + +fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str) +//~^ ERROR: bound is defined in more than one place +where + 'b: 'c, +{ +} + +fn ty_pred() +//~^ ERROR: bound is defined in more than one place +where + for<'a> F: Send + 'a, +{ +} + +struct B; + +impl B { + fn ty(a: F) + //~^ ERROR: bound is defined in more than one place + where + F: Sized, + { + } + + fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str) + //~^ ERROR: bound is defined in more than one place + where + 'b: 'c, + { + } + + fn ty_pred() + //~^ ERROR: bound is defined in more than one place + where + for<'a> F: Send + 'a, + { + } +} + +struct C(F); + +impl C { + fn foo(_f: F) -> Self + where F: std::fmt::Display + { + todo!() + } +} + +fn main() {} diff --git a/tests/ui/multiple_bound_locations.stderr b/tests/ui/multiple_bound_locations.stderr new file mode 100644 index 00000000000..22dd2e0a552 --- /dev/null +++ b/tests/ui/multiple_bound_locations.stderr @@ -0,0 +1,59 @@ +error: bound is defined in more than one place + --> tests/ui/multiple_bound_locations.rs:3:7 + | +LL | fn ty(a: F) + | ^ +... +LL | F: Sized, + | ^ + | + = note: `-D clippy::multiple-bound-locations` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::multiple_bound_locations)]` + +error: bound is defined in more than one place + --> tests/ui/multiple_bound_locations.rs:10:17 + | +LL | fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str) + | ^^ +... +LL | 'b: 'c, + | ^^ + +error: bound is defined in more than one place + --> tests/ui/multiple_bound_locations.rs:17:12 + | +LL | fn ty_pred() + | ^ +... +LL | for<'a> F: Send + 'a, + | ^ + +error: bound is defined in more than one place + --> tests/ui/multiple_bound_locations.rs:27:11 + | +LL | fn ty(a: F) + | ^ +... +LL | F: Sized, + | ^ + +error: bound is defined in more than one place + --> tests/ui/multiple_bound_locations.rs:34:21 + | +LL | fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str) + | ^^ +... +LL | 'b: 'c, + | ^^ + +error: bound is defined in more than one place + --> tests/ui/multiple_bound_locations.rs:41:16 + | +LL | fn ty_pred() + | ^ +... +LL | for<'a> F: Send + 'a, + | ^ + +error: aborting due to 6 previous errors +