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