Add cycle errors to ScrubbedTraitError to remove a couple more calls to new_with_diagnostics

This commit is contained in:
Michael Goulet
2024-06-02 18:36:11 -04:00
parent 27f5eccd1f
commit 1e72c7f536
14 changed files with 42 additions and 64 deletions

View File

@@ -9,8 +9,8 @@ use rustc_middle::traits::CodegenObligationError;
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt;
use rustc_trait_selection::traits::{
FulfillmentErrorCode, ImplSource, Obligation, ObligationCause, ObligationCtxt,
SelectionContext, Unimplemented,
ImplSource, Obligation, ObligationCause, ObligationCtxt, ScrubbedTraitError, SelectionContext,
Unimplemented,
};
use tracing::debug;
@@ -51,7 +51,7 @@ pub fn codegen_select_candidate<'tcx>(
// all nested obligations. This is because they can inform the
// inference of the impl's type parameters.
// FIXME(-Znext-solver): Doesn't need diagnostics if new solver.
let ocx = ObligationCtxt::new_with_diagnostics(&infcx);
let ocx = ObligationCtxt::new(&infcx);
let impl_source = selection.map(|obligation| {
ocx.register_obligation(obligation);
});
@@ -65,7 +65,7 @@ pub fn codegen_select_candidate<'tcx>(
// Cycle errors are the only post-monomorphization errors possible; emit them now so
// `rustc_ty_utils::resolve_associated_item` doesn't return `None` post-monomorphization.
for err in errors {
if let FulfillmentErrorCode::Cycle(cycle) = err.code {
if let ScrubbedTraitError::Cycle(cycle) = err {
infcx.err_ctxt().report_overflow_obligation_cycle(&cycle);
}
}