Skip to content

Commit 0a9f6fe

Browse files
committed
Rename tcx.ensure() to tcx.ensure_ok()
1 parent 5e55679 commit 0a9f6fe

File tree

29 files changed

+187
-162
lines changed

29 files changed

+187
-162
lines changed

compiler/rustc_codegen_cranelift/src/driver/aot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ pub(crate) fn run_aot(
692692

693693
if tcx.dep_graph.is_fully_enabled() {
694694
for cgu in cgus {
695-
tcx.ensure().codegen_unit(cgu.name());
695+
tcx.ensure_ok().codegen_unit(cgu.name());
696696
}
697697
}
698698

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
628628
// unnecessarily.
629629
if tcx.dep_graph.is_fully_enabled() {
630630
for cgu in codegen_units {
631-
tcx.ensure().codegen_unit(cgu.name());
631+
tcx.ensure_ok().codegen_unit(cgu.name());
632632
}
633633
}
634634

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
317317
if let Some(pp_mode) = sess.opts.pretty {
318318
if pp_mode.needs_ast_map() {
319319
create_and_enter_global_ctxt(compiler, krate, |tcx| {
320-
tcx.ensure().early_lint_checks(());
320+
tcx.ensure_ok().early_lint_checks(());
321321
pretty::print(sess, pp_mode, pretty::PrintExtra::NeedsAstMap { tcx });
322322
passes::write_dep_info(tcx);
323323
});
@@ -365,7 +365,7 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
365365
return early_exit();
366366
}
367367

368-
tcx.ensure().analysis(());
368+
tcx.ensure_ok().analysis(());
369369

370370
if callbacks.after_analysis(compiler, tcx) == Compilation::Stop {
371371
return early_exit();

compiler/rustc_driver_impl/src/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl<'tcx> PrintExtra<'tcx> {
221221

222222
pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
223223
if ppm.needs_analysis() {
224-
ex.tcx().ensure().analysis(());
224+
ex.tcx().ensure_ok().analysis(());
225225
}
226226

227227
let (src, src_name) = get_source(sess);

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -781,13 +781,13 @@ fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) {
781781
pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
782782
match tcx.def_kind(def_id) {
783783
DefKind::Static { .. } => {
784-
tcx.ensure().typeck(def_id);
784+
tcx.ensure_ok().typeck(def_id);
785785
maybe_check_static_with_link_section(tcx, def_id);
786786
check_static_inhabited(tcx, def_id);
787787
check_static_linkage(tcx, def_id);
788788
}
789789
DefKind::Const => {
790-
tcx.ensure().typeck(def_id);
790+
tcx.ensure_ok().typeck(def_id);
791791
}
792792
DefKind::Enum => {
793793
check_enum(tcx, def_id);
@@ -807,7 +807,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
807807
DefKind::Impl { of_trait } => {
808808
if of_trait && let Some(impl_trait_header) = tcx.impl_trait_header(def_id) {
809809
if tcx
810-
.ensure()
810+
.ensure_ok()
811811
.coherent_trait(impl_trait_header.trait_ref.instantiate_identity().def_id)
812812
.is_ok()
813813
{
@@ -1045,7 +1045,7 @@ fn check_impl_items_against_trait<'tcx>(
10451045
continue;
10461046
};
10471047

1048-
let res = tcx.ensure().compare_impl_item(impl_item.expect_local());
1048+
let res = tcx.ensure_ok().compare_impl_item(impl_item.expect_local());
10491049

10501050
if res.is_ok() {
10511051
match ty_impl_item.kind {
@@ -1491,7 +1491,7 @@ fn check_enum(tcx: TyCtxt<'_>, def_id: LocalDefId) {
14911491

14921492
for v in def.variants() {
14931493
if let ty::VariantDiscr::Explicit(discr_def_id) = v.discr {
1494-
tcx.ensure().typeck(discr_def_id.expect_local());
1494+
tcx.ensure_ok().typeck(discr_def_id.expect_local());
14951495
}
14961496
}
14971497

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,7 @@ pub(super) fn check_type_bounds<'tcx>(
20432043
) -> Result<(), ErrorGuaranteed> {
20442044
// Avoid bogus "type annotations needed `Foo: Bar`" errors on `impl Bar for Foo` in case
20452045
// other `Foo` impls are incoherent.
2046-
tcx.ensure().coherent_trait(impl_trait_ref.def_id)?;
2046+
tcx.ensure_ok().coherent_trait(impl_trait_ref.def_id)?;
20472047

20482048
let param_env = tcx.param_env(impl_ty.def_id);
20492049
debug!(?param_env);

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ fn check_associated_item(
10441044

10451045
// Avoid bogus "type annotations needed `Foo: Bar`" errors on `impl Bar for Foo` in case
10461046
// other `Foo` impls are incoherent.
1047-
tcx.ensure()
1047+
tcx.ensure_ok()
10481048
.coherent_trait(tcx.parent(item.trait_item_def_id.unwrap_or(item_id.into())))?;
10491049

10501050
let self_ty = match item.container {
@@ -1352,7 +1352,7 @@ fn check_impl<'tcx>(
13521352
let trait_ref = tcx.impl_trait_ref(item.owner_id).unwrap().instantiate_identity();
13531353
// Avoid bogus "type annotations needed `Foo: Bar`" errors on `impl Bar for Foo` in case
13541354
// other `Foo` impls are incoherent.
1355-
tcx.ensure().coherent_trait(trait_ref.def_id)?;
1355+
tcx.ensure_ok().coherent_trait(trait_ref.def_id)?;
13561356
let trait_span = hir_trait_ref.path.span;
13571357
let trait_ref = wfcx.normalize(
13581358
trait_span,
@@ -2265,14 +2265,15 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
22652265

22662266
fn check_mod_type_wf(tcx: TyCtxt<'_>, module: LocalModDefId) -> Result<(), ErrorGuaranteed> {
22672267
let items = tcx.hir_module_items(module);
2268-
let mut res = items.par_items(|item| tcx.ensure().check_well_formed(item.owner_id.def_id));
2269-
res =
2270-
res.and(items.par_impl_items(|item| tcx.ensure().check_well_formed(item.owner_id.def_id)));
2271-
res =
2272-
res.and(items.par_trait_items(|item| tcx.ensure().check_well_formed(item.owner_id.def_id)));
2268+
let mut res = items.par_items(|item| tcx.ensure_ok().check_well_formed(item.owner_id.def_id));
22732269
res = res
2274-
.and(items.par_foreign_items(|item| tcx.ensure().check_well_formed(item.owner_id.def_id)));
2275-
res = res.and(items.par_opaques(|item| tcx.ensure().check_well_formed(item)));
2270+
.and(items.par_impl_items(|item| tcx.ensure_ok().check_well_formed(item.owner_id.def_id)));
2271+
res = res
2272+
.and(items.par_trait_items(|item| tcx.ensure_ok().check_well_formed(item.owner_id.def_id)));
2273+
res = res.and(
2274+
items.par_foreign_items(|item| tcx.ensure_ok().check_well_formed(item.owner_id.def_id)),
2275+
);
2276+
res = res.and(items.par_opaques(|item| tcx.ensure_ok().check_well_formed(item)));
22762277
if module == LocalModDefId::CRATE_DEF_ID {
22772278
super::entry::check_for_entry_fn(tcx);
22782279
}

compiler/rustc_hir_analysis/src/coherence/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ fn visit_implementation_of_coerce_unsized(checker: &Checker<'_>) -> Result<(), E
193193
// errors; other parts of the code may demand it for the info of
194194
// course.
195195
let span = tcx.def_span(impl_did);
196-
tcx.at(span).ensure().coerce_unsized_info(impl_did)
196+
tcx.at(span).ensure_ok().coerce_unsized_info(impl_did)
197197
}
198198

199199
fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<(), ErrorGuaranteed> {

compiler/rustc_hir_analysis/src/coherence/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ fn coherent_trait(tcx: TyCtxt<'_>, def_id: DefId) -> Result<(), ErrorGuaranteed>
151151
let Some(impls) = tcx.all_local_trait_impls(()).get(&def_id) else { return Ok(()) };
152152
// Trigger building the specialization graph for the trait. This will detect and report any
153153
// overlap errors.
154-
let mut res = tcx.ensure().specialization_graph_of(def_id);
154+
let mut res = tcx.ensure_ok().specialization_graph_of(def_id);
155155

156156
for &impl_def_id in impls {
157157
let trait_header = tcx.impl_trait_header(impl_def_id).unwrap();
@@ -162,7 +162,7 @@ fn coherent_trait(tcx: TyCtxt<'_>, def_id: DefId) -> Result<(), ErrorGuaranteed>
162162
res = res.and(check_object_overlap(tcx, impl_def_id, trait_ref));
163163

164164
res = res.and(unsafety::check_item(tcx, impl_def_id, trait_header, trait_def));
165-
res = res.and(tcx.ensure().orphan_check_impl(impl_def_id));
165+
res = res.and(tcx.ensure_ok().orphan_check_impl(impl_def_id));
166166
res = res.and(builtin::check_trait(tcx, def_id, impl_def_id, trait_header));
167167
}
168168

0 commit comments

Comments
 (0)