@@ -15,7 +15,7 @@ use crate::infer::canonical::{
15
15
use crate :: infer:: region_constraints:: { Constraint , RegionConstraintData } ;
16
16
use crate :: infer:: { DefineOpaqueTypes , InferCtxt , InferOk , InferResult } ;
17
17
use crate :: traits:: query:: NoSolution ;
18
- use crate :: traits:: TraitEngine ;
18
+ use crate :: traits:: { FulfillmentErrorLike , TraitEngine } ;
19
19
use crate :: traits:: { Obligation , ObligationCause , PredicateObligation } ;
20
20
use rustc_data_structures:: captures:: Captures ;
21
21
use rustc_index:: Idx ;
@@ -50,11 +50,11 @@ impl<'tcx> InferCtxt<'tcx> {
50
50
/// - Finally, if any of the obligations result in a hard error,
51
51
/// then `Err(NoSolution)` is returned.
52
52
#[ 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 > > (
54
54
& self ,
55
55
inference_vars : CanonicalVarValues < ' tcx > ,
56
56
answer : T ,
57
- fulfill_cx : & mut dyn TraitEngine < ' tcx > ,
57
+ fulfill_cx : & mut dyn TraitEngine < ' tcx , E > ,
58
58
) -> Result < CanonicalQueryResponse < ' tcx , T > , NoSolution >
59
59
where
60
60
T : Debug + TypeFoldable < TyCtxt < ' tcx > > ,
@@ -97,31 +97,25 @@ impl<'tcx> InferCtxt<'tcx> {
97
97
/// Helper for `make_canonicalized_query_response` that does
98
98
/// everything up until the final canonicalization.
99
99
#[ instrument( skip( self , fulfill_cx) , level = "debug" ) ]
100
- fn make_query_response < T > (
100
+ fn make_query_response < T , E : FulfillmentErrorLike < ' tcx > > (
101
101
& self ,
102
102
inference_vars : CanonicalVarValues < ' tcx > ,
103
103
answer : T ,
104
- fulfill_cx : & mut dyn TraitEngine < ' tcx > ,
104
+ fulfill_cx : & mut dyn TraitEngine < ' tcx , E > ,
105
105
) -> Result < QueryResponse < ' tcx , T > , NoSolution >
106
106
where
107
107
T : Debug + TypeFoldable < TyCtxt < ' tcx > > ,
108
108
{
109
109
let tcx = self . tcx ;
110
110
111
111
// 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 ) ;
114
113
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 ( ) ) {
118
116
return Err ( NoSolution ) ;
119
117
}
120
118
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
-
125
119
let region_obligations = self . take_registered_region_obligations ( ) ;
126
120
debug ! ( ?region_obligations) ;
127
121
let region_constraints = self . with_region_constraints ( |region_constraints| {
@@ -135,8 +129,7 @@ impl<'tcx> InferCtxt<'tcx> {
135
129
} ) ;
136
130
debug ! ( ?region_constraints) ;
137
131
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 } ;
140
133
141
134
let opaque_types = self . take_opaque_types_for_query_response ( ) ;
142
135
0 commit comments