How to make cargo to save-analysis?

扶醉桌前 提交于 2019-12-02 08:56:31

问题


How can I make cargo to save-analysis? I know that I can do this with rustc by calling

rustc -Zsave-snalysis <files...>

But, I couldn't figure out for cargo. And also I like to know how I can read them back to rls_analysis data structures.

I tried cargo rustc -Zsave-analysis, but it doesn't seem to work.

I also tried export RUSTC_SAVE_ANALYSIS=api, no work too.

What I want to do is getting fully qualified path (e.g. ::foo1::foo2::Foo3) to the types notated in source code. If there's other solution, please let me know that too.


回答1:


Just do this before calling cargo build.

export RUSTFLAGS="-Z save-analysis"

Update

Saved analysis data won't be loaded with default configuration of AnalysisHost. It's because CargoAnalysisLoader tries to load data from non-default location.

To workaround, just move save-analysis directory to proper location.

target/debug/deps/save-analysis
target/rls/debug/deps/save-analysis
  • Replace debug to release according to your build mode.


来源:https://stackoverflow.com/questions/50426488/how-to-make-cargo-to-save-analysis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!