@@ -422,7 +422,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
422
422
} ) )
423
423
}
424
424
425
- Abi :: ScalarPair ( ..) | Abi :: Aggregate { .. } => {
425
+ Abi :: ScalarPair ( ..) | Abi :: Aggregate { sized : true } => {
426
426
// Helper for computing `homogeneous_aggregate`, allowing a custom
427
427
// starting offset (used below for handling variants).
428
428
let from_fields_at =
@@ -520,6 +520,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
520
520
Ok ( result)
521
521
}
522
522
}
523
+ Abi :: Aggregate { sized : false } => Err ( Heterogeneous ) ,
523
524
}
524
525
}
525
526
}
@@ -555,8 +556,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
555
556
scalar_attrs ( & layout, b, a. size ( cx) . align_to ( b. align ( cx) . abi ) ) ,
556
557
) ,
557
558
Abi :: Vector { .. } => PassMode :: Direct ( ArgAttributes :: new ( ) ) ,
558
- // The `Aggregate` ABI should always be adjusted later.
559
- Abi :: Aggregate { .. } => PassMode :: Direct ( ArgAttributes :: new ( ) ) ,
559
+ Abi :: Aggregate { .. } => Self :: indirect_pass_mode ( & layout) ,
560
560
} ;
561
561
ArgAbi { layout, mode }
562
562
}
@@ -580,10 +580,20 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
580
580
PassMode :: Indirect { attrs, meta_attrs, on_stack : false }
581
581
}
582
582
583
+ /// Pass this argument directly instead. Should NOT be used!
584
+ /// Only exists because of past ABI mistakes that will take time to fix
585
+ /// (see <https://github.com/rust-lang/rust/issues/115666>).
586
+ pub fn make_direct_deprecated ( & mut self ) {
587
+ self . mode = PassMode :: Direct ( ArgAttributes :: new ( ) ) ;
588
+ }
589
+
583
590
pub fn make_indirect ( & mut self ) {
584
591
match self . mode {
585
592
PassMode :: Direct ( _) | PassMode :: Pair ( _, _) => { }
586
- PassMode :: Indirect { attrs : _, meta_attrs : None , on_stack : false } => return ,
593
+ PassMode :: Indirect { attrs : _, meta_attrs : _, on_stack : false } => {
594
+ // already indirect
595
+ return ;
596
+ }
587
597
_ => panic ! ( "Tried to make {:?} indirect" , self . mode) ,
588
598
}
589
599
0 commit comments