Auto merge of #105603 - oli-obk:non_repeatable_queries, r=petrochenkov
Harden the pre-tyctxt query system against accidental recomputation While the current compiler has no issues where we `take` and then compute the query again, in https://github.com/rust-lang/rust/pull/105462 I accidentally introduced such a case. I also took the opportunity to remove `peek_mut`, which is only ever used for `global_tcx` to then invoke `enter`. I added an `enter` method directly on the query.
This commit is contained in:
commit
222d1ff68d
7 changed files with 78 additions and 63 deletions
|
@ -309,8 +309,8 @@ fn run_compiler(
|
|||
|
||||
if let Some(ppm) = &sess.opts.pretty {
|
||||
if ppm.needs_ast_map() {
|
||||
let expanded_crate = queries.expansion()?.peek().0.clone();
|
||||
queries.global_ctxt()?.peek_mut().enter(|tcx| {
|
||||
let expanded_crate = queries.expansion()?.borrow().0.clone();
|
||||
queries.global_ctxt()?.enter(|tcx| {
|
||||
pretty::print_after_hir_lowering(
|
||||
tcx,
|
||||
compiler.input(),
|
||||
|
@ -321,7 +321,7 @@ fn run_compiler(
|
|||
Ok(())
|
||||
})?;
|
||||
} else {
|
||||
let krate = queries.parse()?.take();
|
||||
let krate = queries.parse()?.steal();
|
||||
pretty::print_after_parsing(
|
||||
sess,
|
||||
compiler.input(),
|
||||
|
@ -343,7 +343,8 @@ fn run_compiler(
|
|||
}
|
||||
|
||||
{
|
||||
let (_, lint_store) = &*queries.register_plugins()?.peek();
|
||||
let plugins = queries.register_plugins()?;
|
||||
let (_, lint_store) = &*plugins.borrow();
|
||||
|
||||
// Lint plugins are registered; now we can process command line flags.
|
||||
if sess.opts.describe_lints {
|
||||
|
@ -371,7 +372,7 @@ fn run_compiler(
|
|||
return early_exit();
|
||||
}
|
||||
|
||||
queries.global_ctxt()?.peek_mut().enter(|tcx| {
|
||||
queries.global_ctxt()?.enter(|tcx| {
|
||||
let result = tcx.analysis(());
|
||||
if sess.opts.unstable_opts.save_analysis {
|
||||
let crate_name = tcx.crate_name(LOCAL_CRATE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue