]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-47139-2.rs
Auto merge of #47804 - retep007:recursive-requirements, r=pnkfelix
[rust.git] / src / test / run-pass / issue-47139-2.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Regression test for issue #47139:
12 //
13 // Same as issue-47139-1.rs, but the impls of dummy are in the
14 // opposite order. This influenced the way that coherence ran and in
15 // some cases caused the overflow to occur when it wouldn't otherwise.
16 // In an effort to make the regr test more robust, I am including both
17 // orderings.
18
19 #![allow(dead_code)]
20
21 pub trait Insertable {
22     type Values;
23
24     fn values(self) -> Self::Values;
25 }
26
27 impl<T> Insertable for Option<T>
28     where
29     T: Insertable,
30     T::Values: Default,
31 {
32     type Values = T::Values;
33
34     fn values(self) -> Self::Values {
35         self.map(Insertable::values).unwrap_or_default()
36     }
37 }
38
39 impl<'a, T> Insertable for &'a Option<T>
40     where
41     Option<&'a T>: Insertable,
42 {
43     type Values = <Option<&'a T> as Insertable>::Values;
44
45     fn values(self) -> Self::Values {
46         self.as_ref().values()
47     }
48 }
49
50 impl<'a, T> Insertable for &'a [T]
51 {
52     type Values = Self;
53
54     fn values(self) -> Self::Values {
55         self
56     }
57 }
58
59 trait Unimplemented { }
60
61 trait Dummy { }
62
63 struct Foo<T> { t: T }
64
65 impl<T> Dummy for T
66     where T: Unimplemented
67 { }
68
69 impl<'a, U> Dummy for Foo<&'a U>
70     where &'a U: Insertable
71 {
72 }
73
74 fn main() {
75 }