Skip to content

Commit 7ed6754

Browse files
committed
Use an explicit type when discarding the result of tcx.ensure_ok()
1 parent 4dcdaf4 commit 7ed6754

File tree

1 file changed

+9
-5
lines changed
  • compiler/rustc_hir_analysis/src

1 file changed

+9
-5
lines changed

Diff for: compiler/rustc_hir_analysis/src/lib.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ use rustc_middle::middle;
101101
use rustc_middle::mir::interpret::GlobalId;
102102
use rustc_middle::query::Providers;
103103
use rustc_middle::ty::{self, Const, Ty, TyCtxt};
104-
use rustc_span::Span;
104+
use rustc_span::{ErrorGuaranteed, Span};
105105
use rustc_trait_selection::traits;
106106

107107
use self::hir_ty_lowering::{FeedConstTy, HirTyLowerer};
@@ -139,16 +139,20 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
139139
let _prof_timer = tcx.sess.timer("type_check_crate");
140140

141141
tcx.sess.time("coherence_checking", || {
142+
// When discarding query call results, use an explicit type to indicate
143+
// what we are intending to discard, to help future type-based refactoring.
144+
type R = Result<(), ErrorGuaranteed>;
145+
142146
tcx.hir().par_for_each_module(|module| {
143-
let _ = tcx.ensure_ok().check_mod_type_wf(module);
147+
let _: R = tcx.ensure_ok().check_mod_type_wf(module);
144148
});
145149

146150
for &trait_def_id in tcx.all_local_trait_impls(()).keys() {
147-
let _ = tcx.ensure_ok().coherent_trait(trait_def_id);
151+
let _: R = tcx.ensure_ok().coherent_trait(trait_def_id);
148152
}
149153
// these queries are executed for side-effects (error reporting):
150-
let _ = tcx.ensure_ok().crate_inherent_impls_validity_check(());
151-
let _ = tcx.ensure_ok().crate_inherent_impls_overlap_check(());
154+
let _: R = tcx.ensure_ok().crate_inherent_impls_validity_check(());
155+
let _: R = tcx.ensure_ok().crate_inherent_impls_overlap_check(());
152156
});
153157

154158
if tcx.features().rustc_attrs() {

0 commit comments

Comments
 (0)