2 // Regression test for issue #47139:
4 // Coherence was encountering an (unnecessary) overflow trying to
5 // decide if the two impls of dummy overlap.
7 // The overflow went something like:
9 // - `&'a ?T: Insertable` ?
10 // - let ?T = Option<?U> ?
11 // - `Option<?U>: Insertable` ?
12 // - `Option<&'a ?U>: Insertable` ?
13 // - `&'a ?U: Insertable` ?
15 // While somewhere in the middle, a projection would occur, which
16 // broke cycle detection.
18 // It turned out that this cycle was being kicked off due to some
19 // extended diagnostic attempts in coherence, so removing those
20 // sidestepped the issue for now.
24 pub trait Insertable {
27 fn values(self) -> Self::Values;
30 impl<T> Insertable for Option<T>
35 type Values = T::Values;
37 fn values(self) -> Self::Values {
38 self.map(Insertable::values).unwrap_or_default()
42 impl<'a, T> Insertable for &'a Option<T>
44 Option<&'a T>: Insertable,
46 type Values = <Option<&'a T> as Insertable>::Values;
48 fn values(self) -> Self::Values {
49 self.as_ref().values()
53 impl<'a, T> Insertable for &'a [T]
57 fn values(self) -> Self::Values {
62 trait Unimplemented { }
66 struct Foo<T> { t: T }
68 impl<'a, U> Dummy for Foo<&'a U>
69 where &'a U: Insertable
74 where T: Unimplemented