rustc_mir_dataflow/
debuginfo.rs

1use rustc_index::bit_set::DenseBitSet;
2use rustc_middle::mir::visit::*;
3use rustc_middle::mir::*;
4
5/// Return the set of locals that appear in debuginfo.
6pub fn debuginfo_locals(body: &Body<'_>) -> DenseBitSet<Local> {
7    let mut visitor = DebuginfoLocals(DenseBitSet::new_empty(body.local_decls.len()));
8    for debuginfo in body.var_debug_info.iter() {
9        visitor.visit_var_debug_info(debuginfo);
10    }
11    visitor.0
12}
13
14struct DebuginfoLocals(DenseBitSet<Local>);
15
16impl Visitor<'_> for DebuginfoLocals {
17    fn visit_local(&mut self, local: Local, _: PlaceContext, _: Location) {
18        self.0.insert(local);
19    }
20}