Skip to content

Commit 4fd3181

Browse files
committed
Auto merge of #147111 - BoxyUwU:rename_obligation_processing_apis, r=lcnr
rename `select_where_possible` and `select_all_or_error` r? `@lcnr` I find that people get confused by what these methods do. The verb "select" is not really that helpful and is just a reference to somewhat of an implementation detail of the trait solvers that doesn't even apply to most obligation kinds. I went with `try_evaluate_obligations` and `evaluate_obligations_error_on_ambiguity`. This maintains consistency with the new solvers `evalute_goal` entry point. it's unfortunate that we say obligations rather than goals but this maintains consistency with `register_obligation` functions which I think is a good thing. In the long term possibly we rename `Obligation` or `Goal` 🤷‍♀️
2 parents f6aa851 + 8e9b0c4 commit 4fd3181

File tree

74 files changed

+170
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+170
-145
lines changed

compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ fn try_extract_error_from_fulfill_cx<'a, 'tcx>(
420420
// We generally shouldn't have errors here because the query was
421421
// already run, but there's no point using `span_delayed_bug`
422422
// when we're going to emit an error here anyway.
423-
let _errors = ocx.select_all_or_error();
423+
let _errors = ocx.evaluate_obligations_error_on_ambiguity();
424424
let region_constraints = ocx.infcx.with_region_constraints(|r| r.clone());
425425
try_extract_error_from_region_constraints(
426426
ocx.infcx,

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
13131313
let ocx = ObligationCtxt::new_with_diagnostics(self.infcx);
13141314
let cause = ObligationCause::misc(expr.span, self.mir_def_id());
13151315
ocx.register_bound(cause, self.infcx.param_env, ty, clone_trait);
1316-
let errors = ocx.select_all_or_error();
1316+
let errors = ocx.evaluate_obligations_error_on_ambiguity();
13171317
if errors.iter().all(|error| {
13181318
match error.obligation.predicate.as_clause().and_then(|c| c.as_trait_clause()) {
13191319
Some(clause) => match clause.self_ty().skip_binder().kind() {
@@ -1497,7 +1497,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
14971497
let cause = ObligationCause::misc(span, self.mir_def_id());
14981498

14991499
ocx.register_bound(cause, self.infcx.param_env, ty, def_id);
1500-
let errors = ocx.select_all_or_error();
1500+
let errors = ocx.evaluate_obligations_error_on_ambiguity();
15011501

15021502
// Only emit suggestion if all required predicates are on generic
15031503
let predicates: Result<Vec<_>, _> = errors

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
11341134
Obligation::misc(tcx, span, self.mir_def_id(), self.infcx.param_env, pred)
11351135
}));
11361136

1137-
if ocx.select_all_or_error().is_empty() && count > 0 {
1137+
if ocx.evaluate_obligations_error_on_ambiguity().is_empty() && count > 0 {
11381138
diag.span_suggestion_verbose(
11391139
tcx.hir_body(*body).value.peel_blocks().span.shrink_to_lo(),
11401140
fluent::borrowck_dereference_suggestion,

compiler/rustc_borrowck/src/type_check/liveness/trace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ impl<'tcx> LivenessContext<'_, '_, 'tcx> {
657657
let errors = match dropck_outlives::compute_dropck_outlives_with_errors(
658658
&ocx, op, span,
659659
) {
660-
Ok(_) => ocx.select_all_or_error(),
660+
Ok(_) => ocx.evaluate_obligations_error_on_ambiguity(),
661661
Err(e) => e,
662662
};
663663

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ pub fn validate_trivial_unsize<'tcx>(
139139
) else {
140140
return false;
141141
};
142-
if !ocx.select_all_or_error().is_empty() {
142+
if !ocx.evaluate_obligations_error_on_ambiguity().is_empty() {
143143
return false;
144144
}
145145
infcx.leak_check(universe, None).is_ok()

compiler/rustc_const_eval/src/check_consts/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
415415
)
416416
}));
417417

418-
let errors = ocx.select_all_or_error();
418+
let errors = ocx.evaluate_obligations_error_on_ambiguity();
419419
if errors.is_empty() {
420420
Some(ConstConditionsHold::Yes)
421421
} else {

compiler/rustc_const_eval/src/check_consts/qualifs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl Qualif for HasMutInterior {
119119
ty::TraitRef::new(cx.tcx, freeze_def_id, [ty::GenericArg::from(ty)]),
120120
);
121121
ocx.register_obligation(obligation);
122-
let errors = ocx.select_all_or_error();
122+
let errors = ocx.evaluate_obligations_error_on_ambiguity();
123123
!errors.is_empty()
124124
}
125125

@@ -197,7 +197,7 @@ impl Qualif for NeedsNonConstDrop {
197197
},
198198
),
199199
));
200-
!ocx.select_all_or_error().is_empty()
200+
!ocx.evaluate_obligations_error_on_ambiguity().is_empty()
201201
}
202202

203203
fn is_structural_in_adt_value<'tcx>(cx: &ConstCx<'_, 'tcx>, adt: AdtDef<'tcx>) -> bool {

compiler/rustc_const_eval/src/util/compare_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,5 @@ pub fn relate_types<'tcx>(
4343
Ok(()) => {}
4444
Err(_) => return false,
4545
};
46-
ocx.select_all_or_error().is_empty()
46+
ocx.evaluate_obligations_error_on_ambiguity().is_empty()
4747
}

compiler/rustc_hir_analysis/src/autoderef.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
199199
// evaluate/fulfill mismatches, but that's not a reason for an ICE.
200200
return None;
201201
};
202-
let errors = ocx.select_where_possible();
202+
let errors = ocx.try_evaluate_obligations();
203203
if !errors.is_empty() {
204204
if self.infcx.next_trait_solver() {
205205
unreachable!();

compiler/rustc_hir_analysis/src/check/always_applicable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ fn ensure_impl_predicates_are_implied_by_item_defn<'tcx>(
235235
// They can probably get removed with better treatment of the new `DropImpl`
236236
// obligation cause code, and perhaps some custom logic in `report_region_errors`.
237237

238-
let errors = ocx.select_all_or_error();
238+
let errors = ocx.evaluate_obligations_error_on_ambiguity();
239239
if !errors.is_empty() {
240240
let mut guar = None;
241241
let mut root_predicates = FxHashSet::default();

0 commit comments

Comments
 (0)