@@ -1130,32 +1130,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1130
1130
self . relate_types ( sub, ty:: Variance :: Covariant , sup, locations, category)
1131
1131
}
1132
1132
1133
- /// Try to relate `sub <: sup`; if this fails, instantiate opaque
1134
- /// variables in `sub` with their inferred definitions and try
1135
- /// again. This is used for opaque types in places (e.g., `let x:
1136
- /// impl Foo = ..`).
1137
- fn sub_types_or_anon (
1138
- & mut self ,
1139
- sub : Ty < ' tcx > ,
1140
- sup : Ty < ' tcx > ,
1141
- locations : Locations ,
1142
- category : ConstraintCategory ,
1143
- ) -> Fallible < ( ) > {
1144
- if let Err ( terr) = self . sub_types ( sub, sup, locations, category) {
1145
- if let ty:: Opaque ( ..) = sup. kind ( ) {
1146
- // When you have `let x: impl Foo = ...` in a closure,
1147
- // the resulting inferend values are stored with the
1148
- // def-id of the base function.
1149
- let parent_def_id =
1150
- self . tcx ( ) . closure_base_def_id ( self . body . source . def_id ( ) ) . expect_local ( ) ;
1151
- return self . eq_opaque_type_and_type ( sub, sup, parent_def_id, locations, category) ;
1152
- } else {
1153
- return Err ( terr) ;
1154
- }
1155
- }
1156
- Ok ( ( ) )
1157
- }
1158
-
1159
1133
fn eq_types (
1160
1134
& mut self ,
1161
1135
a : Ty < ' tcx > ,
@@ -1490,7 +1464,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1490
1464
let rv_ty = rv. ty ( body, tcx) ;
1491
1465
let rv_ty = self . normalize ( rv_ty, location) ;
1492
1466
if let Err ( terr) =
1493
- self . sub_types_or_anon ( rv_ty, place_ty, location. to_locations ( ) , category)
1467
+ self . sub_types ( rv_ty, place_ty, location. to_locations ( ) , category)
1494
1468
{
1495
1469
span_mirbug ! (
1496
1470
self ,
@@ -1777,9 +1751,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
1777
1751
1778
1752
let locations = term_location. to_locations ( ) ;
1779
1753
1780
- if let Err ( terr) =
1781
- self . sub_types_or_anon ( sig. output ( ) , dest_ty, locations, category)
1782
- {
1754
+ if let Err ( terr) = self . sub_types ( sig. output ( ) , dest_ty, locations, category) {
1783
1755
span_mirbug ! (
1784
1756
self ,
1785
1757
term,
0 commit comments