Skip to content
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

Stop using driver queries in the public API #134130

Merged
merged 4 commits into from
Dec 14, 2024

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Dec 10, 2024

Follow up to #132410 and #133567

The next PR will completely get rid of driver queries. That PR will also contains some non-trivial refactorings enabled by no longer needing to support entering TyCtxt multiple times after it is constructed. The changes in the current PR have been split out to make it easier to review the api changes and to reduce the size of the next PR to review.

Custom driver breaking change

The after_crate_root_parsing and after_expansion callbacks now accept ast::Crate and TyCtxt respectively rather than Queries. The only safe query in Queries to call inside these callbacks are parse() and global_ctxt() respectively which allows you to access the ast::Crate and TyCtxt either way. To fix your custom driver, replace the queries: &'tcx Queries<'tcx> argument with crate_: ast::Crate and tcx: TyCtxt<'tcx> respectively and for after_expansion remove your queries.global_ctxt().unwrap().enter(|tcx| { ... }) call and only keep the contents of the closure.

@bjorn3 bjorn3 added the A-driver Area: rustc_driver that ties everything together into the `rustc` compiler label Dec 10, 2024
@rustbot
Copy link
Collaborator

rustbot commented Dec 10, 2024

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 Dec 10, 2024
@rust-log-analyzer

This comment has been minimized.

@jieyouxu jieyouxu 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 Dec 10, 2024
@bjorn3 bjorn3 force-pushed the prepare_driver_query_removal branch from a5914c8 to 7e37943 Compare December 12, 2024 11:15
@bjorn3
Copy link
Member Author

bjorn3 commented Dec 12, 2024

@rustbot ready

@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 Dec 12, 2024
@oli-obk
Copy link
Contributor

oli-obk commented Dec 12, 2024

r? @oli-obk

bors r plus

@bors
Copy link
Contributor

bors commented Dec 12, 2024

📌 Commit 7e37943 has been approved by oli-obk

It is now in the queue for this repository.

@rustbot rustbot assigned oli-obk and unassigned Nadrieril Dec 12, 2024
@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 Dec 12, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 13, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#133900 (Advent of `tests/ui` (misc cleanups and improvements) [1/N])
 - rust-lang#133937 (Keep track of parse errors in `mod`s and don't emit resolve errors for paths involving them)
 - rust-lang#133938 (`rustc_mir_dataflow` cleanups, including some renamings)
 - rust-lang#134058 (interpret: reduce usage of TypingEnv::fully_monomorphized)
 - rust-lang#134130 (Stop using driver queries in the public API)
 - rust-lang#134140 (Add AST support for unsafe binders)
 - rust-lang#134229 (Fix typos in docs on provenance)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 13, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#133900 (Advent of `tests/ui` (misc cleanups and improvements) [1/N])
 - rust-lang#133937 (Keep track of parse errors in `mod`s and don't emit resolve errors for paths involving them)
 - rust-lang#133938 (`rustc_mir_dataflow` cleanups, including some renamings)
 - rust-lang#134058 (interpret: reduce usage of TypingEnv::fully_monomorphized)
 - rust-lang#134130 (Stop using driver queries in the public API)
 - rust-lang#134140 (Add AST support for unsafe binders)
 - rust-lang#134229 (Fix typos in docs on provenance)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9f6b07e into rust-lang:master Dec 14, 2024
6 checks passed
@rustbot rustbot added this to the 1.85.0 milestone Dec 14, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 14, 2024
Rollup merge of rust-lang#134130 - bjorn3:prepare_driver_query_removal, r=oli-obk

Stop using driver queries in the public API

Follow up to rust-lang#132410 and rust-lang#133567

The next PR will completely get rid of driver queries. That PR will also contains some non-trivial refactorings enabled by no longer needing to support entering TyCtxt multiple times after it is constructed. The changes in the current PR have been split out to make it easier to review the api changes and to reduce the size of the next PR to review.

## Custom driver breaking change

The `after_crate_root_parsing` and `after_expansion` callbacks now accept `ast::Crate` and `TyCtxt` respectively rather than `Queries`. The only safe query in `Queries` to call inside these callbacks are `parse()` and `global_ctxt()` respectively which allows you to access the `ast::Crate` and `TyCtxt` either way. To fix your custom driver, replace the `queries: &'tcx Queries<'tcx>` argument with `crate_: ast::Crate` and `tcx: TyCtxt<'tcx>` respectively and for `after_expansion` remove your `queries.global_ctxt().unwrap().enter(|tcx| { ... })` call and only keep the contents of the closure.
@bjorn3 bjorn3 deleted the prepare_driver_query_removal branch December 14, 2024 08:37
flip1995 pushed a commit to flip1995/rust that referenced this pull request Dec 15, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#133900 (Advent of `tests/ui` (misc cleanups and improvements) [1/N])
 - rust-lang#133937 (Keep track of parse errors in `mod`s and don't emit resolve errors for paths involving them)
 - rust-lang#133938 (`rustc_mir_dataflow` cleanups, including some renamings)
 - rust-lang#134058 (interpret: reduce usage of TypingEnv::fully_monomorphized)
 - rust-lang#134130 (Stop using driver queries in the public API)
 - rust-lang#134140 (Add AST support for unsafe binders)
 - rust-lang#134229 (Fix typos in docs on provenance)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-driver Area: rustc_driver that ties everything together into the `rustc` compiler S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants