]> git.proxmox.com Git - rustc.git/blob - src/test/compile-fail/issue-22638.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / test / compile-fail / issue-22638.rs
1 // Copyright 2015 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 #![allow(unused)]
12
13 #![recursion_limit = "20"]
14 #![type_length_limit = "20000000"]
15 #![crate_type = "rlib"]
16
17 #[derive(Clone)]
18 struct A (B);
19
20 impl A {
21 pub fn matches<F: Fn()>(&self, f: &F) {
22 //~^ ERROR reached the recursion limit while instantiating `A::matches::<[closure
23 let &A(ref term) = self;
24 term.matches(f);
25 }
26 }
27
28 #[derive(Clone)]
29 enum B {
30 Variant1,
31 Variant2(C),
32 }
33
34 impl B {
35 pub fn matches<F: Fn()>(&self, f: &F) {
36 match self {
37 &B::Variant2(ref factor) => {
38 factor.matches(&|| ())
39 }
40 _ => unreachable!("")
41 }
42 }
43 }
44
45 #[derive(Clone)]
46 struct C (D);
47
48 impl C {
49 pub fn matches<F: Fn()>(&self, f: &F) {
50 let &C(ref base) = self;
51 base.matches(&|| {
52 C(base.clone()).matches(f)
53 })
54 }
55 }
56
57 #[derive(Clone)]
58 struct D (Box<A>);
59
60 impl D {
61 pub fn matches<F: Fn()>(&self, f: &F) {
62 let &D(ref a) = self;
63 a.matches(f)
64 }
65 }
66
67 pub fn matches() {
68 A(B::Variant1).matches(&(|| ()))
69 }