@@ -10,8 +10,8 @@ use rustc_hir::def_id::{DefId, LocalDefId};
10
10
use rustc_hir:: lang_items:: LangItem ;
11
11
use rustc_hir:: ItemKind ;
12
12
use rustc_infer:: infer:: outlives:: env:: OutlivesEnvironment ;
13
+ use rustc_infer:: infer:: TyCtxtInferExt ;
13
14
use rustc_infer:: infer:: { self , RegionResolutionError } ;
14
- use rustc_infer:: infer:: { DefineOpaqueTypes , TyCtxtInferExt } ;
15
15
use rustc_infer:: traits:: Obligation ;
16
16
use rustc_middle:: ty:: adjustment:: CoerceUnsizedInfo ;
17
17
use rustc_middle:: ty:: { self , suggest_constraining_type_params, Ty , TyCtxt , TypeVisitableExt } ;
@@ -189,10 +189,7 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
189
189
// even if they do not carry that attribute.
190
190
use rustc_type_ir:: TyKind :: * ;
191
191
match ( source. kind ( ) , target. kind ( ) ) {
192
- ( & Ref ( r_a, _, mutbl_a) , Ref ( r_b, _, mutbl_b) )
193
- if infcx. at ( & cause, param_env) . eq ( DefineOpaqueTypes :: No , r_a, * r_b) . is_ok ( )
194
- && mutbl_a == * mutbl_b =>
195
- {
192
+ ( & Ref ( r_a, _, mutbl_a) , Ref ( r_b, _, mutbl_b) ) if r_a == * r_b && mutbl_a == * mutbl_b => {
196
193
Ok ( ( ) )
197
194
}
198
195
( & RawPtr ( _, a_mutbl) , & RawPtr ( _, b_mutbl) ) if a_mutbl == b_mutbl => Ok ( ( ) ) ,
@@ -230,18 +227,14 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
230
227
}
231
228
}
232
229
233
- if let Ok ( ok) =
234
- infcx. at ( & cause, param_env) . eq ( DefineOpaqueTypes :: No , ty_a, ty_b)
235
- {
236
- if ok. obligations . is_empty ( ) {
237
- res = Err ( tcx. dcx ( ) . emit_err ( errors:: DispatchFromDynZST {
238
- span,
239
- name : field. name ,
240
- ty : ty_a,
241
- } ) ) ;
230
+ if ty_a == ty_b {
231
+ res = Err ( tcx. dcx ( ) . emit_err ( errors:: DispatchFromDynZST {
232
+ span,
233
+ name : field. name ,
234
+ ty : ty_a,
235
+ } ) ) ;
242
236
243
- return false ;
244
- }
237
+ return false ;
245
238
}
246
239
247
240
return true ;
@@ -433,14 +426,12 @@ pub fn coerce_unsized_info<'tcx>(
433
426
// something more accepting, but we use
434
427
// equality because we want to be able to
435
428
// perform this check without computing
436
- // variance where possible. (This is because
437
- // we may have to evaluate constraint
429
+ // variance or constraining opaque types' hidden types.
430
+ // (This is because we may have to evaluate constraint
438
431
// expressions in the course of execution.)
439
432
// See e.g., #41936.
440
- if let Ok ( ok) = infcx. at ( & cause, param_env) . eq ( DefineOpaqueTypes :: No , a, b) {
441
- if ok. obligations . is_empty ( ) {
442
- return None ;
443
- }
433
+ if a == b {
434
+ return None ;
444
435
}
445
436
446
437
// Collect up all fields that were significantly changed
0 commit comments