@@ -130,14 +130,28 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
130
130
131
131
#[ derive( Copy , Clone , Debug , PartialEq ) ]
132
132
enum Adjustment {
133
+ /// Pass the receiver as-is.
133
134
Identity ,
135
+
136
+ /// We get passed `&[mut] self` and call the target with `*self`.
137
+ ///
138
+ /// This either copies `self` (if `Self: Copy`, eg. for function items), or moves out of it
139
+ /// (for `VtableShim`, which effectively is passed `&own Self`).
134
140
Deref ,
141
+
142
+ /// We get passed `self: Self` and call the target with `&mut self`.
143
+ ///
144
+ /// In this case we need to ensure that the `Self` is dropped after the call, as the callee
145
+ /// won't do it for us.
135
146
RefMut ,
136
147
}
137
148
138
149
#[ derive( Copy , Clone , Debug , PartialEq ) ]
139
150
enum CallKind {
151
+ /// Call the `FnPtr` that was passed as the receiver.
140
152
Indirect ,
153
+
154
+ /// Call a known `FnDef`.
141
155
Direct ( DefId ) ,
142
156
}
143
157
@@ -722,7 +736,10 @@ fn build_call_shim<'tcx>(
722
736
} ) ;
723
737
724
738
let ( callee, mut args) = match call_kind {
739
+ // `FnPtr` call has no receiver. Args are untupled below.
725
740
CallKind :: Indirect => ( rcvr. unwrap ( ) , vec ! [ ] ) ,
741
+
742
+ // `FnDef` call with optional receiver.
726
743
CallKind :: Direct ( def_id) => {
727
744
let ty = tcx. type_of ( def_id) ;
728
745
(
0 commit comments