@@ -357,7 +357,9 @@ pub fn optimize_module_direct(module: &Module) -> Result<Module, EgglogOptError>
357357 } else {
358358 format ! ( "(BSym \" id{}\" )" , sel. condition_id)
359359 } ;
360- let branch_type_class = ctx. id_to_type . get ( & then_id)
360+ let branch_type_class = ctx
361+ . id_to_type
362+ . get ( & then_id)
361363 . and_then ( |ty| type_classes. get ( ty) )
362364 . copied ( )
363365 . unwrap_or ( TypeClass :: Other ) ;
@@ -367,10 +369,8 @@ pub fn optimize_module_direct(module: &Module) -> Result<Module, EgglogOptError>
367369 TypeClass :: Bool => "GammaB" ,
368370 TypeClass :: Other => "Gamma" ,
369371 } ;
370- let gamma_term = format ! (
371- "({} {} id{} id{})" ,
372- gamma_ctor, cond_term, then_id, else_id
373- ) ;
372+ let gamma_term =
373+ format ! ( "({} {} id{} id{})" , gamma_ctor, cond_term, then_id, else_id) ;
374374 let gamma_binding = format ! ( "(let gamma_{}_{} {})" , then_id, else_id, gamma_term) ;
375375 egraph
376376 . parse_and_run_program ( None , & gamma_binding)
@@ -767,9 +767,7 @@ pub fn optimize_module_direct(module: &Module) -> Result<Module, EgglogOptError>
767767 match inst. class . opcode {
768768 Op :: Constant => {
769769 // Check if this constant's type is float
770- let is_float = inst
771- . result_type
772- . and_then ( |ty| type_classes. get ( & ty) )
770+ let is_float = inst. result_type . and_then ( |ty| type_classes. get ( & ty) )
773771 == Some ( & TypeClass :: Float ) ;
774772
775773 if is_float {
@@ -932,9 +930,8 @@ pub fn optimize_module_direct(module: &Module) -> Result<Module, EgglogOptError>
932930 next_id += 1 ;
933931 // value contains f64 bits packed as i64
934932 let f64_val = f64:: from_bits ( value as u64 ) ;
935- let operand = rspirv:: dr:: Operand :: LiteralBit32 (
936- ( f64_val as f32 ) . to_bits ( ) ,
937- ) ;
933+ let operand =
934+ rspirv:: dr:: Operand :: LiteralBit32 ( ( f64_val as f32 ) . to_bits ( ) ) ;
938935 synthesized_constants. push ( Instruction :: new (
939936 Op :: Constant ,
940937 Some ( ty) ,
@@ -2021,7 +2018,12 @@ fn cleanup_module(
20212018fn collect_ids_from_term ( term : & str , id_map : & HashMap < String , Word > , used_ids : & mut HashSet < Word > ) {
20222019 // Find all Sym variants: (Sym "idN"), (ISym "idN"), (FSym "idN"), (BSym "idN")
20232020 let sym_prefixes: & [ & [ u8 ] ] = & [ b"(Sym \" id" , b"(ISym \" id" , b"(FSym \" id" , b"(BSym \" id" ] ;
2024- let const_prefixes: & [ & [ u8 ] ] = & [ b"(Sym \" const" , b"(ISym \" const" , b"(FSym \" const" , b"(BSym \" const" ] ;
2021+ let const_prefixes: & [ & [ u8 ] ] = & [
2022+ b"(Sym \" const" ,
2023+ b"(ISym \" const" ,
2024+ b"(FSym \" const" ,
2025+ b"(BSym \" const" ,
2026+ ] ;
20252027 let mut i = 0 ;
20262028 let bytes = term. as_bytes ( ) ;
20272029 while i < bytes. len ( ) {
@@ -2047,15 +2049,20 @@ fn collect_ids_from_term(term: &str, id_map: &HashMap<String, Word>, used_ids: &
20472049 break ;
20482050 }
20492051 }
2050- if matched { continue ; }
2052+ if matched {
2053+ continue ;
2054+ }
20512055
20522056 // Check for Sym "const..." patterns (constant references)
20532057 for prefix in const_prefixes {
20542058 if i + prefix. len ( ) < bytes. len ( ) && & bytes[ i..i + prefix. len ( ) ] == * prefix {
20552059 // Find the opening quote position: after "(Sym " or "(ISym " etc.
20562060 // We need to extract the key between the quotes
20572061 // Find the full key between quotes
2058- let key_start = bytes[ i..] . iter ( ) . position ( |& b| b == b'"' ) . map ( |p| i + p + 1 ) ;
2062+ let key_start = bytes[ i..]
2063+ . iter ( )
2064+ . position ( |& b| b == b'"' )
2065+ . map ( |p| i + p + 1 ) ;
20592066 if let Some ( ks) = key_start {
20602067 let mut end = ks;
20612068 while end < bytes. len ( ) && bytes[ end] != b'"' {
@@ -2074,7 +2081,9 @@ fn collect_ids_from_term(term: &str, id_map: &HashMap<String, Word>, used_ids: &
20742081 break ;
20752082 }
20762083 }
2077- if matched { continue ; }
2084+ if matched {
2085+ continue ;
2086+ }
20782087
20792088 i += 1 ;
20802089 }
@@ -2499,7 +2508,10 @@ fn topological_sort_bindings(id_to_term: &HashMap<Word, String>) -> Vec<Word> {
24992508 // Skip Sym variant patterns - these are safe opaque references
25002509 // Handles: (Sym "..."), (ISym "..."), (FSym "..."), (BSym "...")
25012510 let skip_sym = ( i + 5 < bytes. len ( ) && & bytes[ i..i + 5 ] == b"(Sym " )
2502- || ( i + 6 < bytes. len ( ) && ( & bytes[ i..i + 6 ] == b"(ISym " || & bytes[ i..i + 6 ] == b"(FSym " || & bytes[ i..i + 6 ] == b"(BSym " ) ) ;
2511+ || ( i + 6 < bytes. len ( )
2512+ && ( & bytes[ i..i + 6 ] == b"(ISym "
2513+ || & bytes[ i..i + 6 ] == b"(FSym "
2514+ || & bytes[ i..i + 6 ] == b"(BSym " ) ) ;
25032515 if skip_sym {
25042516 // Skip to closing paren
25052517 if let Some ( close) = term[ i..] . find ( ')' ) {
@@ -2614,8 +2626,14 @@ fn parse_effect_result(s: &str) -> Option<ParsedEffect> {
26142626
26152627 // Check for Gamma/Select variants (typed and untyped)
26162628 let gamma_select_prefixes = [
2617- "(Gamma " , "(GammaI " , "(GammaF " , "(GammaB " ,
2618- "(Select " , "(SelectI " , "(SelectF " , "(SelectB " ,
2629+ "(Gamma " ,
2630+ "(GammaI " ,
2631+ "(GammaF " ,
2632+ "(GammaB " ,
2633+ "(Select " ,
2634+ "(SelectI " ,
2635+ "(SelectF " ,
2636+ "(SelectB " ,
26192637 ] ;
26202638 let matched_prefix = gamma_select_prefixes. iter ( ) . find ( |p| inner. starts_with ( * p) ) ;
26212639 if let Some ( prefix) = matched_prefix {
@@ -3153,10 +3171,18 @@ fn materialize_term(
31533171
31543172 // Select / Gamma / If (untyped and typed variants) — all map to Op::Select
31553173 for select_prefix in & [
3156- "(Select " , "(Gamma " , "(If " ,
3157- "(SelectI " , "(GammaI " , "(IfI " ,
3158- "(SelectF " , "(GammaF " , "(IfF " ,
3159- "(SelectB " , "(GammaB " , "(IfB " ,
3174+ "(Select " ,
3175+ "(Gamma " ,
3176+ "(If " ,
3177+ "(SelectI " ,
3178+ "(GammaI " ,
3179+ "(IfI " ,
3180+ "(SelectF " ,
3181+ "(GammaF " ,
3182+ "(IfF " ,
3183+ "(SelectB " ,
3184+ "(GammaB " ,
3185+ "(IfB " ,
31603186 ] {
31613187 if let Some ( rest) = term. strip_prefix ( select_prefix) {
31623188 if let Some ( rest) = rest. strip_suffix ( ')' ) {
0 commit comments