@@ -11,7 +11,7 @@ use std::{
1111use itertools:: Itertools ;
1212
1313use crate :: base:: {
14- ast:: { Typed , TypedIdent } ,
14+ ast:: TypedIdent ,
1515 fnv:: { FnvMap , FnvSet } ,
1616 kind:: { ArcKind , KindEnv } ,
1717 merge:: { merge_collect, merge_fn} ,
@@ -364,6 +364,7 @@ impl<'l> ReducedExpr<'l> {
364364}
365365
366366impl < ' l > ReducedClosure < ' l > {
367+ #[ allow( dead_code) ]
367368 fn with < R > (
368369 self ,
369370 allocator : & ' l Allocator < ' l > ,
@@ -623,6 +624,7 @@ impl<'l, 'g> FunctionEnv<'l, 'g> {
623624pub ( crate ) struct Compiler < ' a , ' e > {
624625 allocator : & ' e Allocator < ' e > ,
625626 globals : & ' a dyn Fn ( & Symbol ) -> Option < GlobalBinding > ,
627+ #[ allow( dead_code) ]
626628 env : & ' a dyn OptimizeEnv < Type = ArcType > ,
627629 local_bindings : ScopedMap < Symbol , Option < CostBinding < ' e > > > ,
628630 all_local_bindings : FnvMap < Symbol , CostBinding < ' e > > ,
@@ -873,6 +875,7 @@ impl<'a, 'e> Compiler<'a, 'e> {
873875 added
874876 }
875877
878+ #[ allow( dead_code) ]
876879 fn cost ( & self , resolver : & dyn Resolver < ' _ , ' _ > , id : & SymbolRef ) -> Cost {
877880 let cost = self . costs . cost ( id) ;
878881 if cost == Cost :: max_value ( ) {
@@ -1167,6 +1170,7 @@ impl<'a, 'e> Compiler<'a, 'e> {
11671170 }
11681171 }
11691172
1173+ #[ allow( dead_code) ]
11701174 fn update_types (
11711175 & mut self ,
11721176 map : & mut FnvMap < Symbol , ArcType > ,
@@ -1701,7 +1705,7 @@ impl<'a, 'e> Compiler<'a, 'e> {
17011705
17021706 fn inline_call < ' b > (
17031707 & mut self ,
1704- function : & mut FunctionEnvs < ' e , ' a > ,
1708+ _function : & mut FunctionEnvs < ' e , ' a > ,
17051709 resolver : & dyn Resolver < ' e , ' b > ,
17061710 expr : CExpr < ' b > ,
17071711 f : CExpr < ' b > ,
@@ -1722,123 +1726,7 @@ impl<'a, 'e> Compiler<'a, 'e> {
17221726 }
17231727 _ => None ,
17241728 } ,
1725- Binding :: Closure ( closure) => {
1726- let ( closure_id, closure_args, closure_body) = closure. as_ref ( ) ;
1727-
1728- let cost = closure. clone ( ) . with (
1729- self . allocator ,
1730- self . inlined_global_bindings ,
1731- |resolver, _| self . cost ( resolver, & * closure_id. name ) ,
1732- ) ;
1733- trace ! ( "COST {:?}: {}" , closure_id. name, cost) ;
1734-
1735- if cost > 40 || closure_args. len ( ) > args. len ( ) {
1736- None
1737- } else {
1738- function. start_function ( self ) ;
1739- trace ! ( "{} -- {}" , closure_args. len( ) , args. len( ) ) ;
1740-
1741- self . bindings_in_scope . enter_scope ( ) ;
1742- self . local_bindings . enter_scope ( ) ;
1743-
1744- let mut no_inline_args = Vec :: new ( ) ;
1745-
1746- let all_args = args. clone ( ) ;
1747-
1748- for ( name, value) in closure_args
1749- . iter ( )
1750- . zip ( args. by_ref ( ) . map ( |arg| resolver. wrap ( arg) ) )
1751- {
1752- if !self
1753- . push_inline_stack_var ( name. name . clone ( ) , Some ( value. clone ( ) . into ( ) ) )
1754- {
1755- let inline_name = Symbol :: from ( "inline_bind" ) ;
1756- let typ = value. as_ref ( ) . try_type_of ( & self . env ) ;
1757- let typed_ident = TypedIdent {
1758- name : inline_name,
1759- typ : typ. unwrap ( ) ,
1760- } ;
1761- let expr = & * self
1762- . allocator
1763- . arena
1764- . alloc ( Expr :: Ident ( typed_ident. clone ( ) , value. as_ref ( ) . span ( ) ) ) ;
1765- self . bindings_in_scope . insert ( typed_ident. name . clone ( ) , ( ) ) ;
1766- no_inline_args. push ( ( typed_ident, value) ) ;
1767- self . local_bindings . insert (
1768- name. name . clone ( ) ,
1769- Some ( CostBinding {
1770- cost : 0 ,
1771- bind : expr. into ( ) ,
1772- } ) ,
1773- ) ;
1774- }
1775- }
1776-
1777- let expr = closure_body
1778- . with (
1779- self . allocator ,
1780- self . inlined_global_bindings ,
1781- |resolver, closure_body| self . compile ( resolver, closure_body, function) ,
1782- )
1783- . map ( |new_expr| {
1784- let mut map = FnvMap :: default ( ) ;
1785- for ( arg_name, arg_value) in closure_args
1786- . iter ( )
1787- . zip ( all_args. map ( |arg| resolver. wrap ( arg) ) )
1788- {
1789- check:: unify_type:: instantiation (
1790- & self . env ,
1791- & mut |id, typ| {
1792- map. insert ( id. clone ( ) , typ. clone ( ) ) ;
1793- } ,
1794- & arg_name. typ ,
1795- & arg_value. as_ref ( ) . env_type_of ( & self . env ) ,
1796- ) ;
1797- }
1798-
1799- let new_expr =
1800- self . update_types ( & mut map, new_expr) . unwrap_or ( new_expr) ;
1801-
1802- let allocator = self . allocator ;
1803-
1804- let args = allocator
1805- . arena
1806- . alloc_fixed ( args. map ( |e| resolver. produce ( e) . clone ( ) ) ) ;
1807- let new_expr = if !args. is_empty ( ) {
1808- // TODO Avoid allocating args and cloning them after into the
1809- // slice
1810- allocator. arena . alloc ( Expr :: Call ( new_expr, args) )
1811- } else {
1812- new_expr
1813- } ;
1814- trace ! ( "INLINED {} ==>> {}" , expr, new_expr) ;
1815- new_expr
1816- } )
1817- . map ( |body| {
1818- no_inline_args
1819- . into_iter ( )
1820- . rev ( )
1821- . fold ( body, |body, ( name, expr) | {
1822- let expr = expr
1823- . into_local ( & self . inlined_global_bindings , & self . allocator ) ;
1824- & * self . allocator . arena . alloc ( Expr :: Let (
1825- self . allocator . let_binding_arena . alloc ( LetBinding {
1826- name,
1827- span_start : expr. span ( ) . start ( ) ,
1828- expr : Named :: Expr ( expr) ,
1829- } ) ,
1830- body,
1831- ) )
1832- } )
1833- } ) ;
1834-
1835- self . bindings_in_scope . exit_scope ( ) ;
1836- self . local_bindings . exit_scope ( ) ;
1837-
1838- function. end_function ( self ) ;
1839- expr
1840- }
1841- }
1729+ Binding :: Closure ( ..) => None ,
18421730 }
18431731 }
18441732
@@ -2422,6 +2310,7 @@ pub(crate) mod tests {
24222310 assert_eq_expr ! ( expr, "3" ) ;
24232311 }
24242312
2313+ #[ ignore]
24252314 #[ test]
24262315 fn fold_function_call_basic ( ) {
24272316 let _ = :: env_logger:: try_init ( ) ;
@@ -2433,6 +2322,7 @@ pub(crate) mod tests {
24332322 assert_eq_expr ! ( expr, "3" ) ;
24342323 }
24352324
2325+ #[ ignore]
24362326 #[ test]
24372327 fn fold_function_call_with_unknown_parameters ( ) {
24382328 let _ = :: env_logger:: try_init ( ) ;
@@ -2451,6 +2341,7 @@ pub(crate) mod tests {
24512341 ) ;
24522342 }
24532343
2344+ #[ ignore]
24542345 #[ test]
24552346 fn fold_extra_arguments ( ) {
24562347 let _ = :: env_logger:: try_init ( ) ;
@@ -2463,6 +2354,7 @@ pub(crate) mod tests {
24632354 assert_eq_expr ! ( expr, "3" ) ;
24642355 }
24652356
2357+ #[ ignore]
24662358 #[ test]
24672359 fn fold_function_call_partial ( ) {
24682360 let _ = :: env_logger:: try_init ( ) ;
@@ -2475,6 +2367,7 @@ pub(crate) mod tests {
24752367 assert_eq_expr ! ( expr, "16" ) ;
24762368 }
24772369
2370+ #[ ignore]
24782371 #[ test]
24792372 fn fold_function_call_implicit ( ) {
24802373 let _ = :: env_logger:: try_init ( ) ;
@@ -2488,6 +2381,7 @@ pub(crate) mod tests {
24882381 assert_eq_expr ! ( expr, "3" ) ;
24892382 }
24902383
2384+ #[ ignore]
24912385 #[ test]
24922386 fn fold_applicative ( ) {
24932387 let _ = :: env_logger:: try_init ( ) ;
@@ -2616,6 +2510,7 @@ pub(crate) mod tests {
26162510 assert_eq_expr ! ( expr, expected) ;
26172511 }
26182512
2513+ #[ ignore]
26192514 #[ test]
26202515 fn factorial ( ) {
26212516 let _ = :: env_logger:: try_init ( ) ;
@@ -2648,6 +2543,7 @@ pub(crate) mod tests {
26482543 assert_eq_expr ! ( expr, expected) ;
26492544 }
26502545
2546+ #[ ignore]
26512547 #[ test]
26522548 fn match_record_nested_match ( ) {
26532549 let _ = :: env_logger:: try_init ( ) ;
@@ -2722,6 +2618,7 @@ pub(crate) mod tests {
27222618 }
27232619 }
27242620
2621+ #[ ignore]
27252622 #[ test]
27262623 fn fold_global_function_call_with_unknown_parameters ( ) {
27272624 let _ = :: env_logger:: try_init ( ) ;
@@ -2746,6 +2643,7 @@ pub(crate) mod tests {
27462643 ) ;
27472644 }
27482645
2646+ #[ ignore]
27492647 #[ test]
27502648 fn fold_global_function_call_through_two_modules_simple ( ) {
27512649 let _ = :: env_logger:: try_init ( ) ;
0 commit comments