@@ -3,7 +3,8 @@ use crate::traits::query::evaluate_obligation::InferCtxtExt;
3
3
use crate :: traits:: NormalizeExt ;
4
4
use crate :: traits:: { self , TraitEngine , TraitEngineExt } ;
5
5
use rustc_hir as hir;
6
- use rustc_infer:: infer:: InferCtxt ;
6
+ use rustc_infer:: infer:: { InferCtxt , InferOk } ;
7
+ use rustc_infer:: traits:: TraitEngineExt as _;
7
8
use rustc_middle:: ty:: TypeVisitable ;
8
9
use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
9
10
use rustc_session:: Limit ;
@@ -138,22 +139,24 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
138
139
return None ;
139
140
}
140
141
141
- let normalized_ty = self
142
+ let InferOk { value : normalized_ty, obligations } = self
142
143
. infcx
143
144
. at ( & cause, self . param_env )
144
145
. normalize ( tcx. mk_projection ( tcx. lang_items ( ) . deref_target ( ) ?, trait_ref. substs ) ) ;
145
- let mut fulfillcx = <dyn TraitEngine < ' tcx > >:: new_in_snapshot ( tcx) ;
146
- let normalized_ty =
147
- normalized_ty. into_value_registering_obligations ( self . infcx , & mut * fulfillcx) ;
148
- let errors = fulfillcx. select_where_possible ( & self . infcx ) ;
146
+
147
+ // HACK(compiler-errors): We must *select* here so we *affect* inference...
148
+ // This can probably be moved to method_autoderef_steps or something instead.
149
+ let mut fulfill_cx = <dyn TraitEngine < ' _ > >:: new_in_snapshot ( tcx) ;
150
+ fulfill_cx. register_predicate_obligations ( & self . infcx , obligations. clone ( ) ) ;
151
+ let errors = fulfill_cx. select_where_possible ( & self . infcx ) ;
149
152
if !errors. is_empty ( ) {
150
153
// This shouldn't happen, except for evaluate/fulfill mismatches,
151
154
// but that's not a reason for an ICE (`predicate_may_hold` is conservative
152
155
// by design).
153
156
debug ! ( "overloaded_deref_ty: encountered errors {:?} while fulfilling" , errors) ;
154
157
return None ;
155
158
}
156
- let obligations = fulfillcx . pending_obligations ( ) ;
159
+
157
160
debug ! ( "overloaded_deref_ty({:?}) = ({:?}, {:?})" , ty, normalized_ty, obligations) ;
158
161
self . state . obligations . extend ( obligations) ;
159
162
0 commit comments