]>
Commit | Line | Data |
---|---|---|
dfeec247 | 1 | // build-fail |
b7449926 | 2 | // normalize-stderr-test: "<\[closure@.+`" -> "$$CLOSURE`" |
1b1a35ee | 3 | // normalize-stderr-test: ".nll/" -> "/" |
b7449926 | 4 | |
e9174d1e SL |
5 | #![allow(unused)] |
6 | ||
476ff2be SL |
7 | #![recursion_limit = "20"] |
8 | #![type_length_limit = "20000000"] | |
abe05a73 | 9 | #![crate_type = "rlib"] |
92a42be0 | 10 | |
e9174d1e SL |
11 | #[derive(Clone)] |
12 | struct A (B); | |
13 | ||
14 | impl A { | |
15 | pub fn matches<F: Fn()>(&self, f: &F) { | |
e9174d1e SL |
16 | let &A(ref term) = self; |
17 | term.matches(f); | |
18 | } | |
19 | } | |
20 | ||
21 | #[derive(Clone)] | |
22 | enum B { | |
23 | Variant1, | |
24 | Variant2(C), | |
25 | } | |
26 | ||
27 | impl B { | |
28 | pub fn matches<F: Fn()>(&self, f: &F) { | |
29 | match self { | |
30 | &B::Variant2(ref factor) => { | |
31 | factor.matches(&|| ()) | |
32 | } | |
33 | _ => unreachable!("") | |
34 | } | |
35 | } | |
36 | } | |
37 | ||
38 | #[derive(Clone)] | |
39 | struct C (D); | |
40 | ||
41 | impl C { | |
42 | pub fn matches<F: Fn()>(&self, f: &F) { | |
43 | let &C(ref base) = self; | |
44 | base.matches(&|| { | |
45 | C(base.clone()).matches(f) | |
46 | }) | |
47 | } | |
48 | } | |
49 | ||
50 | #[derive(Clone)] | |
51 | struct D (Box<A>); | |
52 | ||
53 | impl D { | |
54 | pub fn matches<F: Fn()>(&self, f: &F) { | |
55 | let &D(ref a) = self; | |
56 | a.matches(f) | |
6c58768f | 57 | //~^ ERROR reached the recursion limit while instantiating `A::matches::<[closure |
e9174d1e SL |
58 | } |
59 | } | |
60 | ||
61 | pub fn matches() { | |
62 | A(B::Variant1).matches(&(|| ())) | |
63 | } |