Skip to content

Commit 6955a8a

Browse files
Add ui test for multiple_bound_locations lint
1 parent d654acd commit 6955a8a

File tree

2 files changed

+118
-0
lines changed

2 files changed

+118
-0
lines changed

tests/ui/multiple_bound_locations.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#![warn(clippy::multiple_bound_locations)]
2+
3+
fn ty<F: std::fmt::Debug>(a: F)
4+
//~^ ERROR: bound is defined in more than one place
5+
where
6+
F: Sized,
7+
{
8+
}
9+
10+
fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str)
11+
//~^ ERROR: bound is defined in more than one place
12+
where
13+
'b: 'c,
14+
{
15+
}
16+
17+
fn ty_pred<F: Sized>()
18+
//~^ ERROR: bound is defined in more than one place
19+
where
20+
for<'a> F: Send + 'a,
21+
{
22+
}
23+
24+
struct B;
25+
26+
impl B {
27+
fn ty<F: std::fmt::Debug>(a: F)
28+
//~^ ERROR: bound is defined in more than one place
29+
where
30+
F: Sized,
31+
{
32+
}
33+
34+
fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str)
35+
//~^ ERROR: bound is defined in more than one place
36+
where
37+
'b: 'c,
38+
{
39+
}
40+
41+
fn ty_pred<F: Sized>()
42+
//~^ ERROR: bound is defined in more than one place
43+
where
44+
for<'a> F: Send + 'a,
45+
{
46+
}
47+
}
48+
49+
struct C<F>(F);
50+
51+
impl<F> C<F> {
52+
fn foo(_f: F) -> Self
53+
where F: std::fmt::Display
54+
{
55+
todo!()
56+
}
57+
}
58+
59+
fn main() {}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
error: bound is defined in more than one place
2+
--> tests/ui/multiple_bound_locations.rs:3:7
3+
|
4+
LL | fn ty<F: std::fmt::Debug>(a: F)
5+
| ^
6+
...
7+
LL | F: Sized,
8+
| ^
9+
|
10+
= note: `-D clippy::multiple-bound-locations` implied by `-D warnings`
11+
= help: to override `-D warnings` add `#[allow(clippy::multiple_bound_locations)]`
12+
13+
error: bound is defined in more than one place
14+
--> tests/ui/multiple_bound_locations.rs:10:17
15+
|
16+
LL | fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str)
17+
| ^^
18+
...
19+
LL | 'b: 'c,
20+
| ^^
21+
22+
error: bound is defined in more than one place
23+
--> tests/ui/multiple_bound_locations.rs:17:12
24+
|
25+
LL | fn ty_pred<F: Sized>()
26+
| ^
27+
...
28+
LL | for<'a> F: Send + 'a,
29+
| ^
30+
31+
error: bound is defined in more than one place
32+
--> tests/ui/multiple_bound_locations.rs:27:11
33+
|
34+
LL | fn ty<F: std::fmt::Debug>(a: F)
35+
| ^
36+
...
37+
LL | F: Sized,
38+
| ^
39+
40+
error: bound is defined in more than one place
41+
--> tests/ui/multiple_bound_locations.rs:34:21
42+
|
43+
LL | fn lifetime<'a, 'b: 'a, 'c>(a: &'b str, b: &'a str, c: &'c str)
44+
| ^^
45+
...
46+
LL | 'b: 'c,
47+
| ^^
48+
49+
error: bound is defined in more than one place
50+
--> tests/ui/multiple_bound_locations.rs:41:16
51+
|
52+
LL | fn ty_pred<F: Sized>()
53+
| ^
54+
...
55+
LL | for<'a> F: Send + 'a,
56+
| ^
57+
58+
error: aborting due to 6 previous errors
59+

0 commit comments

Comments
 (0)