How to get lifetime information

I want to write a program that needs to get the lifetime of any variable to do some analysis. The lifetime info needs to be reversed to the position in the source code. Is there any API in rustc or other tools (maybe RLS) that can do it? Thanks.

1 Like

Can you specify what you're trying to accomplish? A lifetime does not always have a meaningful correspondence to some span of code, and is more closely related to the control flow graph.