Skip to content

Commit e5f88c9

Browse files
committed
Add tests
1 parent 2b603f9 commit e5f88c9

File tree

5 files changed

+275
-0
lines changed

5 files changed

+275
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
error[E0277]: the trait bound `T: Foo<()>` is not satisfied
2+
--> $DIR/issue-116749.rs:21:5
3+
|
4+
LL | / fn send<T>()
5+
LL | |
6+
LL | |
7+
LL | |
8+
... |
9+
LL | |
10+
LL | | T::FooAssociatedTy: Send,
11+
| |_________________________________^ the trait `Foo<()>` is not implemented for `T`
12+
|
13+
help: consider further restricting this bound
14+
|
15+
LL | T: Foo<Self::BarAssociatedTy> + Foo<()>,
16+
| +++++++++
17+
18+
error[E0277]: the trait bound `T: Foo<()>` is not satisfied
19+
--> $DIR/issue-116749.rs:21:8
20+
|
21+
LL | fn send<T>()
22+
| ^^^^ the trait `Foo<()>` is not implemented for `T`
23+
|
24+
help: consider further restricting this bound
25+
|
26+
LL | T: Foo<Self::BarAssociatedTy> + Foo<()>,
27+
| +++++++++
28+
29+
error[E0277]: the trait bound `T: Foo<()>` is not satisfied
30+
--> $DIR/issue-116749.rs:21:5
31+
|
32+
LL | / fn send<T>()
33+
LL | |
34+
LL | |
35+
LL | |
36+
... |
37+
LL | |
38+
LL | | T::FooAssociatedTy: Send,
39+
| |_________________________________^ the trait `Foo<()>` is not implemented for `T`
40+
|
41+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
42+
help: consider further restricting this bound
43+
|
44+
LL | T: Foo<Self::BarAssociatedTy> + Foo<()>,
45+
| +++++++++
46+
47+
error[E0276]: impl has stricter requirements than trait
48+
--> $DIR/issue-116749.rs:26:12
49+
|
50+
LL | / fn send<T>()
51+
LL | | where
52+
LL | | T: Foo<Self::BarAssociatedTy>,
53+
LL | | T::FooAssociatedTy: Send;
54+
| |_________________________________- definition of `send` from trait
55+
...
56+
LL | T: Foo<Self::BarAssociatedTy>,
57+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: Foo<()>`
58+
59+
error[E0277]: the trait bound `T: Foo<()>` is not satisfied
60+
--> $DIR/issue-116749.rs:36:5
61+
|
62+
LL | / fn send<T>()
63+
LL | |
64+
LL | | where
65+
LL | | T: Foo<()>,
66+
LL | |
67+
LL | | T::FooAssociatedTy: Send,
68+
| |_________________________________^ the trait `Foo<()>` is not implemented for `T`
69+
|
70+
help: consider further restricting this bound
71+
|
72+
LL | T: Foo<()> + Foo<()>,
73+
| +++++++++
74+
75+
error[E0276]: impl has stricter requirements than trait
76+
--> $DIR/issue-116749.rs:39:12
77+
|
78+
LL | / fn send<T>()
79+
LL | | where
80+
LL | | T: Foo<Self::BarAssociatedTy>,
81+
LL | | T::FooAssociatedTy: Send;
82+
| |_________________________________- definition of `send` from trait
83+
...
84+
LL | T: Foo<()>,
85+
| ^^^^^^^ impl has extra requirement `T: Foo<()>`
86+
87+
error: aborting due to 6 previous errors
88+
89+
Some errors have detailed explanations: E0276, E0277.
90+
For more information about an error, try `rustc --explain E0276`.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// revisions: current next
2+
//[next] check-pass
3+
//[next] compile-flags: -Ztrait-solver=next
4+
5+
pub trait Foo<TY> {
6+
type FooAssociatedTy;
7+
}
8+
9+
pub trait Bar {
10+
type BarAssociatedTy;
11+
12+
fn send<T>()
13+
where
14+
T: Foo<Self::BarAssociatedTy>,
15+
T::FooAssociatedTy: Send;
16+
}
17+
18+
impl Bar for () {
19+
type BarAssociatedTy = ();
20+
21+
fn send<T>()
22+
//[current]~^ ERROR the trait bound `T: Foo<()>` is not
23+
//[current]~| ERROR the trait bound `T: Foo<()>` is not
24+
//[current]~| ERROR the trait bound `T: Foo<()>` is not
25+
where
26+
T: Foo<Self::BarAssociatedTy>,
27+
//[current]~^ ERROR impl has stricter requirements than tra
28+
T::FooAssociatedTy: Send,
29+
{
30+
}
31+
}
32+
33+
impl Bar for i32 {
34+
type BarAssociatedTy = ();
35+
36+
fn send<T>()
37+
//[current]~^ ERROR the trait bound `T: Foo<()>` is not
38+
where
39+
T: Foo<()>,
40+
//[current]~^ ERROR impl has stricter requirements than tra
41+
T::FooAssociatedTy: Send,
42+
{
43+
}
44+
}
45+
46+
fn main() {
47+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
error[E0277]: expected a `FnMut(&'any i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>`
2+
--> $DIR/issue-116864.rs:25:1
3+
|
4+
LL | / pub async fn does_not_work<BAZ>(_: BAZ, mut cb: impl for<'any> FnMutFut<&'any BAZ::Param, ()>)
5+
LL | |
6+
LL | | where
7+
LL | | BAZ: Baz<Param = i32>,
8+
| |__________________________^ expected an `FnMut(&'any i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>`
9+
|
10+
= note: expected a closure with arguments `(&<BAZ as Baz>::Param,)`
11+
found a closure with arguments `(&'any i32,)`
12+
note: required for `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` to implement `for<'any> FnMutFut<&'any i32, ()>`
13+
--> $DIR/issue-116864.rs:17:20
14+
|
15+
LL | impl<P, F, FUT, R> FnMutFut<P, R> for F
16+
| ^^^^^^^^^^^^^^ ^
17+
LL | where
18+
LL | F: FnMut(P) -> FUT,
19+
| --------------- unsatisfied trait bound introduced here
20+
21+
error[E0277]: expected a `FnMut(&i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>`
22+
--> $DIR/issue-116864.rs:31:5
23+
|
24+
LL | cb(&1i32).await;
25+
| ^^^^^^^^^ expected an `FnMut(&i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>`
26+
|
27+
= note: expected a closure with arguments `(&<BAZ as Baz>::Param,)`
28+
found a closure with arguments `(&i32,)`
29+
note: required for `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` to implement `FnMutFut<&i32, ()>`
30+
--> $DIR/issue-116864.rs:17:20
31+
|
32+
LL | impl<P, F, FUT, R> FnMutFut<P, R> for F
33+
| ^^^^^^^^^^^^^^ ^
34+
LL | where
35+
LL | F: FnMut(P) -> FUT,
36+
| --------------- unsatisfied trait bound introduced here
37+
38+
error[E0277]: expected a `FnMut(&'any i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>`
39+
--> $DIR/issue-116864.rs:29:1
40+
|
41+
LL | / {
42+
LL | |
43+
LL | | cb(&1i32).await;
44+
LL | |
45+
LL | |
46+
LL | |
47+
LL | | }
48+
| |_^ expected an `FnMut(&'any i32)` closure, found `impl for<'any> FnMutFut<&'any BAZ::Param, ()>`
49+
|
50+
= note: expected a closure with arguments `(&<BAZ as Baz>::Param,)`
51+
found a closure with arguments `(&'any i32,)`
52+
note: required for `impl for<'any> FnMutFut<&'any BAZ::Param, ()>` to implement `for<'any> FnMutFut<&'any i32, ()>`
53+
--> $DIR/issue-116864.rs:17:20
54+
|
55+
LL | impl<P, F, FUT, R> FnMutFut<P, R> for F
56+
| ^^^^^^^^^^^^^^ ^
57+
LL | where
58+
LL | F: FnMut(P) -> FUT,
59+
| --------------- unsatisfied trait bound introduced here
60+
61+
error[E0308]: mismatched types
62+
--> $DIR/issue-116864.rs:31:8
63+
|
64+
LL | cb(&1i32).await;
65+
| -- ^^^^^ expected `&<BAZ as Baz>::Param`, found `&i32`
66+
| |
67+
| arguments to this function are incorrect
68+
|
69+
= note: expected reference `&<BAZ as Baz>::Param`
70+
found reference `&i32`
71+
= help: consider constraining the associated type `<BAZ as Baz>::Param` to `i32`
72+
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
73+
note: type parameter defined here
74+
--> $DIR/issue-116864.rs:25:49
75+
|
76+
LL | pub async fn does_not_work<BAZ>(_: BAZ, mut cb: impl for<'any> FnMutFut<&'any BAZ::Param, ()>)
77+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
78+
help: call `Into::into` on this expression to convert `&i32` into `&<BAZ as Baz>::Param`
79+
|
80+
LL | cb((&1i32).into()).await;
81+
| + ++++++++
82+
83+
error: aborting due to 4 previous errors
84+
85+
Some errors have detailed explanations: E0277, E0308.
86+
For more information about an error, try `rustc --explain E0277`.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/issue-116864.rs:31:5
3+
|
4+
LL | cb(&1i32).await;
5+
| ^^^^^^^^^^^^^^^ cannot infer type
6+
7+
error[E0275]: overflow evaluating the requirement `<impl for<'any> FnMutFut<&'any BAZ::Param, ()> as FnMutFut<&<BAZ as Baz>::Param, ()>>::Future`
8+
|
9+
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_116864`)
10+
11+
error: aborting due to 2 previous errors
12+
13+
Some errors have detailed explanations: E0275, E0282.
14+
For more information about an error, try `rustc --explain E0275`.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// edition:2021
2+
// revisions: current next
3+
//[next] compile-flags: -Ztrait-solver=next
4+
5+
//[next]~^^^^ ERROR overflow evaluating the requirement
6+
7+
use std::future::Future;
8+
9+
pub trait Baz {
10+
type Param;
11+
}
12+
13+
pub trait FnMutFut<P, R>: FnMut(P) -> Self::Future {
14+
type Future: Future<Output = R>;
15+
}
16+
17+
impl<P, F, FUT, R> FnMutFut<P, R> for F
18+
where
19+
F: FnMut(P) -> FUT,
20+
FUT: Future<Output = R>,
21+
{
22+
type Future = FUT;
23+
}
24+
25+
pub async fn does_not_work<BAZ>(_: BAZ, mut cb: impl for<'any> FnMutFut<&'any BAZ::Param, ()>)
26+
//[current]~^ ERROR expected a `FnMut(&'any i32)` closure, found `imp
27+
where
28+
BAZ: Baz<Param = i32>,
29+
{
30+
//[current]~^ ERROR expected a `FnMut(&'any i32)` closure, found
31+
cb(&1i32).await;
32+
//[current]~^ ERROR expected a `FnMut(&i32)` closure, found `impl for<'any> FnMutFut<&'
33+
//[current]~| ERROR mismatched types
34+
//[next]~^^^ ERROR type annotations needed
35+
}
36+
37+
fn main() {
38+
}

0 commit comments

Comments
 (0)