Description
Analyzing profiles on my latest branch, it appears that approximately 4% of total compilation time is spent managing the "causal hash map":
rust/src/librustc_mir/borrow_check/nll/region_infer/values.rs
Lines 187 to 191 in 01dbfda
Currently, that map is only non-None for the "liveness" set, which stores, for each region variable R, each point P where R is directly live (meaning typically that there is some local variable X that has R in its type and which may be used at some point Q reachable from P). The "cause" tracks basically this point Q. It's accessed later when constructing error messages, here:
rust/src/librustc_mir/borrow_check/nll/region_infer/mod.rs
Lines 1067 to 1068 in 01dbfda
We should remove the causal hashmap altogether. Instead, when constructing an error, we can do a BFS over the MIR graph from elem
(a Location
), looking for points that may use the region region_sub
that we are interested in.