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