@@ -22,9 +22,9 @@ pub trait Value<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>>: Copy
22
22
fn layout ( & self ) -> TyLayout < ' tcx > ;
23
23
24
24
// Make this a `MPlaceTy`, or panic if that's not possible.
25
- fn force_allocation (
25
+ fn to_mem_place (
26
26
self ,
27
- ectx : & mut EvalContext < ' a , ' mir , ' tcx , M > ,
27
+ ectx : & EvalContext < ' a , ' mir , ' tcx , M > ,
28
28
) -> EvalResult < ' tcx , MPlaceTy < ' tcx , M :: PointerTag > > ;
29
29
30
30
// Create this from an `MPlaceTy`.
@@ -55,9 +55,9 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Value<'a, 'mir, 'tcx, M>
55
55
}
56
56
57
57
#[ inline( always) ]
58
- fn force_allocation (
58
+ fn to_mem_place (
59
59
self ,
60
- _ectx : & mut EvalContext < ' a , ' mir , ' tcx , M > ,
60
+ _ectx : & EvalContext < ' a , ' mir , ' tcx , M > ,
61
61
) -> EvalResult < ' tcx , MPlaceTy < ' tcx , M :: PointerTag > > {
62
62
Ok ( self . to_mem_place ( ) )
63
63
}
@@ -94,9 +94,9 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Value<'a, 'mir, 'tcx, M>
94
94
}
95
95
96
96
#[ inline( always) ]
97
- fn force_allocation (
97
+ fn to_mem_place (
98
98
self ,
99
- _ectx : & mut EvalContext < ' a , ' mir , ' tcx , M > ,
99
+ _ectx : & EvalContext < ' a , ' mir , ' tcx , M > ,
100
100
) -> EvalResult < ' tcx , MPlaceTy < ' tcx , M :: PointerTag > > {
101
101
Ok ( self )
102
102
}
@@ -133,11 +133,12 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Value<'a, 'mir, 'tcx, M>
133
133
}
134
134
135
135
#[ inline( always) ]
136
- fn force_allocation (
136
+ fn to_mem_place (
137
137
self ,
138
- ectx : & mut EvalContext < ' a , ' mir , ' tcx , M > ,
138
+ ectx : & EvalContext < ' a , ' mir , ' tcx , M > ,
139
139
) -> EvalResult < ' tcx , MPlaceTy < ' tcx , M :: PointerTag > > {
140
- ectx. force_allocation ( self )
140
+ // If this refers to a local, assert that it already has an allocation.
141
+ Ok ( ectx. place_to_op ( self ) ?. to_mem_place ( ) )
141
142
}
142
143
143
144
#[ inline( always) ]
@@ -243,7 +244,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
243
244
match v. layout ( ) . ty . sty {
244
245
ty:: Dynamic ( ..) => {
245
246
// immediate trait objects are not a thing
246
- let dest = v. value ( ) . force_allocation ( self ) ?;
247
+ let dest = v. value ( ) . to_mem_place ( self ) ?;
247
248
let inner = self . unpack_dyn_trait ( dest) ?. 1 ;
248
249
trace ! ( "dyn object layout: {:#?}" , inner. layout) ;
249
250
// recurse with the inner type
@@ -310,7 +311,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
310
311
MPlaceTy :: dangling ( v. layout ( ) , self )
311
312
} else {
312
313
// non-ZST array/slice/str cannot be immediate
313
- v. value ( ) . force_allocation ( self ) ?
314
+ v. value ( ) . to_mem_place ( self ) ?
314
315
} ;
315
316
// Now iterate over it.
316
317
for ( i, field) in self . mplace_array_fields ( mplace) ?. enumerate ( ) {
0 commit comments