Skip to content

Commit 3658060

Browse files
committed
Auto merge of #139234 - compiler-errors:query-tweak, r=oli-obk
Misc query tweaks Remove some redundant work around `cache_on_disk` and `ensure_ok`, since `Result<(), ErrorGuaranteed>` queries don't need to cache or recompute their "value" if they are only used for their result.
2 parents d5b4c2e + 3524e6a commit 3658060

File tree

5 files changed

+8
-11
lines changed

5 files changed

+8
-11
lines changed

compiler/rustc_const_eval/src/check_consts/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
335335
self.tcx.dcx().span_bug(span, "tls access is checked in `Rvalue::ThreadLocalRef`");
336336
}
337337
if let Some(def_id) = def_id.as_local()
338-
&& let Err(guar) = self.tcx.at(span).check_well_formed(hir::OwnerId { def_id })
338+
&& let Err(guar) = self.tcx.ensure_ok().check_well_formed(hir::OwnerId { def_id })
339339
{
340340
self.error_emitted = Some(guar);
341341
}

compiler/rustc_interface/src/passes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
976976
tcx.par_hir_body_owners(|def_id| {
977977
if tcx.is_coroutine(def_id.to_def_id()) {
978978
tcx.ensure_ok().mir_coroutine_witnesses(def_id);
979-
tcx.ensure_ok().check_coroutine_obligations(
979+
let _ = tcx.ensure_ok().check_coroutine_obligations(
980980
tcx.typeck_root_def_id(def_id.to_def_id()).expect_local(),
981981
);
982982
// Eagerly check the unsubstituted layout for cycles.

compiler/rustc_middle/src/query/mod.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ rustc_queries! {
612612

613613
query check_coroutine_obligations(key: LocalDefId) -> Result<(), ErrorGuaranteed> {
614614
desc { |tcx| "verify auto trait bounds for coroutine interior type `{}`", tcx.def_path_str(key) }
615+
return_result_from_ensure_ok
615616
}
616617

617618
/// MIR after our optimization passes have run. This is MIR that is ready
@@ -1033,13 +1034,12 @@ rustc_queries! {
10331034
/// Unsafety-check this `LocalDefId`.
10341035
query check_unsafety(key: LocalDefId) {
10351036
desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key) }
1036-
cache_on_disk_if { true }
10371037
}
10381038

10391039
/// Checks well-formedness of tail calls (`become f()`).
10401040
query check_tail_calls(key: LocalDefId) -> Result<(), rustc_errors::ErrorGuaranteed> {
10411041
desc { |tcx| "tail-call-checking `{}`", tcx.def_path_str(key) }
1042-
cache_on_disk_if { true }
1042+
return_result_from_ensure_ok
10431043
}
10441044

10451045
/// Returns the types assumed to be well formed while "inside" of the given item.
@@ -1308,7 +1308,7 @@ rustc_queries! {
13081308

13091309
query check_match(key: LocalDefId) -> Result<(), rustc_errors::ErrorGuaranteed> {
13101310
desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) }
1311-
cache_on_disk_if { true }
1311+
return_result_from_ensure_ok
13121312
}
13131313

13141314
/// Performs part of the privacy check and computes effective visibilities.
@@ -1607,7 +1607,6 @@ rustc_queries! {
16071607
/// `Err(AlwaysRequiresDrop)` is returned.
16081608
query adt_significant_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
16091609
desc { |tcx| "computing when `{}` has a significant destructor", tcx.def_path_str(def_id) }
1610-
cache_on_disk_if { false }
16111610
}
16121611

16131612
/// Returns a list of types which (a) have a potentially significant destructor
@@ -1629,7 +1628,6 @@ rustc_queries! {
16291628
/// Otherwise, there is a risk of query cycles.
16301629
query list_significant_drop_tys(ty: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>) -> &'tcx ty::List<Ty<'tcx>> {
16311630
desc { |tcx| "computing when `{}` has a significant destructor", ty.value }
1632-
cache_on_disk_if { false }
16331631
}
16341632

16351633
/// Computes the layout of a type. Note that this implicitly
@@ -2517,7 +2515,6 @@ rustc_queries! {
25172515
/// monomorphized.
25182516
query check_mono_item(key: ty::Instance<'tcx>) {
25192517
desc { "monomorphization-time checking" }
2520-
cache_on_disk_if { true }
25212518
}
25222519

25232520
/// Builds the set of functions that should be skipped for the move-size check.

compiler/rustc_mir_build/src/builder/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ pub(crate) fn closure_saved_names_of_captured_variables<'tcx>(
4848
/// this directly; instead use the cached version via `mir_built`.
4949
pub fn build_mir<'tcx>(tcx: TyCtxt<'tcx>, def: LocalDefId) -> Body<'tcx> {
5050
tcx.ensure_done().thir_abstract_const(def);
51-
if let Err(e) = tcx.check_match(def) {
51+
if let Err(e) = tcx.ensure_ok().check_match(def) {
5252
return construct_error(tcx, def, e);
5353
}
5454

55-
if let Err(err) = tcx.check_tail_calls(def) {
55+
if let Err(err) = tcx.ensure_ok().check_tail_calls(def) {
5656
return construct_error(tcx, def, err);
5757
}
5858

compiler/rustc_mir_transform/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> &
529529
| DefKind::Static { .. }
530530
| DefKind::Const
531531
| DefKind::AssocConst => {
532-
if let Err(guar) = tcx.check_well_formed(root.expect_local()) {
532+
if let Err(guar) = tcx.ensure_ok().check_well_formed(root.expect_local()) {
533533
body.tainted_by_errors = Some(guar);
534534
}
535535
}

0 commit comments

Comments
 (0)