@@ -711,32 +711,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
711711 let formal_ret = self . resolve_vars_with_obligations ( formal_ret) ;
712712 let ret_ty = expected_ret. only_has_type ( self ) ?;
713713
714- // HACK(oli-obk): This is a hack to keep RPIT and TAIT in sync wrt their behaviour.
715- // Without it, the inference
716- // variable will get instantiated with the opaque type. The inference variable often
717- // has various helpful obligations registered for it that help closures figure out their
718- // signature. If we infer the inference var to the opaque type, the closure won't be able
719- // to find those obligations anymore, and it can't necessarily find them from the opaque
720- // type itself. We could be more powerful with inference if we *combined* the obligations
721- // so that we got both the obligations from the opaque type and the ones from the inference
722- // variable. That will accept more code than we do right now, so we need to carefully consider
723- // the implications.
724- // Note: this check is pessimistic, as the inference type could be matched with something other
725- // than the opaque type, but then we need a new `TypeRelation` just for this specific case and
726- // can't re-use `sup` below.
727- // See tests/ui/impl-trait/hidden-type-is-opaque.rs and
728- // tests/ui/impl-trait/hidden-type-is-opaque-2.rs for examples that hit this path.
729- if formal_ret. has_infer_types ( ) {
730- for ty in ret_ty. walk ( ) {
731- if let ty:: GenericArgKind :: Type ( ty) = ty. unpack ( )
732- && let ty:: Alias ( ty:: Opaque , ty:: AliasTy { def_id, .. } ) = * ty. kind ( )
733- && self . can_define_opaque_ty ( def_id)
734- {
735- return None ;
736- }
737- }
738- }
739-
740714 let expect_args = self
741715 . fudge_inference_if_ok ( || {
742716 let ocx = ObligationCtxt :: new ( self ) ;
0 commit comments