Skip to content

Make the rustc driver and interface demand driven#56732

Merged
bors merged 1 commit intorust-lang:masterfrom
Zoxc:rustc-interface
Mar 10, 2019
Merged

Make the rustc driver and interface demand driven#56732
bors merged 1 commit intorust-lang:masterfrom
Zoxc:rustc-interface

Conversation

@Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Dec 12, 2018

This introduces a new crate rustc_interface which is the canonical interface for creating and using the compiler. It allows you to access a Compiler type in a closure and that types have methods to run passes on demand. The interesting parts are found here (defining the queries) and here (methods to create a Compiler).

cc @rust-lang/compiler @rust-lang/dev-tools @rust-lang/rustdoc

@rust-highfive
Copy link
Contributor

r? @estebank

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 12, 2018
@rust-highfive

This comment has been minimized.

@bors

This comment has been minimized.

@Dylan-DPC-zz

This comment has been minimized.

@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 14, 2019
@rust-highfive

This comment has been minimized.

@Zoxc Zoxc force-pushed the rustc-interface branch 2 times, most recently from 6a75222 to 32b4fb5 Compare January 20, 2019 08:01
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Jan 21, 2019

Since this will impact rls, clippy and miri quite strongly, could you open PRs against them showing how those changes will impact them?

I would assume rls and miri to be easy (since they don't change compilation and just need access to the TyCtxt to start their business), but clippy inserts new lints, which I'm not sure how to do with the new interface (looks to me like rustdoc has the same problem, but the FIXME shows that you are aware of this already).

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@bors

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@bors

This comment has been minimized.

@Zoxc
Copy link
Contributor Author

Zoxc commented Mar 10, 2019

@bors r=oli-obk

@bors
Copy link
Collaborator

bors commented Mar 10, 2019

📌 Commit 51938c6 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 10, 2019
@bors
Copy link
Collaborator

bors commented Mar 10, 2019

⌛ Testing commit 51938c6 with merge 913ad6d...

bors added a commit that referenced this pull request Mar 10, 2019
Make the rustc driver and interface demand driven

This introduces a new crate `rustc_interface` which is the canonical interface for creating and using the compiler. It allows you to access a `Compiler` type in a closure and that types have methods to run passes on demand. The interesting parts are found [here (defining the queries)](https://github.com/Zoxc/rust/blob/rustc-interface/src/librustc_interface/queries.rs#L78) and [here (methods to create a `Compiler`)](https://github.com/Zoxc/rust/blob/rustc-interface/src/librustc_interface/interface.rs).

cc @rust-lang/compiler @rust-lang/dev-tools @rust-lang/rustdoc
@bors
Copy link
Collaborator

bors commented Mar 10, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: oli-obk
Pushing 913ad6d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 10, 2019
@bors bors merged commit 51938c6 into rust-lang:master Mar 10, 2019
@rust-highfive
Copy link
Contributor

📣 Toolstate changed by #56732!

Tested on commit 913ad6d.
Direct link to PR: #56732

💔 clippy-driver on windows: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk @phansch, @rust-lang/infra).
💔 clippy-driver on linux: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk @phansch, @rust-lang/infra).
💔 miri on windows: test-pass → build-fail (cc @oli-obk @RalfJung @eddyb, @rust-lang/infra).
💔 miri on linux: test-pass → build-fail (cc @oli-obk @RalfJung @eddyb, @rust-lang/infra).
💔 rls on windows: test-pass → build-fail (cc @nrc @Xanewok, @rust-lang/infra).
💔 rls on linux: test-pass → build-fail (cc @nrc @Xanewok, @rust-lang/infra).

@Manishearth
Copy link
Member

I'm not entirely clear on how this changes the driver -- mind patching clippy's driver to work again? Use rustup-toolchain-install-master -n master -f to get a master toolchain so that you can build clippy.

I think what we need to do is invoke parsing, attach the lints, and then continue with compilation. But I'm not sure.

Overall it seems like this makes the driver API more brittle since driver consumers need to know what steps to invoke (as opposed to running the driver with some callbacks, where any change in the compilation process can still be picked up by clippy). There aren't many consumers of the driver interface, but this was supposed to be the path forward for things like clippy. Perhaps an interface which is "does the rustc compilation steps, but with callbacks" can still be exposed?

@Zoxc
Copy link
Contributor Author

Zoxc commented Mar 10, 2019

@Manishearth
Copy link
Member

Oh, I didn't notice that, thanks so much!

While trying to implement this I didn't realize Callbacks existed now, I retract my objection about the driver api being more brittle 😄

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

Labels

merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.