@@ -32,7 +32,7 @@ use syntax_pos::Pos;
3232use super :: { FunctionCx , LocalRef } ;
3333use super :: place:: PlaceRef ;
3434use super :: operand:: OperandRef ;
35- use super :: operand:: OperandValue :: { Pair , Ref , UnsizedRef , Immediate } ;
35+ use super :: operand:: OperandValue :: { Pair , Ref , Immediate } ;
3636
3737impl FunctionCx < ' a , ' ll , ' tcx > {
3838 pub fn codegen_block ( & mut self , bb : mir:: BasicBlock ) {
@@ -232,10 +232,8 @@ impl FunctionCx<'a, 'll, 'tcx> {
232232
233233 PassMode :: Direct ( _) | PassMode :: Pair ( ..) => {
234234 let op = self . codegen_consume ( & bx, & mir:: Place :: Local ( mir:: RETURN_PLACE ) ) ;
235- if let Ref ( llval, align) = op. val {
235+ if let Ref ( llval, _ , align) = op. val {
236236 bx. load ( llval, align)
237- } else if let UnsizedRef ( ..) = op. val {
238- bug ! ( "return type must be sized" ) ;
239237 } else {
240238 op. immediate_or_packed_pair ( & bx)
241239 }
@@ -247,7 +245,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
247245 LocalRef :: Operand ( None ) => bug ! ( "use of return before def" ) ,
248246 LocalRef :: Place ( cg_place) => {
249247 OperandRef {
250- val : Ref ( cg_place. llval , cg_place. align ) ,
248+ val : Ref ( cg_place. llval , None , cg_place. align ) ,
251249 layout : cg_place. layout
252250 }
253251 }
@@ -259,12 +257,11 @@ impl FunctionCx<'a, 'll, 'tcx> {
259257 op. val . store ( & bx, scratch) ;
260258 scratch. llval
261259 }
262- Ref ( llval, align) => {
260+ Ref ( llval, _ , align) => {
263261 assert_eq ! ( align. abi( ) , op. layout. align. abi( ) ,
264262 "return place is unaligned!" ) ;
265263 llval
266264 }
267- UnsizedRef ( ..) => bug ! ( "return type must be sized" ) ,
268265 } ;
269266 bx. load (
270267 bx. pointercast ( llslot, cast_ty. llvm_type ( bx. cx ) . ptr_to ( ) ) ,
@@ -605,15 +602,11 @@ impl FunctionCx<'a, 'll, 'tcx> {
605602 // The callee needs to own the argument memory if we pass it
606603 // by-ref, so make a local copy of non-immediate constants.
607604 match ( arg, op. val ) {
608- ( & mir:: Operand :: Copy ( _) , Ref ( .. ) ) |
609- ( & mir:: Operand :: Constant ( _) , Ref ( .. ) ) => {
605+ ( & mir:: Operand :: Copy ( _) , Ref ( _ , None , _ ) ) |
606+ ( & mir:: Operand :: Constant ( _) , Ref ( _ , None , _ ) ) => {
610607 let tmp = PlaceRef :: alloca ( & bx, op. layout , "const" ) ;
611608 op. val . store ( & bx, tmp) ;
612- op. val = Ref ( tmp. llval , tmp. align ) ;
613- }
614- ( & mir:: Operand :: Copy ( _) , UnsizedRef ( ..) ) |
615- ( & mir:: Operand :: Constant ( _) , UnsizedRef ( ..) ) => {
616- bug ! ( "tried to pass an unsized argument by copy or constant" )
609+ op. val = Ref ( tmp. llval , None , tmp. align ) ;
617610 }
618611 _ => { }
619612 }
@@ -667,7 +660,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
667660 }
668661 } else if arg. is_unsized_indirect ( ) {
669662 match op. val {
670- UnsizedRef ( a, b ) => {
663+ Ref ( a, Some ( b ) , _ ) => {
671664 llargs. push ( a) ;
672665 llargs. push ( b) ;
673666 return ;
@@ -690,7 +683,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
690683 }
691684 }
692685 }
693- Ref ( llval, align) => {
686+ Ref ( llval, _ , align) => {
694687 if arg. is_indirect ( ) && align. abi ( ) < arg. layout . align . abi ( ) {
695688 // `foo(packed.large_field)`. We can't pass the (unaligned) field directly. I
696689 // think that ATM (Rust 1.16) we only pass temporaries, but we shouldn't
@@ -703,8 +696,6 @@ impl FunctionCx<'a, 'll, 'tcx> {
703696 ( llval, align, true )
704697 }
705698 }
706- UnsizedRef ( ..) =>
707- bug ! ( "codegen_argument: tried to pass unsized operand to sized argument" ) ,
708699 } ;
709700
710701 if by_ref && !arg. is_indirect ( ) {
@@ -740,13 +731,13 @@ impl FunctionCx<'a, 'll, 'tcx> {
740731 let tuple = self . codegen_operand ( bx, operand) ;
741732
742733 // Handle both by-ref and immediate tuples.
743- if let Ref ( llval, align) = tuple. val {
734+ if let Ref ( llval, None , align) = tuple. val {
744735 let tuple_ptr = PlaceRef :: new_sized ( llval, tuple. layout , align) ;
745736 for i in 0 ..tuple. layout . fields . count ( ) {
746737 let field_ptr = tuple_ptr. project_field ( bx, i) ;
747738 self . codegen_argument ( bx, field_ptr. load ( bx) , llargs, & args[ i] ) ;
748739 }
749- } else if let UnsizedRef ( .. ) = tuple. val {
740+ } else if let Ref ( _ , Some ( _ ) , _ ) = tuple. val {
750741 bug ! ( "closure arguments must be sized" )
751742 } else {
752743 // If the tuple is immediate, the elements are as well.
0 commit comments