@@ -3363,7 +3363,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3363
3363
3364
3364
let field_ty = self . field_ty ( expr. span , field, args) ;
3365
3365
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.
3367
3368
self . require_type_is_sized ( field_ty, expr. span , ObligationCauseCode :: Misc ) ;
3368
3369
3369
3370
if field. vis . is_accessible_from ( sub_def_scope, self . tcx ) {
@@ -3391,8 +3392,19 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3391
3392
{
3392
3393
let field_ty = self . field_ty ( expr. span , field, args) ;
3393
3394
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
+ }
3396
3408
3397
3409
if field. vis . is_accessible_from ( def_scope, self . tcx ) {
3398
3410
self . tcx . check_stability ( field. did , Some ( expr. hir_id ) , expr. span , None ) ;
@@ -3412,10 +3424,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3412
3424
if let Ok ( index) = field. as_str ( ) . parse :: < usize > ( )
3413
3425
&& field. name == sym:: integer ( index)
3414
3426
{
3415
- for ty in tys. iter ( ) . take ( index + 1 ) {
3416
- self . require_type_is_sized ( ty, expr. span , ObligationCauseCode :: Misc ) ;
3417
- }
3418
3427
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
+
3419
3442
field_indices. push ( ( FIRST_VARIANT , index. into ( ) ) ) ;
3420
3443
current_container = field_ty;
3421
3444
0 commit comments