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

Some more refactorings towards removing driver queries #132410

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

bjorn3
Copy link
Member

@bjorn3 bjorn3 commented Oct 31, 2024

Follow up to #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.

@rustbot
Copy link
Collaborator

rustbot commented Oct 31, 2024

r? @pnkfelix

rustbot has assigned @pnkfelix.
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 A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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 Oct 31, 2024
@rustbot
Copy link
Collaborator

rustbot commented Oct 31, 2024

The Miri subtree was changed

cc @rust-lang/miri

@jieyouxu
Copy link
Member

Probably compat relnotes for custom drivers?

@bjorn3
Copy link
Member Author

bjorn3 commented Oct 31, 2024

Probably compat relnotes for custom drivers?

Custom drivers are unstable and by the time we get release notes all custom drivers that are still maintained will have updated already for at least a month. If you are writing a custom driver you have to be looking for PR's when something breaks anyway.

@rust-log-analyzer

This comment has been minimized.

@bjorn3 bjorn3 force-pushed the yet_another_driver_refactor_round branch from aaf0567 to 86b0254 Compare October 31, 2024 17:08
@rust-log-analyzer

This comment has been minimized.

@bjorn3 bjorn3 force-pushed the yet_another_driver_refactor_round branch from 86b0254 to c2423f3 Compare October 31, 2024 18:42
@rust-log-analyzer

This comment has been minimized.

@bjorn3 bjorn3 force-pushed the yet_another_driver_refactor_round branch from c2423f3 to 7e7a344 Compare October 31, 2024 19:52
@rust-log-analyzer

This comment has been minimized.

@bjorn3 bjorn3 force-pushed the yet_another_driver_refactor_round branch from 7e7a344 to a30d62f Compare November 1, 2024 09:21
@rust-log-analyzer

This comment has been minimized.

@bjorn3 bjorn3 force-pushed the yet_another_driver_refactor_round branch 2 times, most recently from 5bc8708 to dd67650 Compare November 1, 2024 10:23
This allows simplifying the call site and make_input by using a single
match instead of two levels of if's.
This allows re-entrant entering of the GlobalCtxt
We now only exit the GlobalCtxt when calling a callback and all the way
at the end when the GlobalCtxt is about to be destroyed.
@bjorn3 bjorn3 force-pushed the yet_another_driver_refactor_round branch from dd67650 to 74fdbb7 Compare November 9, 2024 17:55
@rust-log-analyzer

This comment has been minimized.

There is no other query that may need to be called at that point anyway.
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.
@bjorn3 bjorn3 force-pushed the yet_another_driver_refactor_round branch from 74fdbb7 to 159ba4c Compare November 9, 2024 18:43
@bjorn3 bjorn3 mentioned this pull request Nov 19, 2024
Copy link
Contributor

@cjgillot cjgillot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit and r=me

compiler/rustc_driver_impl/src/lib.rs Outdated Show resolved Hide resolved
@bjorn3
Copy link
Member Author

bjorn3 commented Nov 27, 2024

@bors r=cjgillot

@bors
Copy link
Contributor

bors commented Nov 27, 2024

📌 Commit dc65c63 has been approved by cjgillot

It is now in the queue for this repository.

@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 Nov 27, 2024
joboet added a commit to joboet/rust that referenced this pull request Nov 27, 2024
…_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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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.

8 participants