]> git.proxmox.com Git - rustc.git/blob - src/test/ui/issues/issue-22638.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / issues / issue-22638.rs
1 // build-fail
2 // normalize-stderr-test: "<\[closure@.+`" -> "$$CLOSURE`"
3 // normalize-stderr-test: ".nll/" -> "/"
4
5 #![allow(unused)]
6
7 #![recursion_limit = "20"]
8 #![type_length_limit = "20000000"]
9 #![crate_type = "rlib"]
10
11 #[derive(Clone)]
12 struct A (B);
13
14 impl A {
15 pub fn matches<F: Fn()>(&self, f: &F) {
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)
57 //~^ ERROR reached the recursion limit while instantiating `A::matches::<[closure
58 }
59 }
60
61 pub fn matches() {
62 A(B::Variant1).matches(&(|| ()))
63 }