Stop using driver queries in the public API by bjorn3 · Pull Request #134130 · rust-lang/rust (original) (raw)

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.