]> git.proxmox.com Git - rustc.git/blame - src/test/ui/issues/issue-47139-2.rs
New upstream version 1.62.1+dfsg1
[rustc.git] / src / test / ui / issues / issue-47139-2.rs
CommitLineData
b7449926 1// run-pass
ff7c6d11
XL
2// Regression test for issue #47139:
3//
4// Same as issue-47139-1.rs, but the impls of dummy are in the
5// opposite order. This influenced the way that coherence ran and in
6// some cases caused the overflow to occur when it wouldn't otherwise.
7// In an effort to make the regr test more robust, I am including both
8// orderings.
9
10#![allow(dead_code)]
11
12pub trait Insertable {
13 type Values;
14
15 fn values(self) -> Self::Values;
16}
17
18impl<T> Insertable for Option<T>
19 where
20 T: Insertable,
21 T::Values: Default,
22{
23 type Values = T::Values;
24
25 fn values(self) -> Self::Values {
26 self.map(Insertable::values).unwrap_or_default()
27 }
28}
29
30impl<'a, T> Insertable for &'a Option<T>
31 where
32 Option<&'a T>: Insertable,
33{
34 type Values = <Option<&'a T> as Insertable>::Values;
35
36 fn values(self) -> Self::Values {
37 self.as_ref().values()
38 }
39}
40
41impl<'a, T> Insertable for &'a [T]
42{
43 type Values = Self;
44
45 fn values(self) -> Self::Values {
46 self
47 }
48}
49
50trait Unimplemented { }
51
52trait Dummy { }
53
54struct Foo<T> { t: T }
55
56impl<T> Dummy for T
57 where T: Unimplemented
58{ }
59
60impl<'a, U> Dummy for Foo<&'a U>
61 where &'a U: Insertable
62{
63}
64
65fn main() {
66}