summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/inline/exponential_runtime.rs
blob: 39985528f462ab439fa552670e81b574a9d1c905 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// ignore-wasm32 compiled with panic=abort by default
// Checks that code with exponential runtime does not have exponential behavior in inlining.

trait A {
    fn call();
}

trait B {
    fn call();
}
impl<T: A> B for T {
    #[inline]
    fn call() {
        <T as A>::call();
        <T as A>::call();
        <T as A>::call();
    }
}

trait C {
    fn call();
}
impl<T: B> C for T {
    #[inline]
    fn call() {
        <T as B>::call();
        <T as B>::call();
        <T as B>::call();
    }
}

trait D {
    fn call();
}
impl<T: C> D for T {
    #[inline]
    fn call() {
        <T as C>::call();
        <T as C>::call();
        <T as C>::call();
    }
}

trait E {
    fn call();
}
impl<T: D> E for T {
    #[inline]
    fn call() {
        <T as D>::call();
        <T as D>::call();
        <T as D>::call();
    }
}

trait F {
    fn call();
}
impl<T: E> F for T {
    #[inline]
    fn call() {
        <T as E>::call();
        <T as E>::call();
        <T as E>::call();
    }
}

trait G {
    fn call();
}
impl<T: F> G for T {
    #[inline]
    fn call() {
        <T as F>::call();
        <T as F>::call();
        <T as F>::call();
    }
}

impl A for () {
    #[inline(never)]
    fn call() {}
}

// EMIT_MIR exponential_runtime.main.Inline.diff
fn main() {
    <() as G>::call();
}