Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ fn try_extract_error_from_fulfill_cx<'a, 'tcx>(
// We generally shouldn't have errors here because the query was
// already run, but there's no point using `span_delayed_bug`
// when we're going to emit an error here anyway.
let _errors = ocx.select_all_or_error();
let _errors = ocx.evaluate_obligations_error_on_ambiguity();
let region_constraints = ocx.infcx.with_region_constraints(|r| r.clone());
try_extract_error_from_region_constraints(
ocx.infcx,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let ocx = ObligationCtxt::new_with_diagnostics(self.infcx);
let cause = ObligationCause::misc(expr.span, self.mir_def_id());
ocx.register_bound(cause, self.infcx.param_env, ty, clone_trait);
let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if errors.iter().all(|error| {
match error.obligation.predicate.as_clause().and_then(|c| c.as_trait_clause()) {
Some(clause) => match clause.self_ty().skip_binder().kind() {
Expand Down Expand Up @@ -1497,7 +1497,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let cause = ObligationCause::misc(span, self.mir_def_id());

ocx.register_bound(cause, self.infcx.param_env, ty, def_id);
let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();

// Only emit suggestion if all required predicates are on generic
let predicates: Result<Vec<_>, _> = errors
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
Obligation::misc(tcx, span, self.mir_def_id(), self.infcx.param_env, pred)
}));

if ocx.select_all_or_error().is_empty() && count > 0 {
if ocx.evaluate_obligations_error_on_ambiguity().is_empty() && count > 0 {
diag.span_suggestion_verbose(
tcx.hir_body(*body).value.peel_blocks().span.shrink_to_lo(),
fluent::borrowck_dereference_suggestion,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/type_check/liveness/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ impl<'tcx> LivenessContext<'_, '_, 'tcx> {
let errors = match dropck_outlives::compute_dropck_outlives_with_errors(
&ocx, op, span,
) {
Ok(_) => ocx.select_all_or_error(),
Ok(_) => ocx.evaluate_obligations_error_on_ambiguity(),
Err(e) => e,
};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub fn validate_trivial_unsize<'tcx>(
) else {
return false;
};
if !ocx.select_all_or_error().is_empty() {
if !ocx.evaluate_obligations_error_on_ambiguity().is_empty() {
return false;
}
infcx.leak_check(universe, None).is_ok()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/check_consts/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
)
}));

let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if errors.is_empty() {
Some(ConstConditionsHold::Yes)
} else {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/check_consts/qualifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Qualif for HasMutInterior {
ty::TraitRef::new(cx.tcx, freeze_def_id, [ty::GenericArg::from(ty)]),
);
ocx.register_obligation(obligation);
let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
!errors.is_empty()
}

Expand Down Expand Up @@ -197,7 +197,7 @@ impl Qualif for NeedsNonConstDrop {
},
),
));
!ocx.select_all_or_error().is_empty()
!ocx.evaluate_obligations_error_on_ambiguity().is_empty()
}

