willcrichton / flowistry

Flowistry is an IDE plugin for Rust that helps you focus on relevant code.
https://marketplace.visualstudio.com/items?itemName=wcrichton.flowistry
MIT License
1.91k stars 45 forks source link

Improve precision for boxes #71

Open momvart opened 1 year ago

momvart commented 1 year ago

Boxes provide the simplest form of heap allocation in Rust. However, because they own a pointer, flowistry conservatively considers a maximum (unknown) region for them causing all of them to be grouped under a single alias group. This behavior seems to be an exception, which can be rooted here. https://github.com/willcrichton/flowistry/blob/a156ab9839b9e84fe9e178ce16937e98d13613b5/crates/flowistry/src/mir/utils.rs#L613-L614

As Boxes are probably the most-used structure for heap allocation, improving the precision of the analysis for them and avoiding reasoning about the pointer inside them can help a lot. It also affects the results for other types such as vectors when they use boxes. (e.g., using into_boxed_slice or some forms of vec! macro).