Background
I'm writing a custom analysis pass within rustc_driver::Callbacks::after_analysis().
Goal
Given an HirId of a block, I would like to collect DefId of functions that are called inside the block.
Current Status
- I'm traversing HIR expressions inside the target block and check if
ExprKindisCallorMethodCall. -
rustc_documentation recommends to use
qpath_res()forCall(Path(...), ...)andtype_dependent_def_id()forMethodCall(...)to get theDefIdof the callee. Both methods are defined onTypeckResults. - (blocked here) I'm not sure how to get the corresponding
TypeckResultsfor those expressions. I have an access to the global contextTyCtxt<'tcx>.