问题
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
torelease
according to your build mode.
来源:https://stackoverflow.com/questions/50426488/how-to-make-cargo-to-save-analysis