@@ -3391,8 +3391,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33913391 {
33923392 let field_ty = self . field_ty ( expr. span , field, args) ;
33933393
3394- // FIXME: DSTs with static alignment should be allowed
3395- self . require_type_is_sized ( field_ty, expr. span , ObligationCauseCode :: Misc ) ;
3394+ if self . tcx . features ( ) . offset_of_slice {
3395+ self . require_type_has_static_alignment (
3396+ field_ty,
3397+ expr. span ,
3398+ ObligationCauseCode :: Misc ,
3399+ ) ;
3400+ } else {
3401+ self . require_type_is_sized (
3402+ field_ty,
3403+ expr. span ,
3404+ ObligationCauseCode :: Misc ,
3405+ ) ;
3406+ }
33963407
33973408 if field. vis . is_accessible_from ( def_scope, self . tcx ) {
33983409 self . tcx . check_stability ( field. did , Some ( expr. hir_id ) , expr. span , None ) ;
@@ -3412,10 +3423,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
34123423 if let Ok ( index) = field. as_str ( ) . parse :: < usize > ( )
34133424 && field. name == sym:: integer ( index)
34143425 {
3415- for ty in tys. iter ( ) . take ( index + 1 ) {
3416- self . require_type_is_sized ( ty, expr. span , ObligationCauseCode :: Misc ) ;
3417- }
34183426 if let Some ( & field_ty) = tys. get ( index) {
3427+ if self . tcx . features ( ) . offset_of_slice {
3428+ self . require_type_has_static_alignment (
3429+ field_ty,
3430+ expr. span ,
3431+ ObligationCauseCode :: Misc ,
3432+ ) ;
3433+ } else {
3434+ self . require_type_is_sized (
3435+ field_ty,
3436+ expr. span ,
3437+ ObligationCauseCode :: Misc ,
3438+ ) ;
3439+ }
3440+
34193441 field_indices. push ( ( FIRST_VARIANT , index. into ( ) ) ) ;
34203442 current_container = field_ty;
34213443
0 commit comments