@@ -689,9 +689,8 @@ pub fn trans_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, discr: D
689
689
let lldiscr = C_integral ( Type :: from_integer ( ccx, d) , discr. 0 as u64 , true ) ;
690
690
let mut vals_with_discr = vec ! [ lldiscr] ;
691
691
vals_with_discr. extend_from_slice ( vals) ;
692
- let mut contents = build_const_struct ( ccx, & variant,
693
- & vals_with_discr[ ..] ) ;
694
- let needed_padding = l. size ( dl) . bytes ( ) - variant. min_size . bytes ( ) ;
692
+ let mut contents = build_const_struct ( ccx, & variant, & vals_with_discr[ ..] ) ;
693
+ let needed_padding = l. size ( dl) . bytes ( ) - variant. stride ( ) . bytes ( ) ;
695
694
if needed_padding > 0 {
696
695
contents. push ( padding ( ccx, needed_padding) ) ;
697
696
}
@@ -704,8 +703,7 @@ pub fn trans_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, discr: D
704
703
}
705
704
layout:: Univariant { ref variant, .. } => {
706
705
assert_eq ! ( discr, Disr ( 0 ) ) ;
707
- let contents = build_const_struct ( ccx,
708
- & variant, vals) ;
706
+ let contents = build_const_struct ( ccx, & variant, vals) ;
709
707
C_struct ( ccx, & contents[ ..] , variant. packed )
710
708
}
711
709
layout:: Vector { .. } => {
@@ -722,17 +720,15 @@ pub fn trans_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, discr: D
722
720
}
723
721
layout:: StructWrappedNullablePointer { ref nonnull, nndiscr, .. } => {
724
722
if discr. 0 == nndiscr {
725
- C_struct ( ccx, & build_const_struct ( ccx, & nonnull, vals) ,
726
- false )
723
+ C_struct ( ccx, & build_const_struct ( ccx, & nonnull, vals) , false )
727
724
} else {
728
725
let fields = compute_fields ( ccx, t, nndiscr as usize , false ) ;
729
726
let vals = fields. iter ( ) . map ( |& ty| {
730
727
// Always use null even if it's not the `discrfield`th
731
728
// field; see #8506.
732
729
C_null ( type_of:: sizing_type_of ( ccx, ty) )
733
730
} ) . collect :: < Vec < ValueRef > > ( ) ;
734
- C_struct ( ccx, & build_const_struct ( ccx, & nonnull, & vals[ ..] ) ,
735
- false )
731
+ C_struct ( ccx, & build_const_struct ( ccx, & nonnull, & vals[ ..] ) , false )
736
732
}
737
733
}
738
734
_ => bug ! ( "trans_const: cannot handle type {} repreented as {:#?}" , t, l)
0 commit comments