@@ -3363,7 +3363,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33633363
33643364 let field_ty = self . field_ty ( expr. span , field, args) ;
33653365
3366- // FIXME: DSTs with static alignment should be allowed
3366+ // Enums are anyway always sized. But just to safeguard against future
3367+ // language extensions, let's double-check.
33673368 self . require_type_is_sized ( field_ty, expr. span , ObligationCauseCode :: Misc ) ;
33683369
33693370 if field. vis . is_accessible_from ( sub_def_scope, self . tcx ) {
@@ -3391,8 +3392,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
33913392 {
33923393 let field_ty = self . field_ty ( expr. span , field, args) ;
33933394
3394- // FIXME: DSTs with static alignment should be allowed
3395- self . require_type_is_sized ( field_ty, expr. span , ObligationCauseCode :: Misc ) ;
3395+ if self . tcx . features ( ) . offset_of_slice {
3396+ self . require_type_has_static_alignment (
3397+ field_ty,
3398+ expr. span ,
3399+ ObligationCauseCode :: Misc ,
3400+ ) ;
3401+ } else {
3402+ self . require_type_is_sized (
3403+ field_ty,
3404+ expr. span ,
3405+ ObligationCauseCode :: Misc ,
3406+ ) ;
3407+ }
33963408
33973409 if field. vis . is_accessible_from ( def_scope, self . tcx ) {
33983410 self . tcx . check_stability ( field. did , Some ( expr. hir_id ) , expr. span , None ) ;
@@ -3412,10 +3424,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
34123424 if let Ok ( index) = field. as_str ( ) . parse :: < usize > ( )
34133425 && field. name == sym:: integer ( index)
34143426 {
3415- for ty in tys. iter ( ) . take ( index + 1 ) {
3416- self . require_type_is_sized ( ty, expr. span , ObligationCauseCode :: Misc ) ;
3417- }
34183427 if let Some ( & field_ty) = tys. get ( index) {
3428+ if self . tcx . features ( ) . offset_of_slice {
3429+ self . require_type_has_static_alignment (
3430+ field_ty,
3431+ expr. span ,
3432+ ObligationCauseCode :: Misc ,
3433+ ) ;
3434+ } else {
3435+ self . require_type_is_sized (
3436+ field_ty,
3437+ expr. span ,
3438+ ObligationCauseCode :: Misc ,
3439+ ) ;
3440+ }
3441+
34193442 field_indices. push ( ( FIRST_VARIANT , index. into ( ) ) ) ;
34203443 current_container = field_ty;
34213444
0 commit comments