More refactorings to rustc_interface by bjorn3 · Pull Request #127184 · rust-lang/rust (original) (raw)

bjorn3

@bjorn3

@rustbot

r? @Nadrieril

rustbot has assigned @Nadrieril.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-compiler

Relevant to the compiler team, which will review and decide on the PR/issue.

labels

Jun 30, 2024

@bjorn3

This doesn't yet remove driver queries entirely as I'm not sure how to deal with the various finalization things in Compiler::enter. Shifting the responsibility to call them to custom drivers seems like it would be forgotten too easily.

@rust-log-analyzer

This comment has been minimized.

@Nadrieril

Looks good, just a test to update.

I'm curious: what do you mean by "remove driver queries"?

@bjorn3

The methods on https://doc.rust-lang.org/nightly/nightly-rustc/rustc_interface/struct.Queries.html are what I call driver queries. Just like the queries in TyCtxt they are cached after their first call, but they are not serialized in the incr comp cache. They are purely interacted with by rustc_driver_impl and custom drivers. IMO they complicate things as it makes it easy for custom drivers to create the TyCtxt or HIR before the driver callback where you are supposed to access these, skipping various driver steps. In fact most custom drivers I have seen make this mistake at least once.

@Nadrieril

I see, thanks! Pretty sure I've done that myself :>

@Nadrieril Nadrieril 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

Jun 30, 2024

@bjorn3

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Jul 1, 2024

@rust-log-analyzer

This comment has been minimized.

@Nadrieril

@bors

📌 Commit f276459 has been approved by Nadrieril

It is now in the queue for this repository.

@bors

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

@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

Jul 2, 2024

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Jul 2, 2024

@matthiaskrgr

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jul 3, 2024

@bors

…iaskrgr

Rollup of 9 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jul 3, 2024

@bors

…iaskrgr

Rollup of 9 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jul 3, 2024

@bors

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Jul 4, 2024

@rust-timer

@bjorn3 bjorn3 deleted the interface_refactor2 branch

July 4, 2024 06:40

joboet added a commit to joboet/rust that referenced this pull request

Nov 27, 2024

@joboet

…_round, r=cjgillot

Some more refactorings towards removing driver queries

Follow up to rust-lang#127184

Custom driver breaking change

The after_analysis callback is changed to accept TyCtxt instead of Queries. The only safe query in Queries to call at this point is global_ctxt() which allows you to enter the TyCtxt either way. To fix your custom driver, replace the queries: &'tcx Queries<'tcx> argument with tcx: TyCtxt<'tcx> and remove your queries.global_ctxt().unwrap().enter(|tcx| { ... }) call and only keep the contents of the closure.

Custom driver deprecation

The after_crate_root_parsing callback is now deprecated. Several custom drivers are incorrectly calling queries.global_ctxt() from inside of it, which causes some driver code to be skipped. As such I would like to either remove it in the future or if custom drivers still need it, change it to accept an &rustc_ast::Crate instead.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Nov 27, 2024

@matthiaskrgr

…_round, r=cjgillot

Some more refactorings towards removing driver queries

Follow up to rust-lang#127184

Custom driver breaking change

The after_analysis callback is changed to accept TyCtxt instead of Queries. The only safe query in Queries to call at this point is global_ctxt() which allows you to enter the TyCtxt either way. To fix your custom driver, replace the queries: &'tcx Queries<'tcx> argument with tcx: TyCtxt<'tcx> and remove your queries.global_ctxt().unwrap().enter(|tcx| { ... }) call and only keep the contents of the closure.

Custom driver deprecation

The after_crate_root_parsing callback is now deprecated. Several custom drivers are incorrectly calling queries.global_ctxt() from inside of it, which causes some driver code to be skipped. As such I would like to either remove it in the future or if custom drivers still need it, change it to accept an &rustc_ast::Crate instead.

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Nov 28, 2024

@rust-timer

Rollup merge of rust-lang#132410 - bjorn3:yet_another_driver_refactor_round, r=cjgillot

Some more refactorings towards removing driver queries

Follow up to rust-lang#127184

Custom driver breaking change

The after_analysis callback is changed to accept TyCtxt instead of Queries. The only safe query in Queries to call at this point is global_ctxt() which allows you to enter the TyCtxt either way. To fix your custom driver, replace the queries: &'tcx Queries<'tcx> argument with tcx: TyCtxt<'tcx> and remove your queries.global_ctxt().unwrap().enter(|tcx| { ... }) call and only keep the contents of the closure.

Custom driver deprecation

The after_crate_root_parsing callback is now deprecated. Several custom drivers are incorrectly calling queries.global_ctxt() from inside of it, which causes some driver code to be skipped. As such I would like to either remove it in the future or if custom drivers still need it, change it to accept an &rustc_ast::Crate instead.

github-actions bot pushed a commit to rust-lang/miri that referenced this pull request

Nov 28, 2024

@matthiaskrgr

…=cjgillot

Some more refactorings towards removing driver queries

Follow up to rust-lang/rust#127184

Custom driver breaking change

The after_analysis callback is changed to accept TyCtxt instead of Queries. The only safe query in Queries to call at this point is global_ctxt() which allows you to enter the TyCtxt either way. To fix your custom driver, replace the queries: &'tcx Queries<'tcx> argument with tcx: TyCtxt<'tcx> and remove your queries.global_ctxt().unwrap().enter(|tcx| { ... }) call and only keep the contents of the closure.

Custom driver deprecation

The after_crate_root_parsing callback is now deprecated. Several custom drivers are incorrectly calling queries.global_ctxt() from inside of it, which causes some driver code to be skipped. As such I would like to either remove it in the future or if custom drivers still need it, change it to accept an &rustc_ast::Crate instead.