@@ -8,8 +8,8 @@ use rustc_hir::def_id::{DefId, LocalDefId};
8
8
use rustc_hir:: lang_items:: LangItem ;
9
9
use rustc_hir:: ItemKind ;
10
10
use rustc_infer:: infer:: outlives:: env:: OutlivesEnvironment ;
11
- use rustc_infer:: infer:: TyCtxtInferExt ;
12
11
use rustc_infer:: infer:: { self , RegionResolutionError } ;
12
+ use rustc_infer:: infer:: { DefiningAnchor , TyCtxtInferExt } ;
13
13
use rustc_middle:: ty:: adjustment:: CoerceUnsizedInfo ;
14
14
use rustc_middle:: ty:: { self , suggest_constraining_type_params, Ty , TyCtxt , TypeVisitableExt } ;
15
15
use rustc_trait_selection:: traits:: error_reporting:: TypeErrCtxtExt ;
@@ -227,7 +227,8 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
227
227
use rustc_type_ir:: sty:: TyKind :: * ;
228
228
match ( source. kind ( ) , target. kind ( ) ) {
229
229
( & Ref ( r_a, _, mutbl_a) , Ref ( r_b, _, mutbl_b) )
230
- if infcx. at ( & cause, param_env) . eq ( r_a, * r_b) . is_ok ( ) && mutbl_a == * mutbl_b => { }
230
+ if infcx. at ( & cause, param_env, DefiningAnchor :: Error ) . eq ( r_a, * r_b) . is_ok ( )
231
+ && mutbl_a == * mutbl_b => { }
231
232
( & RawPtr ( tm_a) , & RawPtr ( tm_b) ) if tm_a. mutbl == tm_b. mutbl => ( ) ,
232
233
( & Adt ( def_a, substs_a) , & Adt ( def_b, substs_b) )
233
234
if def_a. is_struct ( ) && def_b. is_struct ( ) =>
@@ -270,7 +271,9 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
270
271
}
271
272
}
272
273
273
- if let Ok ( ok) = infcx. at ( & cause, param_env) . eq ( ty_a, ty_b) {
274
+ if let Ok ( ok) =
275
+ infcx. at ( & cause, param_env, DefiningAnchor :: Error ) . eq ( ty_a, ty_b)
276
+ {
274
277
if ok. obligations . is_empty ( ) {
275
278
create_err (
276
279
"the trait `DispatchFromDyn` may only be implemented \
@@ -497,7 +500,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
497
500
// we may have to evaluate constraint
498
501
// expressions in the course of execution.)
499
502
// See e.g., #41936.
500
- if let Ok ( ok) = infcx. at ( & cause, param_env) . eq ( a, b) {
503
+ if let Ok ( ok) = infcx. at ( & cause, param_env, DefiningAnchor :: Error ) . eq ( a, b) {
501
504
if ok. obligations . is_empty ( ) {
502
505
return None ;
503
506
}
0 commit comments