From afdcae286049681b43694be6bfdb0f2220710bd2 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 20 Mar 2024 09:05:22 +0000 Subject: [PATCH] Rename mir_const query to mir_built --- compiler/rustc_middle/src/hooks/mod.rs | 2 +- compiler/rustc_middle/src/query/mod.rs | 2 +- compiler/rustc_mir_build/src/check_unsafety.rs | 4 ++-- compiler/rustc_mir_transform/src/check_unsafety.rs | 4 ++-- compiler/rustc_mir_transform/src/ffi_unwind_calls.rs | 2 +- compiler/rustc_mir_transform/src/lib.rs | 10 +++++----- .../multiple_definitions_attribute_merging.stderr | 2 +- tests/ui/resolve/proc_macro_generated_packed.stderr | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_middle/src/hooks/mod.rs b/compiler/rustc_middle/src/hooks/mod.rs index 33447dfed93..aa2cddad093 100644 --- a/compiler/rustc_middle/src/hooks/mod.rs +++ b/compiler/rustc_middle/src/hooks/mod.rs @@ -81,6 +81,6 @@ declare_hooks! { /// Create the MIR for a given `DefId` - this includes /// unreachable code. /// You do not want to call this yourself, instead use the cached version - /// via `mir_const` + /// via `mir_built` hook build_mir(key: LocalDefId) -> mir::Body<'tcx>; } diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 5e9432296ea..4bdc0b1e4ca 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -489,7 +489,7 @@ rustc_queries! { /// ready for const qualification. /// /// See the README for the `mir` module for details. - query mir_const(key: LocalDefId) -> &'tcx Steal> { + query mir_built(key: LocalDefId) -> &'tcx Steal> { desc { |tcx| "preparing `{}` for borrow checking", tcx.def_path_str(key) } } diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index 9ccf71744a1..1ce8da162bf 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -139,7 +139,7 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> { fn visit_inner_body(&mut self, def: LocalDefId) { if let Ok((inner_thir, expr)) = self.tcx.thir_body(def) { // Runs all other queries that depend on THIR. - self.tcx.ensure_with_value().mir_const(def); + self.tcx.ensure_with_value().mir_built(def); let inner_thir = &inner_thir.steal(); let hir_context = self.tcx.local_def_id_to_hir_id(def); let safety_context = mem::replace(&mut self.safety_context, SafetyContext::Safe); @@ -921,7 +921,7 @@ pub fn check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) { let Ok((thir, expr)) = tcx.thir_body(def) else { return }; // Runs all other queries that depend on THIR. - tcx.ensure_with_value().mir_const(def); + tcx.ensure_with_value().mir_built(def); let thir = &thir.steal(); // If `thir` is empty, a type error occurred, skip this body. if thir.exprs.is_empty() { diff --git a/compiler/rustc_mir_transform/src/check_unsafety.rs b/compiler/rustc_mir_transform/src/check_unsafety.rs index bf463021d4b..a0c3de3af58 100644 --- a/compiler/rustc_mir_transform/src/check_unsafety.rs +++ b/compiler/rustc_mir_transform/src/check_unsafety.rs @@ -497,8 +497,8 @@ fn mir_unsafety_check_result(tcx: TyCtxt<'_>, def: LocalDefId) -> &UnsafetyCheck debug!("unsafety_violations({:?})", def); // N.B., this borrow is valid because all the consumers of - // `mir_const` force this. - let body = &tcx.mir_const(def).borrow(); + // `mir_built` force this. + let body = &tcx.mir_built(def).borrow(); if body.is_custom_mir() || body.tainted_by_errors.is_some() { return tcx.arena.alloc(UnsafetyCheckResult { diff --git a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs index 16a417d9a38..0970c4de19f 100644 --- a/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs +++ b/compiler/rustc_mir_transform/src/ffi_unwind_calls.rs @@ -53,7 +53,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool { return false; } - let body = &*tcx.mir_const(local_def_id).borrow(); + let body = &*tcx.mir_built(local_def_id).borrow(); let body_ty = tcx.type_of(def_id).skip_binder(); let body_abi = match body_ty.kind() { diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 9d6463b34ad..1636fe2339a 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -127,7 +127,7 @@ pub fn provide(providers: &mut Providers) { cross_crate_inline::provide(providers); providers.queries = query::Providers { mir_keys, - mir_const, + mir_built, mir_const_qualif, mir_promoted, mir_drops_elaborated_and_const_checked, @@ -259,9 +259,9 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def: LocalDefId) -> ConstQualifs { // N.B., this `borrow()` is guaranteed to be valid (i.e., the value // cannot yet be stolen), because `mir_promoted()`, which steals - // from `mir_const()`, forces this query to execute before + // from `mir_built()`, forces this query to execute before // performing the steal. - let body = &tcx.mir_const(def).borrow(); + let body = &tcx.mir_built(def).borrow(); if body.return_ty().references_error() { // It's possible to reach here without an error being emitted (#121103). @@ -282,7 +282,7 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def: LocalDefId) -> ConstQualifs { /// Make MIR ready for const evaluation. This is run on all MIR, not just on consts! /// FIXME(oli-obk): it's unclear whether we still need this phase (and its corresponding query). /// We used to have this for pre-miri MIR based const eval. -fn mir_const(tcx: TyCtxt<'_>, def: LocalDefId) -> &Steal> { +fn mir_built(tcx: TyCtxt<'_>, def: LocalDefId) -> &Steal> { // MIR unsafety check uses the raw mir, so make sure it is run. if !tcx.sess.opts.unstable_opts.thir_unsafeck { tcx.ensure_with_value().mir_unsafety_check_result(def); @@ -338,7 +338,7 @@ fn mir_promoted( }; // has_ffi_unwind_calls query uses the raw mir, so make sure it is run. tcx.ensure_with_value().has_ffi_unwind_calls(def); - let mut body = tcx.mir_const(def).steal(); + let mut body = tcx.mir_built(def).steal(); if let Some(error_reported) = const_qualifs.tainted_by_errors { body.tainted_by_errors = Some(error_reported); } diff --git a/tests/ui/resolve/multiple_definitions_attribute_merging.stderr b/tests/ui/resolve/multiple_definitions_attribute_merging.stderr index 563db44c946..d0af8cef676 100644 --- a/tests/ui/resolve/multiple_definitions_attribute_merging.stderr +++ b/tests/ui/resolve/multiple_definitions_attribute_merging.stderr @@ -18,7 +18,7 @@ LL | struct Dealigned(u8, T); | = Box query stack during panic: -#0 [mir_const] preparing `::eq` for borrow checking +#0 [mir_built] preparing `::eq` for borrow checking #1 [check_unsafety] unsafety-checking `::eq` end of query stack error: aborting due to 2 previous errors diff --git a/tests/ui/resolve/proc_macro_generated_packed.stderr b/tests/ui/resolve/proc_macro_generated_packed.stderr index 4c515b9809b..0f758ece207 100644 --- a/tests/ui/resolve/proc_macro_generated_packed.stderr +++ b/tests/ui/resolve/proc_macro_generated_packed.stderr @@ -9,7 +9,7 @@ LL | struct Dealigned(u8, T); | = Box query stack during panic: -#0 [mir_const] preparing `::eq` for borrow checking +#0 [mir_built] preparing `::eq` for borrow checking #1 [check_unsafety] unsafety-checking `::eq` end of query stack error: aborting due to 1 previous error