@@ -86,7 +86,7 @@ pub struct Frame<'tcx> {
86
86
/// This is pure interpreter magic and has nothing to do with how rustc does it
87
87
/// An example is calling an FnMut closure that has been converted to a FnOnce closure
88
88
/// If they are Value::ByRef, their memory will be freed when the stackframe finishes
89
- pub interpreter_temporaries : Vec < Value > ,
89
+ pub interpreter_temporaries : Vec < Pointer > ,
90
90
91
91
////////////////////////////////////////////////////////////////////////////////
92
92
// Current position within the function
@@ -333,7 +333,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
333
333
substs : & ' tcx Substs < ' tcx > ,
334
334
return_lvalue : Lvalue < ' tcx > ,
335
335
return_to_block : StackPopCleanup ,
336
- temporaries : Vec < Value > ,
336
+ temporaries : Vec < Pointer > ,
337
337
) -> EvalResult < ' tcx , ( ) > {
338
338
:: log_settings:: settings ( ) . indentation += 1 ;
339
339
@@ -393,8 +393,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
393
393
StackPopCleanup :: None => { } ,
394
394
}
395
395
// deallocate all locals that are backed by an allocation
396
- for local in frame. locals . into_iter ( ) . filter_map ( |l| l) . chain ( frame. interpreter_temporaries ) {
397
- if let Value :: ByRef ( ptr) = local {
396
+ for local in frame. locals . into_iter ( ) {
397
+ if let Some ( Value :: ByRef ( ptr) ) = local {
398
+ trace ! ( "deallocating local" ) ;
398
399
self . memory . dump ( ptr. alloc_id ) ;
399
400
match self . memory . deallocate ( ptr) {
400
401
// Any frozen memory means that it belongs to a constant or something referenced
@@ -406,6 +407,12 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
406
407
}
407
408
}
408
409
}
410
+ // deallocate all temporary allocations
411
+ for ptr in frame. interpreter_temporaries {
412
+ trace ! ( "deallocating temporary allocation" ) ;
413
+ self . memory . dump ( ptr. alloc_id ) ;
414
+ self . memory . deallocate ( ptr) ?;
415
+ }
409
416
Ok ( ( ) )
410
417
}
411
418
0 commit comments