@@ -422,7 +422,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
422422 } ) )
423423 }
424424
425- Abi :: ScalarPair ( ..) | Abi :: Aggregate { .. } => {
425+ Abi :: ScalarPair ( ..) | Abi :: Aggregate { sized : true } => {
426426 // Helper for computing `homogeneous_aggregate`, allowing a custom
427427 // starting offset (used below for handling variants).
428428 let from_fields_at =
@@ -520,6 +520,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
520520 Ok ( result)
521521 }
522522 }
523+ Abi :: Aggregate { sized : false } => Err ( Heterogeneous ) ,
523524 }
524525 }
525526}
@@ -555,8 +556,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
555556 scalar_attrs ( & layout, b, a. size ( cx) . align_to ( b. align ( cx) . abi ) ) ,
556557 ) ,
557558 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) ,
560560 } ;
561561 ArgAbi { layout, mode }
562562 }
@@ -580,10 +580,20 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
580580 PassMode :: Indirect { attrs, meta_attrs, on_stack : false }
581581 }
582582
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+
583590 pub fn make_indirect ( & mut self ) {
584591 match self . mode {
585592 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+ }
587597 _ => panic ! ( "Tried to make {:?} indirect" , self . mode) ,
588598 }
589599
0 commit comments