@@ -15,7 +15,7 @@ use crate::infer::canonical::{
1515use crate :: infer:: region_constraints:: { Constraint , RegionConstraintData } ;
1616use crate :: infer:: { DefineOpaqueTypes , InferCtxt , InferOk , InferResult } ;
1717use crate :: traits:: query:: NoSolution ;
18- use crate :: traits:: TraitEngine ;
18+ use crate :: traits:: { FulfillmentErrorLike , TraitEngine } ;
1919use crate :: traits:: { Obligation , ObligationCause , PredicateObligation } ;
2020use rustc_data_structures:: captures:: Captures ;
2121use rustc_index:: Idx ;
@@ -50,11 +50,11 @@ impl<'tcx> InferCtxt<'tcx> {
5050 /// - Finally, if any of the obligations result in a hard error,
5151 /// then `Err(NoSolution)` is returned.
5252 #[ instrument( skip( self , inference_vars, answer, fulfill_cx) , level = "trace" ) ]
53- pub fn make_canonicalized_query_response < T > (
53+ pub fn make_canonicalized_query_response < T , E : FulfillmentErrorLike < ' tcx > > (
5454 & self ,
5555 inference_vars : CanonicalVarValues < ' tcx > ,
5656 answer : T ,
57- fulfill_cx : & mut dyn TraitEngine < ' tcx > ,
57+ fulfill_cx : & mut dyn TraitEngine < ' tcx , E > ,
5858 ) -> Result < CanonicalQueryResponse < ' tcx , T > , NoSolution >
5959 where
6060 T : Debug + TypeFoldable < TyCtxt < ' tcx > > ,
@@ -97,31 +97,25 @@ impl<'tcx> InferCtxt<'tcx> {
9797 /// Helper for `make_canonicalized_query_response` that does
9898 /// everything up until the final canonicalization.
9999 #[ instrument( skip( self , fulfill_cx) , level = "debug" ) ]
100- fn make_query_response < T > (
100+ fn make_query_response < T , E : FulfillmentErrorLike < ' tcx > > (
101101 & self ,
102102 inference_vars : CanonicalVarValues < ' tcx > ,
103103 answer : T ,
104- fulfill_cx : & mut dyn TraitEngine < ' tcx > ,
104+ fulfill_cx : & mut dyn TraitEngine < ' tcx , E > ,
105105 ) -> Result < QueryResponse < ' tcx , T > , NoSolution >
106106 where
107107 T : Debug + TypeFoldable < TyCtxt < ' tcx > > ,
108108 {
109109 let tcx = self . tcx ;
110110
111111 // Select everything, returning errors.
112- let true_errors = fulfill_cx. select_where_possible ( self ) ;
113- debug ! ( "true_errors = {:#?}" , true_errors) ;
112+ let errors = fulfill_cx. select_all_or_error ( self ) ;
114113
115- if !true_errors. is_empty ( ) {
116- // FIXME -- we don't indicate *why* we failed to solve
117- debug ! ( "make_query_response: true_errors={:#?}" , true_errors) ;
114+ // True error!
115+ if errors. iter ( ) . any ( |e| e. is_true_error ( ) ) {
118116 return Err ( NoSolution ) ;
119117 }
120118
121- // Anything left unselected *now* must be an ambiguity.
122- let ambig_errors = fulfill_cx. select_all_or_error ( self ) ;
123- debug ! ( "ambig_errors = {:#?}" , ambig_errors) ;
124-
125119 let region_obligations = self . take_registered_region_obligations ( ) ;
126120 debug ! ( ?region_obligations) ;
127121 let region_constraints = self . with_region_constraints ( |region_constraints| {
@@ -135,8 +129,7 @@ impl<'tcx> InferCtxt<'tcx> {
135129 } ) ;
136130 debug ! ( ?region_constraints) ;
137131
138- let certainty =
139- if ambig_errors. is_empty ( ) { Certainty :: Proven } else { Certainty :: Ambiguous } ;
132+ let certainty = if errors. is_empty ( ) { Certainty :: Proven } else { Certainty :: Ambiguous } ;
140133
141134 let opaque_types = self . take_opaque_types_for_query_response ( ) ;
142135
0 commit comments