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
ExprKind
isCall
orMethodCall
. -
rustc_documentation recommends to use
qpath_res()
forCall(Path(...), ...)
andtype_dependent_def_id()
forMethodCall(...)
to get theDefId
of the callee. Both methods are defined onTypeckResults
. - (blocked here) I'm not sure how to get the corresponding
TypeckResults
for those expressions. I have an access to the global contextTyCtxt<'tcx>
.