Hi all,
I am trying to get the borrow checker results. I use rustc_driver::RunCompiler::new with a customized rustc_driver::Callbacks::after_analysis. Inside after_analysis, I call mir_borrowck like this
let local_def_id = ... // get the local_def_id of the function...
tcx.ensure().mir_borrowck(local_def_id);
let bc_result = tcx.mir_borrowck(local_def_id);
info!("borrow checker result: {:?}", bc_result);
But the bc_result is always a dummy value BorrowCheckResult { concrete_opaque_types: {}, closure_requirements: None, used_mut_upvars: [], tainted_by_errors: None }.
Any insight as to why that's the case? I can try to come up with a minimal reproducible example if needed.
EDIT: I've found what I missed there. The actual API should be used is like
use rustc_borrowck::consumers::{
get_body_with_borrowck_facts, ConsumerOptions::PoloniusOutputFacts,
};
let bc_result = get_body_with_borrowck_facts(tcx, local_def_id, PoloniusOutputFacts);
I will leave the post as it is if it might be useful for anyone else hitting into the same issue.