Find where the closure is defined rather than called, including the closure instance and the arg. e.g., let mut _20: [closure@src/main.rs:13:28: 16:6]; _20 is of type Closure, but it is actually the arg that captures the variables in the defining function.
(&mut self, local: Local, local_decl: &LocalDecl<'tcx>)
| 229 | /// e.g., let mut _20: [closure@src/main.rs:13:28: 16:6]; |
| 230 | /// |
| 231 | /// _20 is of type Closure, but it is actually the arg that captures |
| 232 | /// the variables in the defining function. |
| 233 | fn visit_local_decl(&mut self, local: Local, local_decl: &LocalDecl<'tcx>) { |
| 234 | let func_ty = self.caller.instantiate_mir_and_normalize_erasing_regions( |
| 235 | self.tcx, |
| 236 | self.typing_env, |
| 237 | EarlyBinder::bind(local_decl.ty), |
| 238 | ); |
| 239 | if let TyKind::Closure(def_id, substs) = func_ty.kind() { |
| 240 | match self.body.local_kind(local) { |
| 241 | LocalKind::Arg | LocalKind::ReturnPointer => {} |
| 242 | _ => { |
| 243 | if let Some(callee_instance) = |
| 244 | Instance::try_resolve(self.tcx, self.typing_env, *def_id, substs) |
| 245 | .ok() |
| 246 | .flatten() |
| 247 | { |
| 248 | self.callsites |
| 249 | .push((callee_instance, CallSiteLocation::ClosureDef(local, None))); |
| 250 | } |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | self.super_local_decl(local, local_decl); |
| 255 | } |
| 256 | } |
nothing calls this directly
no outgoing calls
no test coverage detected