44//! other areas of the compiler as well.
55
66use rustc_infer:: infer:: TyCtxtInferExt ;
7- use rustc_middle:: traits:: { DefiningAnchor , ObligationCause } ;
7+ use rustc_middle:: traits:: ObligationCause ;
88use rustc_middle:: ty:: { ParamEnv , Ty , TyCtxt , Variance } ;
99use rustc_trait_selection:: traits:: ObligationCtxt ;
1010
@@ -33,9 +33,6 @@ pub fn is_equal_up_to_subtyping<'tcx>(
3333/// When validating assignments, the variance should be `Covariant`. When checking
3434/// during `MirPhase` >= `MirPhase::Runtime(RuntimePhase::Initial)` variance should be `Invariant`
3535/// because we want to check for type equality.
36- ///
37- /// This mostly ignores opaque types as it can be used in constraining contexts
38- /// while still computing the final underlying type.
3936pub fn relate_types < ' tcx > (
4037 tcx : TyCtxt < ' tcx > ,
4138 param_env : ParamEnv < ' tcx > ,
@@ -47,8 +44,7 @@ pub fn relate_types<'tcx>(
4744 return true ;
4845 }
4946
50- let mut builder =
51- tcx. infer_ctxt ( ) . ignoring_regions ( ) . with_opaque_type_inference ( DefiningAnchor :: Bubble ) ;
47+ let mut builder = tcx. infer_ctxt ( ) . ignoring_regions ( ) ;
5248 let infcx = builder. build ( ) ;
5349 let ocx = ObligationCtxt :: new ( & infcx) ;
5450 let cause = ObligationCause :: dummy ( ) ;
@@ -58,20 +54,5 @@ pub fn relate_types<'tcx>(
5854 Ok ( ( ) ) => { }
5955 Err ( _) => return false ,
6056 } ;
61- let errors = ocx. select_all_or_error ( ) ;
62- // With `Reveal::All`, opaque types get normalized away, with `Reveal::UserFacing`
63- // we would get unification errors because we're unable to look into opaque types,
64- // even if they're constrained in our current function.
65- for ( key, ty) in infcx. take_opaque_types ( ) {
66- let hidden_ty = tcx. type_of ( key. def_id ) . instantiate ( tcx, key. args ) ;
67- if hidden_ty != ty. hidden_type . ty {
68- span_bug ! (
69- ty. hidden_type. span,
70- "{}, {}" ,
71- tcx. type_of( key. def_id) . instantiate( tcx, key. args) ,
72- ty. hidden_type. ty
73- ) ;
74- }
75- }
76- errors. is_empty ( )
57+ ocx. select_all_or_error ( ) . is_empty ( )
7758}
0 commit comments