@@ -32,7 +32,7 @@ use syntax_pos::Pos;
32
32
use super::{FunctionCx, LocalRef};
33
33
use super::place::PlaceRef;
34
34
use super::operand::OperandRef;
35
- use super::operand::OperandValue::{Pair, Ref, UnsizedRef, Immediate};
35
+ use super::operand::OperandValue::{Pair, Ref, Immediate};
36
36
37
37
impl FunctionCx<'a, 'll, 'tcx> {
38
38
pub fn codegen_block(&mut self, bb: mir::BasicBlock) {
@@ -232,10 +232,8 @@ impl FunctionCx<'a, 'll, 'tcx> {
232
232
233
233
PassMode::Direct(_) | PassMode::Pair(..) => {
234
234
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 {
236
236
bx.load(llval, align)
237
- } else if let UnsizedRef(..) = op.val {
238
- bug!("return type must be sized");
239
237
} else {
240
238
op.immediate_or_packed_pair(&bx)
241
239
}
@@ -247,7 +245,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
247
245
LocalRef::Operand(None) => bug!("use of return before def"),
248
246
LocalRef::Place(cg_place) => {
249
247
OperandRef {
250
- val: Ref(cg_place.llval, cg_place.align),
248
+ val: Ref(cg_place.llval, None, cg_place.align),
251
249
layout: cg_place.layout
252
250
}
253
251
}
@@ -259,12 +257,11 @@ impl FunctionCx<'a, 'll, 'tcx> {
259
257
op.val.store(&bx, scratch);
260
258
scratch.llval
261
259
}
262
- Ref(llval, align) => {
260
+ Ref(llval, _, align) => {
263
261
assert_eq!(align.abi(), op.layout.align.abi(),
264
262
"return place is unaligned!");
265
263
llval
266
264
}
267
- UnsizedRef(..) => bug!("return type must be sized"),
268
265
};
269
266
bx.load(
270
267
bx.pointercast(llslot, cast_ty.llvm_type(bx.cx).ptr_to()),
@@ -605,15 +602,11 @@ impl FunctionCx<'a, 'll, 'tcx> {
605
602
// The callee needs to own the argument memory if we pass it
606
603
// by-ref, so make a local copy of non-immediate constants.
607
604
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, _ )) => {
610
607
let tmp = PlaceRef::alloca(&bx, op.layout, "const");
611
608
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);
617
610
}
618
611
_ => {}
619
612
}
@@ -667,7 +660,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
667
660
}
668
661
} else if arg.is_unsized_indirect() {
669
662
match op.val {
670
- UnsizedRef (a, b ) => {
663
+ Ref (a, Some(b), _ ) => {
671
664
llargs.push(a);
672
665
llargs.push(b);
673
666
return;
@@ -690,7 +683,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
690
683
}
691
684
}
692
685
}
693
- Ref(llval, align) => {
686
+ Ref(llval, _, align) => {
694
687
if arg.is_indirect() && align.abi() < arg.layout.align.abi() {
695
688
// `foo(packed.large_field)`. We can't pass the (unaligned) field directly. I
696
689
// think that ATM (Rust 1.16) we only pass temporaries, but we shouldn't
@@ -703,8 +696,6 @@ impl FunctionCx<'a, 'll, 'tcx> {
703
696
(llval, align, true)
704
697
}
705
698
}
706
- UnsizedRef(..) =>
707
- bug!("codegen_argument: tried to pass unsized operand to sized argument"),
708
699
};
709
700
710
701
if by_ref && !arg.is_indirect() {
@@ -740,13 +731,13 @@ impl FunctionCx<'a, 'll, 'tcx> {
740
731
let tuple = self.codegen_operand(bx, operand);
741
732
742
733
// Handle both by-ref and immediate tuples.
743
- if let Ref(llval, align) = tuple.val {
734
+ if let Ref(llval, None, align) = tuple.val {
744
735
let tuple_ptr = PlaceRef::new_sized(llval, tuple.layout, align);
745
736
for i in 0..tuple.layout.fields.count() {
746
737
let field_ptr = tuple_ptr.project_field(bx, i);
747
738
self.codegen_argument(bx, field_ptr.load(bx), llargs, &args[i]);
748
739
}
749
- } else if let UnsizedRef(.. ) = tuple.val {
740
+ } else if let Ref(_, Some(_), _ ) = tuple.val {
750
741
bug!("closure arguments must be sized")
751
742
} else {
752
743
// If the tuple is immediate, the elements are as well.
0 commit comments