fn is_structural_in_adt_value<'tcx>(cx: &ConstCx<'_, 'tcx>, adt: AdtDef<'tcx>) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/util/compare_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ pub fn relate_types<'tcx>(
Ok(()) => {}
Err(_) => return false,
};
ocx.select_all_or_error().is_empty()
ocx.evaluate_obligations_error_on_ambiguity().is_empty()
}
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/autoderef.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
// evaluate/fulfill mismatches, but that's not a reason for an ICE.
return None;
};
let errors = ocx.select_where_possible();
let errors = ocx.try_evaluate_obligations();
if !errors.is_empty() {
if self.infcx.next_trait_solver() {
unreachable!();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/always_applicable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ fn ensure_impl_predicates_are_implied_by_item_defn<'tcx>(
// They can probably get removed with better treatment of the new `DropImpl`
// obligation cause code, and perhaps some custom logic in `report_region_errors`.

let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
let mut guar = None;
let mut root_predicates = FxHashSet::default();
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ fn check_opaque_meets_bounds<'tcx>(

// Check that all obligations are satisfied by the implementation's
// version.
let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
let guar = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(guar);
Expand Down Expand Up @@ -2028,7 +2028,7 @@ pub(super) fn check_coroutine_obligations(
ocx.register_obligation(Obligation::new(tcx, cause.clone(), param_env, *predicate));
}

let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
debug!(?errors);
if !errors.is_empty() {
return Err(infcx.err_ctxt().report_fulfillment_errors(errors));
Expand Down Expand Up @@ -2072,7 +2072,7 @@ pub(super) fn check_potentially_region_dependent_goals<'tcx>(
ocx.register_obligation(Obligation::new(tcx, cause.clone(), param_env, predicate));
}

let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
debug!(?errors);
if errors.is_empty() { Ok(()) } else { Err(infcx.err_ctxt().report_fulfillment_errors(errors)) }
}
12 changes: 6 additions & 6 deletions compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ fn compare_method_predicate_entailment<'tcx>(

// Check that all obligations are satisfied by the implementation's
// version.
let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(reported);
Expand Down Expand Up @@ -669,7 +669,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(

// Check that all obligations are satisfied by the implementation's
// RPITs.
let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
if let Err(guar) = try_report_async_mismatch(tcx, infcx, &errors, trait_m, impl_m, impl_sig)
{
Expand Down Expand Up @@ -1215,7 +1215,7 @@ fn check_region_late_boundedness<'tcx>(
return None;
};

let errors = ocx.select_where_possible();
let errors = ocx.try_evaluate_obligations();
if !errors.is_empty() {
return None;
}
Expand Down Expand Up @@ -2106,7 +2106,7 @@ fn compare_const_predicate_entailment<'tcx>(

// Check that all obligations are satisfied by the implementation's
// version.
let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
return Err(infcx.err_ctxt().report_fulfillment_errors(errors));
}
Expand Down Expand Up @@ -2242,7 +2242,7 @@ fn compare_type_predicate_entailment<'tcx>(

// Check that all obligations are satisfied by the implementation's
// version.
let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(reported);
Expand Down Expand Up @@ -2367,7 +2367,7 @@ pub(super) fn check_type_bounds<'tcx>(
// Check that all obligations are satisfied by the implementation's
// version.
ocx.register_obligations(obligations);
let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
let reported = infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(reported);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub(crate) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
param_env,
trait_m_sig.inputs_and_output,
));
if !ocx.select_all_or_error().is_empty() {
if !ocx.evaluate_obligations_error_on_ambiguity().is_empty() {
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (selection)");
return;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
let ocx = traits::ObligationCtxt::new_with_diagnostics(&infcx);
let norm_return_ty = ocx.normalize(&cause, param_env, return_ty);
ocx.register_bound(cause, param_env, norm_return_ty, term_did);
let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
infcx.err_ctxt().report_fulfillment_errors(errors);
error = true;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ pub fn check_function_signature<'tcx>(

match ocx.eq(&cause, param_env, expected_sig, actual_sig) {
Ok(()) => {
let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
return Err(infcx.err_ctxt().report_fulfillment_errors(errors));
}
Expand Down
14 changes: 11 additions & 3 deletions compiler/rustc_hir_analysis/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ where
}
f(&mut wfcx)?;

let errors = wfcx.select_all_or_error();
let errors = wfcx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
return Err(infcx.err_ctxt().report_fulfillment_errors(errors));
}
Expand Down Expand Up @@ -1803,7 +1803,11 @@ fn receiver_is_valid<'tcx>(
if let Ok(()) = wfcx.infcx.commit_if_ok(|_| {
let ocx = ObligationCtxt::new(wfcx.infcx);
ocx.eq(&cause, wfcx.param_env, self_ty, receiver_ty)?;
if ocx.select_all_or_error().is_empty() { Ok(()) } else { Err(NoSolution) }
if ocx.evaluate_obligations_error_on_ambiguity().is_empty() {
Ok(())
} else {
Err(NoSolution)
}
}) {
return Ok(());
}
Expand Down Expand Up @@ -1838,7 +1842,11 @@ fn receiver_is_valid<'tcx>(
if let Ok(()) = wfcx.infcx.commit_if_ok(|_| {
let ocx = ObligationCtxt::new(wfcx.infcx);
ocx.eq(&cause, wfcx.param_env, self_ty, potential_self_ty)?;
if ocx.select_all_or_error().is_empty() { Ok(()) } else { Err(NoSolution) }
if ocx.evaluate_obligations_error_on_ambiguity().is_empty() {
Ok(())
} else {
Err(NoSolution)
}
}) {
wfcx.register_obligations(autoderef.into_obligations());
return Ok(());
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_hir_analysis/src/coherence/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
param_env,
ty::TraitRef::new(tcx, trait_ref.def_id, [ty_a, ty_b]),
));
let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
if is_from_coerce_pointee_derive(tcx, span) {
return Err(tcx.dcx().emit_err(errors::CoerceFieldValidity {
Expand Down Expand Up @@ -558,7 +558,7 @@ pub(crate) fn coerce_unsized_info<'tcx>(
ty::TraitRef::new(tcx, trait_def_id, [source, target]),
);
ocx.register_obligation(obligation);
let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();

if !errors.is_empty() {
if is_from_coerce_pointee_derive(tcx, span) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/coherence/orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ fn orphan_check<'tcx>(
let ocx = traits::ObligationCtxt::new(&infcx);
let ty = ocx.normalize(&cause, ty::ParamEnv::empty(), user_ty);
let ty = infcx.resolve_vars_if_possible(ty);
let errors = ocx.select_where_possible();
let errors = ocx.try_evaluate_obligations();
if !errors.is_empty() {
return Ok(user_ty);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ pub fn suggest_impl_trait<'tcx>(
Ty::new_projection_from_args(infcx.tcx, assoc_item_def_id, args),
);
// FIXME(compiler-errors): We may benefit from resolving regions here.
if ocx.select_where_possible().is_empty()
if ocx.try_evaluate_obligations().is_empty()
&& let item_ty = infcx.resolve_vars_if_possible(item_ty)
&& let Some(item_ty) = item_ty.make_suggestable(infcx.tcx, false, None)
&& let Some(sugg) = formatter(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/hir_wf_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub(super) fn diagnostic_hir_wf_check<'tcx>(
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(tcx_ty.into())),
));

for error in ocx.select_all_or_error() {
for error in ocx.evaluate_obligations_error_on_ambiguity() {
debug!("Wf-check got error for {:?}: {:?}", ty, error);
if error.obligation.predicate == self.predicate {
// Save the cause from the greatest depth - this corresponds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ fn get_impl_args(
&ObligationCause::misc(impl1_span, impl1_def_id),
);

let errors = ocx.select_all_or_error();
let errors = ocx.evaluate_obligations_error_on_ambiguity();
if !errors.is_empty() {
let guar = ocx.infcx.err_ctxt().report_fulfillment_errors(errors);
return Err(guar);
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_hir_typeck/src/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
Ok(InferOk { value, obligations }) if self.next_trait_solver() => {
let ocx = ObligationCtxt::new(self);
ocx.register_obligations(obligations);
if ocx.select_where_possible().is_empty() {
if ocx.try_evaluate_obligations().is_empty() {
Ok(InferOk { value, obligations: ocx.into_pending_obligations() })
} else {
Err(TypeError::Mismatch)
Expand Down Expand Up @@ -677,7 +677,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
Some(ty::PredicateKind::AliasRelate(..)) => {
let ocx = ObligationCtxt::new(self);
ocx.register_obligation(obligation);
if !ocx.select_where_possible().is_empty() {
if !ocx.try_evaluate_obligations().is_empty() {
return Err(TypeError::Mismatch);
}
coercion.obligations.extend(ocx.into_pending_obligations());
Expand Down Expand Up @@ -1099,7 +1099,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return false;
};
ocx.register_obligations(ok.obligations);
ocx.select_where_possible().is_empty()
ocx.try_evaluate_obligations().is_empty()
})
}

Expand Down Expand Up @@ -1203,7 +1203,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if self.next_trait_solver() {
let ocx = ObligationCtxt::new(self);
let value = ocx.lub(cause, self.param_env, prev_ty, new_ty)?;
if ocx.select_where_possible().is_empty() {
if ocx.try_evaluate_obligations().is_empty() {
Ok(InferOk {
value,
obligations: ocx.into_pending_obligations(),
Expand Down Expand Up @@ -1818,7 +1818,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
))
}),
);
ocx.select_where_possible().is_empty()
ocx.try_evaluate_obligations().is_empty()
})
};

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.fudge_inference_if_ok(|| {
let ocx = ObligationCtxt::new(self);
ocx.sup(&self.misc(path_span), self.param_env, expected, adt_ty)?;
if !ocx.select_where_possible().is_empty() {
if !ocx.try_evaluate_obligations().is_empty() {
return Err(TypeError::Mismatch);
}
Ok(self.resolve_vars_if_possible(adt_ty))
Expand Down Expand Up @@ -3678,15 +3678,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
),
);

let true_errors = ocx.select_where_possible();
let true_errors = ocx.try_evaluate_obligations();

// Do a leak check -- we can't really report a useful error here,
// but it at least avoids an ICE when the error has to do with higher-ranked
// lifetimes.
self.leak_check(outer_universe, Some(snapshot))?;

// Bail if we have ambiguity errors, which we can't report in a useful way.
let ambiguity_errors = ocx.select_all_or_error();
let ambiguity_errors = ocx.evaluate_obligations_error_on_ambiguity();
if true_errors.is_empty() && !ambiguity_errors.is_empty() {
return Err(NoSolution);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
.expect("expected diverging var to be unconstrained");
}

ocx.select_where_possible()
ocx.try_evaluate_obligations()
})
};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self,
mutate_fulfillment_errors: impl Fn(&mut Vec<traits::FulfillmentError<'tcx>>),
) {
let mut result = self.fulfillment_cx.borrow_mut().select_where_possible(self);
let mut result = self.fulfillment_cx.borrow_mut().try_evaluate_obligations(self);
if !result.is_empty() {
mutate_fulfillment_errors(&mut result);
self.adjust_fulfillment_errors_for_expr_obligation(&mut result);
Expand Down
Loading
Loading