@@ -32,6 +32,7 @@ use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
3232use rustc_errors:: ErrorGuaranteed ;
3333use rustc_middle:: query:: Providers ;
3434use rustc_middle:: span_bug;
35+ use rustc_middle:: ty:: error:: { ExpectedFound , TypeError } ;
3536use rustc_middle:: ty:: fold:: TypeFoldable ;
3637use rustc_middle:: ty:: visit:: { TypeVisitable , TypeVisitableExt } ;
3738use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeFolder , TypeSuperVisitable , Upcast } ;
@@ -145,6 +146,43 @@ impl<'tcx> Debug for FulfillmentError<'tcx> {
145146 }
146147}
147148
149+ #[ derive( Clone ) ]
150+ pub enum FulfillmentErrorCode < ' tcx > {
151+ /// Inherently impossible to fulfill; this trait is implemented if and only
152+ /// if it is already implemented.
153+ Cycle ( Vec < PredicateObligation < ' tcx > > ) ,
154+ Select ( SelectionError < ' tcx > ) ,
155+ Project ( MismatchedProjectionTypes < ' tcx > ) ,
156+ Subtype ( ExpectedFound < Ty < ' tcx > > , TypeError < ' tcx > ) , // always comes from a SubtypePredicate
157+ ConstEquate ( ExpectedFound < ty:: Const < ' tcx > > , TypeError < ' tcx > ) ,
158+ Ambiguity {
159+ /// Overflow is only `Some(suggest_recursion_limit)` when using the next generation
160+ /// trait solver `-Znext-solver`. With the old solver overflow is eagerly handled by
161+ /// emitting a fatal error instead.
162+ overflow : Option < bool > ,
163+ } ,
164+ }
165+
166+ impl < ' tcx > Debug for FulfillmentErrorCode < ' tcx > {
167+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
168+ match * self {
169+ FulfillmentErrorCode :: Select ( ref e) => write ! ( f, "{e:?}" ) ,
170+ FulfillmentErrorCode :: Project ( ref e) => write ! ( f, "{e:?}" ) ,
171+ FulfillmentErrorCode :: Subtype ( ref a, ref b) => {
172+ write ! ( f, "CodeSubtypeError({a:?}, {b:?})" )
173+ }
174+ FulfillmentErrorCode :: ConstEquate ( ref a, ref b) => {
175+ write ! ( f, "CodeConstEquateError({a:?}, {b:?})" )
176+ }
177+ FulfillmentErrorCode :: Ambiguity { overflow : None } => write ! ( f, "Ambiguity" ) ,
178+ FulfillmentErrorCode :: Ambiguity { overflow : Some ( suggest_increasing_limit) } => {
179+ write ! ( f, "Overflow({suggest_increasing_limit})" )
180+ }
181+ FulfillmentErrorCode :: Cycle ( ref cycle) => write ! ( f, "Cycle({cycle:?})" ) ,
182+ }
183+ }
184+ }
185+
148186/// Whether to skip the leak check, as part of a future compatibility warning step.
149187///
150188/// The "default" for skip-leak-check corresponds to the current
0 commit comments