@@ -17,6 +17,8 @@ use rustc_infer::infer::DefineOpaqueTypes;
1717use rustc_infer:: infer:: { self , InferOk , TyCtxtInferExt } ;
1818use rustc_middle:: middle:: stability;
1919use rustc_middle:: query:: Providers ;
20+ use rustc_middle:: traits:: query:: type_op:: MethodAutoderef ;
21+ use rustc_middle:: traits:: query:: CanonicalMethodAutoderefGoal ;
2022use rustc_middle:: ty:: fast_reject:: { simplify_type, TreatParams } ;
2123use rustc_middle:: ty:: AssocItem ;
2224use rustc_middle:: ty:: GenericParamDefKind ;
@@ -36,7 +38,6 @@ use rustc_trait_selection::traits::query::method_autoderef::MethodAutoderefBadTy
3638use rustc_trait_selection:: traits:: query:: method_autoderef:: {
3739 CandidateStep , MethodAutoderefStepsResult ,
3840} ;
39- use rustc_trait_selection:: traits:: query:: CanonicalTyGoal ;
4041use rustc_trait_selection:: traits:: NormalizeExt ;
4142use rustc_trait_selection:: traits:: { self , ObligationCause } ;
4243use std:: cell:: RefCell ;
@@ -371,34 +372,32 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
371372 OP : FnOnce ( ProbeContext < ' _ , ' tcx > ) -> Result < R , MethodError < ' tcx > > ,
372373 {
373374 let mut orig_values = OriginalQueryValues :: default ( ) ;
374- let param_env_and_self_ty = self . canonicalize_query (
375- ParamEnvAnd { param_env : self . param_env , value : self_ty } ,
376- & mut orig_values,
377- ) ;
375+ let goal = MethodAutoderef {
376+ self_ty,
377+ host_effect_param : self . tcx . expected_host_effect_param_for_body ( self . body_id ) ,
378+ } ;
379+ let canonical_goal = self . canonicalize_query ( self . param_env . and ( goal) , & mut orig_values) ;
378380
379381 let steps = match mode {
380- Mode :: MethodCall => self . tcx . method_autoderef_steps ( param_env_and_self_ty ) ,
382+ Mode :: MethodCall => self . tcx . method_autoderef_steps ( canonical_goal ) ,
381383 Mode :: Path => self . probe ( |_| {
382384 // Mode::Path - the deref steps is "trivial". This turns
383385 // our CanonicalQuery into a "trivial" QueryResponse. This
384386 // is a bit inefficient, but I don't think that writing
385387 // special handling for this "trivial case" is a good idea.
386388
387389 let infcx = & self . infcx ;
388- let ( ParamEnvAnd { param_env : _, value : self_ty } , canonical_inference_vars) =
389- infcx. instantiate_canonical_with_fresh_inference_vars (
390- span,
391- & param_env_and_self_ty,
392- ) ;
390+ let ( ParamEnvAnd { param_env : _, value : goal } , canonical_inference_vars) =
391+ infcx. instantiate_canonical_with_fresh_inference_vars ( span, & canonical_goal) ;
393392 debug ! (
394- "probe_op: Mode::Path, param_env_and_self_ty ={:?} self_ty={:?}" ,
395- param_env_and_self_ty , self_ty
393+ "probe_op: Mode::Path, canonical_goal ={:?} self_ty={:?}" ,
394+ canonical_goal , self_ty
396395 ) ;
397396 MethodAutoderefStepsResult {
398397 steps : infcx. tcx . arena . alloc_from_iter ( [ CandidateStep {
399398 self_ty : self . make_query_response_ignoring_pending_obligations (
400399 canonical_inference_vars,
401- self_ty,
400+ goal . self_ty ,
402401 ) ,
403402 autoderefs : 0 ,
404403 from_unsafe_deref : false ,
@@ -510,17 +509,23 @@ pub fn provide(providers: &mut Providers) {
510509
511510fn method_autoderef_steps < ' tcx > (
512511 tcx : TyCtxt < ' tcx > ,
513- goal : CanonicalTyGoal < ' tcx > ,
512+ goal : CanonicalMethodAutoderefGoal < ' tcx > ,
514513) -> MethodAutoderefStepsResult < ' tcx > {
515514 debug ! ( "method_autoderef_steps({:?})" , goal) ;
516515
517516 let ( ref infcx, goal, inference_vars) = tcx. infer_ctxt ( ) . build_with_canonical ( DUMMY_SP , & goal) ;
518- let ParamEnvAnd { param_env, value : self_ty } = goal;
519-
520- let mut autoderef =
521- Autoderef :: new ( infcx, param_env, hir:: def_id:: CRATE_DEF_ID , DUMMY_SP , self_ty)
522- . include_raw_pointers ( )
523- . silence_errors ( ) ;
517+ let ParamEnvAnd { param_env, value : MethodAutoderef { self_ty, host_effect_param } } = goal;
518+
519+ let mut autoderef = Autoderef :: new (
520+ infcx,
521+ param_env,
522+ hir:: def_id:: CRATE_DEF_ID ,
523+ DUMMY_SP ,
524+ self_ty,
525+ host_effect_param,
526+ )
527+ . include_raw_pointers ( )
528+ . silence_errors ( ) ;
524529 let mut reached_raw_pointer = false ;
525530 let mut steps: Vec < _ > = autoderef
526531 . by_ref ( )
0 commit comments