From: varkor Date: Mon, 25 Feb 2019 23:55:34 +0000 (+0000) Subject: Add a test for #55731 X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=b7763af5267be200ffcb75e1ed35a0f3979c7d51;p=rust.git Add a test for #55731 --- diff --git a/src/test/ui/issues/issue-55731.rs b/src/test/ui/issues/issue-55731.rs new file mode 100644 index 00000000000..7b4f4e2cd3b --- /dev/null +++ b/src/test/ui/issues/issue-55731.rs @@ -0,0 +1,52 @@ +use std::marker::PhantomData; + +trait DistributedIterator { + fn reduce(self) + where + Self: Sized, + { + unreachable!() + } +} + +trait DistributedIteratorMulti { + type Item; +} + +struct Connect(PhantomData); +impl DistributedIteratorMulti<&'a ()>> DistributedIterator for Connect where {} + +struct Cloned(PhantomData); +impl<'a, Source> DistributedIteratorMulti<&'a Source> for Cloned<&'a Source> { + type Item = (); +} + +struct Map { + i: I, + f: F, +} +impl, F, Source> DistributedIteratorMulti for Map +where + F: A<>::Item>, +{ + type Item = (); +} + +trait A {} + +struct X; +impl A<()> for X {} + +fn multi(_reducer: I) +where + I: for<'a> DistributedIteratorMulti<&'a ()>, +{ + DistributedIterator::reduce(Connect::(PhantomData)) +} + +fn main() { + multi(Map { //~ ERROR implementation of `DistributedIteratorMulti` is not general enough + i: Cloned(PhantomData), + f: X, + }); +} diff --git a/src/test/ui/issues/issue-55731.stderr b/src/test/ui/issues/issue-55731.stderr new file mode 100644 index 00000000000..67f2053de1e --- /dev/null +++ b/src/test/ui/issues/issue-55731.stderr @@ -0,0 +1,12 @@ +error: implementation of `DistributedIteratorMulti` is not general enough + --> $DIR/issue-55731.rs:48:5 + | +LL | multi(Map { //~ ERROR implementation of `DistributedIteratorMulti` is not general enough + | ^^^^^ + | + = note: Due to a where-clause on `multi`, + = note: `Map, X>` must implement `DistributedIteratorMulti<&'0 ()>`, for any lifetime `'0` + = note: but `Map, X>` actually implements `DistributedIteratorMulti<&'1 ()>`, for some specific lifetime `'1` + +error: aborting due to previous error +