@@ -21,32 +21,29 @@ use crate::interpret::{
2121fn  branches < ' tcx > ( 
2222    ecx :  & CompileTimeInterpCx < ' tcx > , 
2323    place :  & MPlaceTy < ' tcx > , 
24-     n :  usize , 
24+     field_count :  usize , 
2525    variant :  Option < VariantIdx > , 
2626    num_nodes :  & mut  usize , 
2727)  -> ValTreeCreationResult < ' tcx >  { 
2828    let  place = match  variant { 
2929        Some ( variant)  => ecx. project_downcast ( place,  variant) . unwrap ( ) , 
3030        None  => place. clone ( ) , 
3131    } ; 
32-     let  variant = variant
33-         . map ( |variant| Some ( ty:: ValTree :: from_scalar_int ( * ecx. tcx ,  variant. as_u32 ( ) . into ( ) ) ) ) ; 
34-     debug ! ( ?place,  ?variant) ; 
32+     debug ! ( ?place) ; 
3533
36-     let  mut  fields = Vec :: with_capacity ( n) ; 
37-     for  i in  0 ..n { 
38-         let  field = ecx. project_field ( & place,  i) . unwrap ( ) ; 
39-         let  valtree = const_to_valtree_inner ( ecx,  & field,  num_nodes) ?; 
40-         fields. push ( Some ( valtree) ) ; 
41-     } 
34+     let  mut  branches = Vec :: with_capacity ( field_count + variant. is_some ( )  as  usize ) ; 
4235
4336    // For enums, we prepend their variant index before the variant's fields so we can figure out 
4437    // the variant again when just seeing a valtree. 
45-     let  branches = variant
46-         . into_iter ( ) 
47-         . chain ( fields. into_iter ( ) ) 
48-         . collect :: < Option < Vec < _ > > > ( ) 
49-         . expect ( "should have already checked for errors in ValTree creation" ) ; 
38+     if  let  Some ( variant)  = variant { 
39+         branches. push ( ty:: ValTree :: from_scalar_int ( * ecx. tcx ,  variant. as_u32 ( ) . into ( ) ) ) ; 
40+     } 
41+ 
42+     for  i in  0 ..field_count { 
43+         let  field = ecx. project_field ( & place,  i) . unwrap ( ) ; 
44+         let  valtree = const_to_valtree_inner ( ecx,  & field,  num_nodes) ?; 
45+         branches. push ( valtree) ; 
46+     } 
5047
5148    // Have to account for ZSTs here 
5249    if  branches. len ( )  == 0  { 
0 commit comments