@@ -415,10 +415,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
415415 infcx. instantiate_canonical ( span, & query_input. canonical ) ;
416416 let query:: MethodAutoderefSteps { predefined_opaques_in_body : _, self_ty } = value;
417417 debug ! ( ?self_ty, ?query_input, "probe_op: Mode::Path" ) ;
418+ let prev_opaque_entries = self . inner . borrow_mut ( ) . opaque_types ( ) . num_entries ( ) ;
418419 MethodAutoderefStepsResult {
419420 steps : infcx. tcx . arena . alloc_from_iter ( [ CandidateStep {
420- self_ty : self
421- . make_query_response_ignoring_pending_obligations ( var_values, self_ty) ,
421+ self_ty : self . make_query_response_ignoring_pending_obligations (
422+ var_values,
423+ self_ty,
424+ prev_opaque_entries,
425+ ) ,
422426 self_ty_is_opaque : false ,
423427 autoderefs : 0 ,
424428 from_unsafe_deref : false ,
@@ -607,6 +611,7 @@ pub(crate) fn method_autoderef_steps<'tcx>(
607611 debug ! ( ?key, ?ty, ?prev, "ignore duplicate in `opaque_types_storage`" ) ;
608612 }
609613 }
614+ let prev_opaque_entries = infcx. inner . borrow_mut ( ) . opaque_types ( ) . num_entries ( ) ;
610615
611616 // We accept not-yet-defined opaque types in the autoderef
612617 // chain to support recursive calls. We do error if the final
@@ -650,8 +655,11 @@ pub(crate) fn method_autoderef_steps<'tcx>(
650655 . zip ( reachable_via_deref)
651656 . map ( |( ( ty, d) , reachable_via_deref) | {
652657 let step = CandidateStep {
653- self_ty : infcx
654- . make_query_response_ignoring_pending_obligations ( inference_vars, ty) ,
658+ self_ty : infcx. make_query_response_ignoring_pending_obligations (
659+ inference_vars,
660+ ty,
661+ prev_opaque_entries,
662+ ) ,
655663 self_ty_is_opaque : self_ty_is_opaque ( ty) ,
656664 autoderefs : d,
657665 from_unsafe_deref : reached_raw_pointer,
@@ -671,8 +679,11 @@ pub(crate) fn method_autoderef_steps<'tcx>(
671679 . by_ref ( )
672680 . map ( |( ty, d) | {
673681 let step = CandidateStep {
674- self_ty : infcx
675- . make_query_response_ignoring_pending_obligations ( inference_vars, ty) ,
682+ self_ty : infcx. make_query_response_ignoring_pending_obligations (
683+ inference_vars,
684+ ty,
685+ prev_opaque_entries,
686+ ) ,
676687 self_ty_is_opaque : self_ty_is_opaque ( ty) ,
677688 autoderefs : d,
678689 from_unsafe_deref : reached_raw_pointer,
@@ -692,18 +703,27 @@ pub(crate) fn method_autoderef_steps<'tcx>(
692703 let opt_bad_ty = match final_ty. kind ( ) {
693704 ty:: Infer ( ty:: TyVar ( _) ) if !self_ty_is_opaque ( final_ty) => Some ( MethodAutoderefBadTy {
694705 reached_raw_pointer,
695- ty : infcx. make_query_response_ignoring_pending_obligations ( inference_vars, final_ty) ,
706+ ty : infcx. make_query_response_ignoring_pending_obligations (
707+ inference_vars,
708+ final_ty,
709+ prev_opaque_entries,
710+ ) ,
696711 } ) ,
697712 ty:: Error ( _) => Some ( MethodAutoderefBadTy {
698713 reached_raw_pointer,
699- ty : infcx. make_query_response_ignoring_pending_obligations ( inference_vars, final_ty) ,
714+ ty : infcx. make_query_response_ignoring_pending_obligations (
715+ inference_vars,
716+ final_ty,
717+ prev_opaque_entries,
718+ ) ,
700719 } ) ,
701720 ty:: Array ( elem_ty, _) => {
702721 let autoderefs = steps. iter ( ) . filter ( |s| s. reachable_via_deref ) . count ( ) - 1 ;
703722 steps. push ( CandidateStep {
704723 self_ty : infcx. make_query_response_ignoring_pending_obligations (
705724 inference_vars,
706725 Ty :: new_slice ( infcx. tcx , * elem_ty) ,
726+ prev_opaque_entries,
707727 ) ,
708728 self_ty_is_opaque : false ,
709729 autoderefs,
0 commit comments