New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilise `-Zsave-analysis` #43606

Open
nrc opened this Issue Aug 2, 2017 · 9 comments

Comments

Projects
None yet
7 participants
@nrc
Member

nrc commented Aug 2, 2017

-Z flags are now unstable. However, we plan to use save-analysis info for the RLS and Rustdoc and we want these to work on stable compilers. Therefore, we need a stable flag. Options:

  • --save-analysis
  • --emit analysis or analysis-info or analysis-data or whatever
  • Keep the -Z flag and give tools a loophole to use it on stable

I propose that the existence of the flag is stable, but that we make no guarantees about the output when using the flag. We might consider guaranteeing that the output is valid JSON (but that includes {}). We could promise that the shape of the ouput won't change, but I'd rather not.

@nrc nrc changed the title from Stabilise -Zsave-analysis to Stabilise `-Zsave-analysis` Aug 2, 2017

@nrc

This comment has been minimized.

Member

nrc commented Aug 3, 2017

Another alternative is that the RLS and Rustdoc could use a custom compiler driver. This would mean we would not need a stable CL flag. This seems fine for the RLS (it would mean a marginally more complex build, but nothing too serious) but would mean some extra work for Rustdoc and mean it would only work if distributed with Rustdoc.

(Motivation for avoiding a stable flag is to prevent other users using the save-analysis data and it becoming de facto stable).

@steveklabnik

This comment has been minimized.

Member

steveklabnik commented Aug 4, 2017

What does "custom compiler driver" mean exactly?

@oli-obk

This comment has been minimized.

Contributor

oli-obk commented Aug 4, 2017

It means that you are using rustc as a library. So instead of extending rustc via plugins, you are writing your own rustc binary (but you are reusing all of the boilerplate offered by the rustc_driver that rustc itself uses). You basically end up implementing a small trait, forwarding all methods to rustc's default implementation, and injecting your own code at the appropriate locations.

@nrc

This comment has been minimized.

Member

nrc commented Aug 8, 2017

I've implemented a shim at https://github.com/nrc/rls-rustc I have a couple more features to add, but this should be a drop-in replacement for rustc for the RLS and rustdoc. I'll leave this issue open until we confirm this approach works, but I think we don't need to stabilise -Zsave-analysis any more.

@staktrace

This comment has been minimized.

Contributor

staktrace commented Jan 23, 2018

@nrc: can you explain how to go about using this wrapper? In particular I'm looking to do a mozilla-central build on taskcluster with save-analysis turned on. Right now I can do this easily by using a rust nightly toolchain and export RUSTFLAGS="-Zsave-analysis". It's not clear to me how I would plug in this wrapper though. (FWIW I would still prefer stabilizing the save-analysis option into rust stable)

@nrc

This comment has been minimized.

Member

nrc commented Jan 29, 2018

You should just be able to make an executable which looks like:

extern crate rls_rustc;

fn main() {
    rls_rustc::run();
}

And then run that executable as a drop-in replacement for rustc.

@nrc

This comment has been minimized.

Member

nrc commented Jan 29, 2018

@staktrace

This comment has been minimized.

Contributor

staktrace commented Jan 29, 2018

@nrc Thanks. I think hooking that into taskcluster is probably nontrivial (at least for me) as I would have to create a custom toolchain and override the compiler being used. I think for now I'll continue using the nightly rustc since that's easier and I have it working, but I would still really like having the -Zsave-analysis option in rust stable.

@ishitatsuyuki

This comment has been minimized.

Member

ishitatsuyuki commented Jul 17, 2018

I think we should not make any guarantee of the analysis format, however it worths to expose a lib like rls-analysis bundled with the compiler distribution. It would start with a small subset of types, expanding as we decide, similar to what proc-macro has been.

Stabilising this allows us to have documentation generators other than rustdoc, for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment