@@ -961,6 +961,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
961
961
origin : hir:: OpaqueTyOrigin ,
962
962
) -> Ty < ' tcx > {
963
963
let infcx = self . infcx ;
964
+ let tcx = infcx. tcx ;
964
965
let OpaqueTypeKey { def_id, substs } = opaque_type_key;
965
966
966
967
// Use the same type variable if the exact same opaque type appears more
@@ -992,15 +993,6 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
992
993
}
993
994
994
995
debug ! ( "generated new type inference var {:?}" , ty_var. kind( ) ) ;
995
- self . compute_opaque_type_obligations ( opaque_type_key) ;
996
-
997
- ty_var
998
- }
999
-
1000
- fn compute_opaque_type_obligations ( & mut self , opaque_type_key : OpaqueTypeKey < ' tcx > ) {
1001
- let infcx = self . infcx ;
1002
- let tcx = infcx. tcx ;
1003
- let OpaqueTypeKey { def_id, substs } = opaque_type_key;
1004
996
1005
997
let item_bounds = tcx. explicit_item_bounds ( def_id) ;
1006
998
debug ! ( ?item_bounds) ;
@@ -1021,7 +1013,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
1021
1013
if let ty:: PredicateKind :: Projection ( projection) = predicate. kind ( ) . skip_binder ( ) {
1022
1014
if projection. ty . references_error ( ) {
1023
1015
// No point on adding these obligations since there's a type error involved.
1024
- return ;
1016
+ return ty_var ;
1025
1017
}
1026
1018
}
1027
1019
}
@@ -1040,6 +1032,8 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
1040
1032
debug ! ( "instantiate_opaque_types: predicate={:?}" , predicate) ;
1041
1033
self . obligations . push ( traits:: Obligation :: new ( cause, self . param_env , predicate) ) ;
1042
1034
}
1035
+
1036
+ ty_var
1043
1037
}
1044
1038
}
1045
1039
0 commit comments