File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
compiler/rustc_ty_utils/src Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -517,6 +517,10 @@ fn layout_of_uncached<'tcx>(
517517 pref : dl. vector_align ( size) . pref ,
518518 } ,
519519 )
520+ } else if let Some ( align) = def. repr ( ) . align {
521+ let natural_align = dl. vector_align ( size) ;
522+ let align = natural_align. max ( AbiAndPrefAlign :: new ( align) ) ;
523+ ( Abi :: Vector { element : e_abi, count : e_len } , align)
520524 } else {
521525 ( Abi :: Vector { element : e_abi, count : e_len } , dl. vector_align ( size) )
522526 } ;
Original file line number Diff line number Diff line change 1+ //@ run-pass
2+ // A regression test for https://github.com/rust-lang/rust/issues/130402
3+ // Our SIMD representation did not combine correctly with the repr(align) attribute,
4+ // and this will remain a concern regardless of what we do with SIMD types.
5+ #![ feature( repr_simd) ]
6+ use std:: mem:: { size_of, align_of} ;
7+
8+ #[ repr( simd, align( 64 ) ) ]
9+ struct IntelsIdeaOfWhatAvx512Means ( [ u8 ; 32 ] ) ;
10+
11+ #[ repr( transparent) ]
12+ struct DesignValidation ( IntelsIdeaOfWhatAvx512Means ) ;
13+
14+ fn main ( ) {
15+ assert_eq ! ( 64 , size_of:: <IntelsIdeaOfWhatAvx512Means >( ) ) ;
16+ assert_eq ! ( 64 , align_of:: <IntelsIdeaOfWhatAvx512Means >( ) ) ;
17+ assert_eq ! ( 64 , size_of:: <DesignValidation >( ) ) ;
18+ assert_eq ! ( 64 , align_of:: <DesignValidation >( ) ) ;
19+ }
You can’t perform that action at this time.
0 commit comments