@@ -30,24 +30,29 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
30
30
) -> EvalResult < ' tcx > {
31
31
trace ! ( "drop: {:?},\n {:?}, {:?}" , arg, ty. sty, instance. def) ;
32
32
33
- let instance = match ty. sty {
33
+ let ( instance, arg ) = match ty. sty {
34
34
ty:: TyDynamic ( ..) => {
35
- if let Value :: ScalarPair ( _, vtable) = arg {
36
- self . read_drop_type_from_vtable ( vtable. to_ptr ( ) ?) ?
35
+ if let Value :: ScalarPair ( ptr, vtable) = arg {
36
+ // Figure out the specific drop function to call, and just pass along
37
+ // the thin part of the pointer.
38
+ let instance = self . read_drop_type_from_vtable ( vtable. to_ptr ( ) ?) ?;
39
+ trace ! ( "Dropping via vtable: {:?}" , instance. def) ;
40
+ ( instance, Value :: Scalar ( ptr) )
37
41
} else {
38
42
bug ! ( "expected fat ptr, got {:?}" , arg) ;
39
43
}
40
44
}
41
- _ => instance,
45
+ _ => ( instance, arg ) ,
42
46
} ;
43
47
44
48
// the drop function expects a reference to the value
49
+ let fn_sig = self . tcx . fn_sig ( instance. def_id ( ) ) . skip_binder ( ) . clone ( ) ;
45
50
let arg = OpTy {
46
51
op : Operand :: Immediate ( arg) ,
47
- layout : self . layout_of ( self . tcx . mk_mut_ptr ( ty ) ) ?,
52
+ layout : self . layout_of ( fn_sig . output ( ) ) ?,
48
53
} ;
54
+ trace ! ( "Dropped type: {:?}" , fn_sig. output( ) ) ;
49
55
50
- let fn_sig = self . tcx . fn_sig ( instance. def_id ( ) ) . skip_binder ( ) . clone ( ) ;
51
56
// This should always be (), but getting it from the sig seems
52
57
// easier than creating a layout of ().
53
58
let dest = PlaceTy :: null ( & self , self . layout_of ( fn_sig. output ( ) ) ?) ;
0 commit comments