Rename tcx.ensure() to tcx.ensure_ok()

This commit is contained in:
Zalathar
2025-01-30 16:20:09 +11:00
parent 854f22563c
commit 24cdaa146a
29 changed files with 186 additions and 160 deletions

View File

@@ -140,15 +140,15 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
tcx.sess.time("coherence_checking", || {
tcx.hir().par_for_each_module(|module| {
let _ = tcx.ensure().check_mod_type_wf(module);
let _ = tcx.ensure_ok().check_mod_type_wf(module);
});
for &trait_def_id in tcx.all_local_trait_impls(()).keys() {
let _ = tcx.ensure().coherent_trait(trait_def_id);
let _ = tcx.ensure_ok().coherent_trait(trait_def_id);
}
// these queries are executed for side-effects (error reporting):
let _ = tcx.ensure().crate_inherent_impls_validity_check(());
let _ = tcx.ensure().crate_inherent_impls_overlap_check(());
let _ = tcx.ensure_ok().crate_inherent_impls_validity_check(());
let _ = tcx.ensure_ok().crate_inherent_impls_overlap_check(());
});
if tcx.features().rustc_attrs() {
@@ -167,12 +167,12 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
tcx.hir().par_body_owners(|item_def_id| {
let def_kind = tcx.def_kind(item_def_id);
match def_kind {
DefKind::Static { .. } => tcx.ensure().eval_static_initializer(item_def_id),
DefKind::Static { .. } => tcx.ensure_ok().eval_static_initializer(item_def_id),
DefKind::Const if tcx.generics_of(item_def_id).is_empty() => {
let instance = ty::Instance::new(item_def_id.into(), ty::GenericArgs::empty());
let cid = GlobalId { instance, promoted: None };
let typing_env = ty::TypingEnv::fully_monomorphized();
tcx.ensure().eval_to_const_value_raw(typing_env.as_query_input(cid));
tcx.ensure_ok().eval_to_const_value_raw(typing_env.as_query_input(cid));
}
_ => (),
}
@@ -185,11 +185,11 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
tcx.hir().par_body_owners(|item_def_id| {
let def_kind = tcx.def_kind(item_def_id);
if !matches!(def_kind, DefKind::AnonConst) {
tcx.ensure().typeck(item_def_id);
tcx.ensure_ok().typeck(item_def_id);
}
});
tcx.ensure().check_unused_traits(());
tcx.ensure_ok().check_unused_traits(());
}
/// Lower a [`hir::Ty`] to a [`Ty`].