@@ -334,7 +334,7 @@ fn caller() -> i32 {
334334
335335 let mut program = air;
336336 compute_layouts ( & mut program) ;
337- let program = monomorphize ( program) ;
337+ let program = monomorphize ( program) . unwrap ( ) ;
338338
339339 let mono_fn = program
340340 . functions
@@ -418,7 +418,7 @@ fn main() {
418418"# ,
419419 ) ;
420420 compute_layouts ( & mut air) ;
421- let mut air = monomorphize ( air) ;
421+ let mut air = monomorphize ( air) . unwrap ( ) ;
422422 passes:: copy_elim:: eliminate_copies ( & mut air) ;
423423 passes:: dead_locals:: eliminate_dead_locals ( & mut air) ;
424424
@@ -501,7 +501,7 @@ fn align_probe(x: i64, y: i32, z: i16, w: i8, b: bool, f: f32, d: f64, p: string
501501"# ,
502502 ) ;
503503 compute_layouts ( & mut air) ;
504- let mut air = monomorphize ( air) ;
504+ let mut air = monomorphize ( air) . unwrap ( ) ;
505505 passes:: copy_elim:: eliminate_copies ( & mut air) ;
506506
507507 let f = func ( & air, "align_probe" ) ;
@@ -536,7 +536,7 @@ fn keep_copy(x: i64) -> i64 {
536536"# ,
537537 ) ;
538538 compute_layouts ( & mut air) ;
539- let mut air = monomorphize ( air) ;
539+ let mut air = monomorphize ( air) . unwrap ( ) ;
540540 aelys_air:: passes:: copy_elim:: eliminate_copies ( & mut air) ;
541541
542542 let f = func ( & air, "keep_copy" ) ;
@@ -626,7 +626,7 @@ fn align_probe(x: i64, y: i32, z: i16, w: i8, b: bool, f: f32, d: f64, p: string
626626"# ,
627627 ) ;
628628 compute_layouts ( & mut air) ;
629- let mut air = monomorphize ( air) ;
629+ let mut air = monomorphize ( air) . unwrap ( ) ;
630630 passes:: copy_elim:: eliminate_copies ( & mut air) ;
631631 passes:: dead_locals:: eliminate_dead_locals ( & mut air) ;
632632
@@ -658,7 +658,7 @@ fn caller() -> i64 {
658658
659659 let mut program = air;
660660 compute_layouts ( & mut program) ;
661- let program = monomorphize ( program) ;
661+ let program = monomorphize ( program) . unwrap ( ) ;
662662
663663 // Both instantiations should exist
664664 let mono_i32 = program
@@ -998,20 +998,20 @@ fn main() -> i64 {
998998"# ,
999999 ) ;
10001000 let f = func ( & air, "main" ) ;
1001- let has_fnref = f. blocks . iter ( ) . any ( |b| {
1001+ let has_closure_create = f. blocks . iter ( ) . any ( |b| {
10021002 b. stmts . iter ( ) . any ( |s| {
10031003 matches ! (
10041004 & s. kind,
10051005 AirStmtKind :: Assign {
1006- rvalue: Rvalue :: Use ( Operand :: Const ( AirConst :: FnRef ( name ) ) ) ,
1006+ rvalue: Rvalue :: ClosureCreate { fn_name , .. } ,
10071007 ..
1008- } if name == "inc"
1008+ } if fn_name == "inc"
10091009 )
10101010 } )
10111011 } ) ;
10121012 assert ! (
1013- has_fnref ,
1014- "expected function identifier value to materialize from FnRef (\" inc\" )"
1013+ has_closure_create ,
1014+ "expected function identifier value to materialize from ClosureCreate (\" inc\" )"
10151015 ) ;
10161016}
10171017
@@ -1156,7 +1156,7 @@ fn caller() -> i32 {
11561156"# ,
11571157 ) ;
11581158 compute_layouts ( & mut air) ;
1159- let mut air = monomorphize ( air) ;
1159+ let mut air = monomorphize ( air) . unwrap ( ) ;
11601160 passes:: copy_elim:: eliminate_copies ( & mut air) ;
11611161 passes:: dead_locals:: eliminate_dead_locals ( & mut air) ;
11621162
@@ -1423,7 +1423,7 @@ fn caller() -> i64 {
14231423"# ,
14241424 ) ;
14251425 compute_layouts ( & mut air) ;
1426- let mut air = monomorphize ( air) ;
1426+ let mut air = monomorphize ( air) . unwrap ( ) ;
14271427 passes:: copy_elim:: eliminate_copies ( & mut air) ;
14281428 passes:: dead_locals:: eliminate_dead_locals ( & mut air) ;
14291429
@@ -1448,7 +1448,7 @@ fn main() {
14481448 & [ "print" , "println" ] ,
14491449 ) ;
14501450 compute_layouts ( & mut air) ;
1451- let mut air = monomorphize ( air) ;
1451+ let mut air = monomorphize ( air) . unwrap ( ) ;
14521452 passes:: copy_elim:: eliminate_copies ( & mut air) ;
14531453 passes:: dead_locals:: eliminate_dead_locals ( & mut air) ;
14541454
@@ -1710,31 +1710,13 @@ fn validate_rejects_ambiguous_generic_unit_variant_after_mono() {
17101710 struct_sizes : std:: collections:: HashMap :: new ( ) ,
17111711 } ;
17121712
1713- let air = monomorphize ( program) ;
1714- let result = validate_air ( & air) ;
1715- assert ! (
1716- result. is_err( ) ,
1717- "ambiguous generic unit variant should be rejected after monomorphization"
1718- ) ;
1719- let errors = result. unwrap_err ( ) ;
1720- assert ! (
1721- errors. iter( ) . any( |e| matches!(
1722- & e. detail,
1723- AirValidationDetail :: UnknownEnumType {
1724- local_name: Some ( name) ,
1725- enum_name,
1726- ..
1727- } if name == "ambiguous" && enum_name == "Option"
1728- ) ) ,
1729- "expected unknown enum type error for unresolved local, got: {:?}" ,
1730- errors
1731- ) ;
1713+ let errors = match monomorphize ( program) {
1714+ Err ( e) => e,
1715+ Ok ( _) => panic ! ( "ambiguous generic unit variant should be rejected during monomorphization" ) ,
1716+ } ;
17321717 assert ! (
1733- errors. iter( ) . any( |e| matches!(
1734- & e. detail,
1735- AirValidationDetail :: UnknownEnumReference { enum_name, .. } if enum_name == "Option"
1736- ) ) ,
1737- "expected unknown enum reference error for unresolved enum_init, got: {:?}" ,
1718+ errors. iter( ) . any( |e| e. contains( "ambiguous unit variant" ) ) ,
1719+ "expected ambiguous unit variant error, got: {:?}" ,
17381720 errors
17391721 ) ;
17401722}
@@ -1894,7 +1876,7 @@ fn monomorphize_distinguishes_fnptr_calling_conventions_in_enum_type_args() {
18941876 struct_sizes : std:: collections:: HashMap :: new ( ) ,
18951877 } ;
18961878
1897- let air = monomorphize ( program) ;
1879+ let air = monomorphize ( program) . unwrap ( ) ;
18981880 let holder_defs: Vec < _ > = air
18991881 . enums
19001882 . iter ( )
0 commit comments