Skip to content

Commit d76a632

Browse files
committed
Add a test for rust-lang#55731
1 parent 4e5f780 commit d76a632

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

src/test/ui/issues/issue-55731.rs

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
use std::marker::PhantomData;
2+
3+
trait DistributedIterator {
4+
fn reduce(self)
5+
where
6+
Self: Sized,
7+
{
8+
unreachable!()
9+
}
10+
}
11+
12+
trait DistributedIteratorMulti<Source> {
13+
type Item;
14+
}
15+
16+
struct Connect<I>(PhantomData<fn(I)>);
17+
impl<I: for<'a> DistributedIteratorMulti<&'a ()>> DistributedIterator for Connect<I> where {}
18+
19+
struct Cloned<Source>(PhantomData<fn(Source)>);
20+
impl<'a, Source> DistributedIteratorMulti<&'a Source> for Cloned<&'a Source> {
21+
type Item = ();
22+
}
23+
24+
struct Map<I, F> {
25+
i: I,
26+
f: F,
27+
}
28+
impl<I: DistributedIteratorMulti<Source>, F, Source> DistributedIteratorMulti<Source> for Map<I, F>
29+
where
30+
F: A<<I as DistributedIteratorMulti<Source>>::Item>,
31+
{
32+
type Item = ();
33+
}
34+
35+
trait A<B> {}
36+
37+
struct X;
38+
impl A<()> for X {}
39+
40+
fn multi<I>(_reducer: I)
41+
where
42+
I: for<'a> DistributedIteratorMulti<&'a ()>,
43+
{
44+
DistributedIterator::reduce(Connect::<I>(PhantomData))
45+
}
46+
47+
fn main() {
48+
multi(Map { //~ ERROR implementation of `DistributedIteratorMulti` is not general enough
49+
i: Cloned(PhantomData),
50+
f: X,
51+
});
52+
}

src/test/ui/issues/issue-55731.stderr

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error: implementation of `DistributedIteratorMulti` is not general enough
2+
--> $DIR/issue-55731.rs:48:5
3+
|
4+
LL | multi(Map { //~ ERROR implementation of `DistributedIteratorMulti` is not general enough
5+
| ^^^^^
6+
|
7+
= note: Due to a where-clause on `multi`,
8+
= note: `Map<Cloned<&()>, X>` must implement `DistributedIteratorMulti<&'0 ()>`, for any lifetime `'0`
9+
= note: but `Map<Cloned<&()>, X>` actually implements `DistributedIteratorMulti<&'1 ()>`, for some specific lifetime `'1`
10+
11+
error: aborting due to previous error
12+

0 commit comments

Comments
 (0)