File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed
collector/benchmarks/deeply-nested-closures Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ [package ]
2+ name = " deeply-nested-closures"
3+ version = " 0.1.0"
4+ authors = [" Valerii Lashmanov <vflashm@gmail.com>" ]
5+
6+ [dependencies ]
7+
8+ [workspace ]
Original file line number Diff line number Diff line change 1+ // A test case from rust-lang/rust#72408.
2+ // Nesting closures produce exponentially sized type tree with a lot of duplicates.
3+
4+ #![ type_length_limit="469762040" ]
5+
6+ fn dup ( f : impl Fn ( i32 ) -> i32 ) -> impl Fn ( i32 ) -> i32 {
7+ move |a| f ( a * 2 )
8+ }
9+
10+ pub fn foo ( ) {
11+ let f = |a| a;
12+
13+ let f = dup ( f) ;
14+ let f = dup ( f) ;
15+ let f = dup ( f) ;
16+ let f = dup ( f) ;
17+ let f = dup ( f) ;
18+
19+ let f = dup ( f) ;
20+ let f = dup ( f) ;
21+ let f = dup ( f) ;
22+ let f = dup ( f) ;
23+ let f = dup ( f) ;
24+
25+ let f = dup ( f) ;
26+ let f = dup ( f) ;
27+ let f = dup ( f) ;
28+ let f = dup ( f) ;
29+ let f = dup ( f) ;
30+
31+ let f = dup ( f) ;
32+ let f = dup ( f) ;
33+ let f = dup ( f) ;
34+ let f = dup ( f) ;
35+ let f = dup ( f) ;
36+
37+ let f = dup ( f) ;
38+ let f = dup ( f) ;
39+ let f = dup ( f) ;
40+ let f = dup ( f) ;
41+ let f = dup ( f) ;
42+
43+ println ! ( "Type size was at least {}" , f( 1 ) ) ;
44+ }
You can’t perform that action at this time.
0 commit comments