]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-22638.rs
ff58c7aaced03186b1bf5809147ed72fe30a3098
[rust.git] / src / test / ui / issues / issue-22638.rs
1 // normalize-stderr-test: "<\[closure@.+`" -> "$$CLOSURE`"
2
3 #![allow(unused)]
4
5 #![recursion_limit = "20"]
6 #![type_length_limit = "20000000"]
7 #![crate_type = "rlib"]
8
9 #[derive(Clone)]
10 struct A (B);
11
12 impl A {
13     pub fn matches<F: Fn()>(&self, f: &F) {
14         let &A(ref term) = self;
15         term.matches(f);
16     }
17 }
18
19 #[derive(Clone)]
20 enum B {
21     Variant1,
22     Variant2(C),
23 }
24
25 impl B {
26     pub fn matches<F: Fn()>(&self, f: &F) {
27         match self {
28             &B::Variant2(ref factor) => {
29                 factor.matches(&|| ())
30             }
31             _ => unreachable!("")
32         }
33     }
34 }
35
36 #[derive(Clone)]
37 struct C (D);
38
39 impl C {
40     pub fn matches<F: Fn()>(&self, f: &F) {
41         let &C(ref base) = self;
42         base.matches(&|| {
43             C(base.clone()).matches(f)
44         })
45     }
46 }
47
48 #[derive(Clone)]
49 struct D (Box<A>);
50
51 impl D {
52     pub fn matches<F: Fn()>(&self, f: &F) {
53         //~^ ERROR reached the type-length limit while instantiating `<D>::matches::<[closure
54         let &D(ref a) = self;
55         a.matches(f)
56     }
57 }
58
59 pub fn matches() {
60     A(B::Variant1).matches(&(|| ()))
61 }