I am working on a project to mark the source code of simple Rust programs with the Live, Dead, borrow, move, drop locations of each local. I believe this information is available in the MIR but I am struggling to extract the source code locations. For each function, I iterate through the local_decls and get the declaration location from span. However, the associated locations for live, borrow, move, and drop are basic block locations. The source code locations are included in the playground mir but not part of the body returned from optimized_mir. How do I get the source code location mapping of StorageLive, StorageDead, move and drop from the function body returned from optimized_mir()? I am new to Rust so apologize if I missed something obvious. Any suggestions, examples, links, repos are welcome and appreciated.
StorageDead and moves the
mir::Statement type has a
source_info field which in turn has a
span field representing the location of the statement. As for
Drop, this is a MIR terminator and as such you have a
mir::Terminator, which also has a
GitHub - willcrichton/flowistry: Flowistry is an IDE plugin for Rust that helps you focus on relevant code. is likely to have code snippets you need.
It is there (via
SourceInfo), as @bjorn3 pointed out.
The playground uses
--emit=mir which pretty-prints
optimized_mir - if you see something in textual MIR, it means it's available to the compiler.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.