@@ -44,6 +44,7 @@ use rustc_hir::def_id::DefId;
4444use rustc_hir:: intravisit:: { self , Visitor } ;
4545use rustc_hir:: Expr ;
4646use rustc_hir_analysis:: astconv:: AstConv ;
47+ use rustc_infer:: infer:: at:: At ;
4748use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
4849use rustc_infer:: infer:: { Coercion , DefiningAnchor , InferOk , InferResult } ;
4950use rustc_infer:: traits:: Obligation ;
@@ -140,12 +141,14 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
140141 Coerce { fcx, cause, allow_two_phase, use_lub : false }
141142 }
142143
144+ pub fn at ( & self ) -> At < ' _ , ' tcx > {
145+ self . infcx . at ( & self . cause , self . param_env )
146+ }
147+
143148 fn unify ( & self , a : Ty < ' tcx > , b : Ty < ' tcx > ) -> InferResult < ' tcx , Ty < ' tcx > > {
144149 debug ! ( "unify(a: {:?}, b: {:?}, use_lub: {})" , a, b, self . use_lub) ;
145150 self . commit_if_ok ( |_| {
146- let at = self
147- . at ( & self . cause , self . fcx . param_env )
148- . define_opaque_types ( self . defining_use_anchor ( ) ) ;
151+ let at = self . at ( ) . define_opaque_types ( self . defining_use_anchor ( ) ) ;
149152 if self . use_lub {
150153 at. lub ( b, a)
151154 } else {
@@ -177,9 +180,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
177180 // so this will have the side-effect of making sure we have no ambiguities
178181 // due to `[type error]` and `_` not coercing together.
179182 let _ = self . commit_if_ok ( |_| {
180- self . at ( & self . cause , self . param_env )
181- . define_opaque_types ( self . defining_use_anchor ( ) )
182- . eq ( a, b)
183+ self . at ( ) . define_opaque_types ( self . defining_use_anchor ( ) ) . eq ( a, b)
183184 } ) ;
184185 return success ( vec ! [ ] , self . fcx . tcx . ty_error ( guar) , vec ! [ ] ) ;
185186 }
@@ -843,8 +844,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
843844 //! into a closure or a `proc`.
844845
845846 let b = self . shallow_resolve ( b) ;
846- let InferOk { value : b, mut obligations } =
847- self . at ( & self . cause , self . param_env ) . normalize ( b) ;
847+ let InferOk { value : b, mut obligations } = self . at ( ) . normalize ( b) ;
848848 debug ! ( "coerce_from_fn_item(a={:?}, b={:?})" , a, b) ;
849849
850850 match b. kind ( ) {
@@ -865,8 +865,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
865865 }
866866 }
867867
868- let InferOk { value : a_sig, obligations : o1 } =
869- self . at ( & self . cause , self . param_env ) . normalize ( a_sig) ;
868+ let InferOk { value : a_sig, obligations : o1 } = self . at ( ) . normalize ( a_sig) ;
870869 obligations. extend ( o1) ;
871870
872871 let a_fn_pointer = self . tcx . mk_fn_ptr ( a_sig) ;
@@ -1105,9 +1104,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11051104 ( ty:: FnDef ( ..) , ty:: FnDef ( ..) ) => {
11061105 // Don't reify if the function types have a LUB, i.e., they
11071106 // are the same function and their parameters have a LUB.
1108- match self
1109- . commit_if_ok ( |_| self . at ( cause, self . param_env ) . lub ( prev_ty, new_ty) )
1110- {
1107+ match self . commit_if_ok ( |_| self . at ( cause) . lub ( prev_ty, new_ty) ) {
11111108 // We have a LUB of prev_ty and new_ty, just return it.
11121109 Ok ( ok) => return Ok ( self . register_infer_ok_obligations ( ok) ) ,
11131110 Err ( _) => {
@@ -1155,7 +1152,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11551152 // The signature must match.
11561153 let ( a_sig, b_sig) = self . normalize ( new. span , ( a_sig, b_sig) ) ;
11571154 let sig = self
1158- . at ( cause, self . param_env )
1155+ . at ( cause)
11591156 . trace ( prev_ty, new_ty)
11601157 . lub ( a_sig, b_sig)
11611158 . map ( |ok| self . register_infer_ok_obligations ( ok) ) ?;
@@ -1241,7 +1238,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12411238 ) ;
12421239
12431240 return self
1244- . commit_if_ok ( |_| self . at ( cause, self . param_env ) . lub ( prev_ty, new_ty) )
1241+ . commit_if_ok ( |_| self . at ( cause) . lub ( prev_ty, new_ty) )
12451242 . map ( |ok| self . register_infer_ok_obligations ( ok) ) ;
12461243 }
12471244 }
@@ -1252,7 +1249,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12521249 if let Some ( e) = first_error {
12531250 Err ( e)
12541251 } else {
1255- self . commit_if_ok ( |_| self . at ( cause, self . param_env ) . lub ( prev_ty, new_ty) )
1252+ self . commit_if_ok ( |_| self . at ( cause) . lub ( prev_ty, new_ty) )
12561253 . map ( |ok| self . register_infer_ok_obligations ( ok) )
12571254 }
12581255 }
@@ -1489,7 +1486,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
14891486 //
14901487 // Another example is `break` with no argument expression.
14911488 assert ! ( expression_ty. is_unit( ) , "if let hack without unit type" ) ;
1492- fcx. at ( cause, fcx . param_env )
1489+ fcx. at ( cause)
14931490 // needed for tests/ui/type-alias-impl-trait/issue-65679-inst-opaque-ty-from-val-twice.rs
14941491 . define_opaque_types ( fcx. defining_use_anchor ( ) )
14951492 . eq_exp ( label_expression_as_expected, expression_ty, self . merged_ty ( ) )
0 commit comments