@@ -1158,20 +1158,17 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
1158
1158
1159
1159
// before we go into the whole skolemization thing, just
1160
1160
// quickly check if the self-type is a projection at all.
1161
- let trait_def_id = match obligation. predicate . 0 . trait_ref . self_ty ( ) . sty {
1162
- ty:: TyProjection ( ref data ) => data . trait_ref . def_id ,
1161
+ match obligation. predicate . 0 . trait_ref . self_ty ( ) . sty {
1162
+ ty:: TyProjection ( _ ) | ty :: TyAnon ( .. ) => { }
1163
1163
ty:: TyInfer ( ty:: TyVar ( _) ) => {
1164
1164
span_bug ! ( obligation. cause. span,
1165
1165
"Self=_ should have been handled by assemble_candidates" ) ;
1166
1166
}
1167
- _ => { return ; }
1168
- } ;
1169
-
1170
- debug ! ( "assemble_candidates_for_projected_tys: trait_def_id={:?}" ,
1171
- trait_def_id) ;
1167
+ _ => return
1168
+ }
1172
1169
1173
1170
let result = self . probe ( |this, snapshot| {
1174
- this. match_projection_obligation_against_bounds_from_trait ( obligation,
1171
+ this. match_projection_obligation_against_definition_bounds ( obligation,
1175
1172
snapshot)
1176
1173
} ) ;
1177
1174
@@ -1180,7 +1177,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
1180
1177
}
1181
1178
}
1182
1179
1183
- fn match_projection_obligation_against_bounds_from_trait (
1180
+ fn match_projection_obligation_against_definition_bounds (
1184
1181
& mut self ,
1185
1182
obligation : & TraitObligation < ' tcx > ,
1186
1183
snapshot : & infer:: CombinedSnapshot )
@@ -1190,28 +1187,29 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
1190
1187
self . infcx ( ) . resolve_type_vars_if_possible ( & obligation. predicate ) ;
1191
1188
let ( skol_trait_predicate, skol_map) =
1192
1189
self . infcx ( ) . skolemize_late_bound_regions ( & poly_trait_predicate, snapshot) ;
1193
- debug ! ( "match_projection_obligation_against_bounds_from_trait : \
1190
+ debug ! ( "match_projection_obligation_against_definition_bounds : \
1194
1191
skol_trait_predicate={:?} skol_map={:?}",
1195
1192
skol_trait_predicate,
1196
1193
skol_map) ;
1197
1194
1198
- let projection_trait_ref = match skol_trait_predicate. trait_ref . self_ty ( ) . sty {
1199
- ty:: TyProjection ( ref data) => & data. trait_ref ,
1195
+ let ( def_id, substs) = match skol_trait_predicate. trait_ref . self_ty ( ) . sty {
1196
+ ty:: TyProjection ( ref data) => ( data. trait_ref . def_id , data. trait_ref . substs ) ,
1197
+ ty:: TyAnon ( def_id, substs) => ( def_id, substs) ,
1200
1198
_ => {
1201
1199
span_bug ! (
1202
1200
obligation. cause. span,
1203
- "match_projection_obligation_against_bounds_from_trait () called \
1201
+ "match_projection_obligation_against_definition_bounds () called \
1204
1202
but self-ty not a projection: {:?}",
1205
1203
skol_trait_predicate. trait_ref. self_ty( ) ) ;
1206
1204
}
1207
1205
} ;
1208
- debug ! ( "match_projection_obligation_against_bounds_from_trait : \
1209
- projection_trait_ref ={:?}",
1210
- projection_trait_ref ) ;
1206
+ debug ! ( "match_projection_obligation_against_definition_bounds : \
1207
+ def_id={:?}, substs ={:?}",
1208
+ def_id , substs ) ;
1211
1209
1212
- let trait_predicates = self . tcx ( ) . lookup_predicates ( projection_trait_ref . def_id ) ;
1213
- let bounds = trait_predicates . instantiate ( self . tcx ( ) , projection_trait_ref . substs ) ;
1214
- debug ! ( "match_projection_obligation_against_bounds_from_trait : \
1210
+ let item_predicates = self . tcx ( ) . lookup_predicates ( def_id) ;
1211
+ let bounds = item_predicates . instantiate ( self . tcx ( ) , substs) ;
1212
+ debug ! ( "match_projection_obligation_against_definition_bounds : \
1215
1213
bounds={:?}",
1216
1214
bounds) ;
1217
1215
@@ -1226,7 +1224,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
1226
1224
& skol_map,
1227
1225
snapshot) ) ) ;
1228
1226
1229
- debug ! ( "match_projection_obligation_against_bounds_from_trait : \
1227
+ debug ! ( "match_projection_obligation_against_definition_bounds : \
1230
1228
matching_bound={:?}",
1231
1229
matching_bound) ;
1232
1230
match matching_bound {
@@ -1472,7 +1470,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
1472
1470
}
1473
1471
}
1474
1472
ty:: TyParam ( ..) |
1475
- ty:: TyProjection ( ..) => {
1473
+ ty:: TyProjection ( ..) |
1474
+ ty:: TyAnon ( ..) => {
1476
1475
// In these cases, we don't know what the actual
1477
1476
// type is. Therefore, we cannot break it down
1478
1477
// into its constituent types. So we don't
@@ -1796,7 +1795,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
1796
1795
} ) )
1797
1796
}
1798
1797
1799
- ty:: TyProjection ( _) | ty:: TyParam ( _) => None ,
1798
+ ty:: TyProjection ( _) | ty:: TyParam ( _) | ty :: TyAnon ( .. ) => None ,
1800
1799
ty:: TyInfer ( ty:: TyVar ( _) ) => Ambiguous ,
1801
1800
1802
1801
ty:: TyInfer ( ty:: FreshTy ( _) )
@@ -1842,7 +1841,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
1842
1841
Where ( ty:: Binder ( tys. to_vec ( ) ) )
1843
1842
}
1844
1843
1845
- ty:: TyStruct ( ..) | ty:: TyEnum ( ..) | ty:: TyProjection ( ..) | ty:: TyParam ( ..) => {
1844
+ ty:: TyStruct ( ..) | ty:: TyEnum ( ..) |
1845
+ ty:: TyProjection ( ..) | ty:: TyParam ( ..) | ty:: TyAnon ( ..) => {
1846
1846
// Fallback to whatever user-defined impls exist in this case.
1847
1847
None
1848
1848
}
@@ -1893,6 +1893,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
1893
1893
ty:: TyTrait ( ..) |
1894
1894
ty:: TyParam ( ..) |
1895
1895
ty:: TyProjection ( ..) |
1896
+ ty:: TyAnon ( ..) |
1896
1897
ty:: TyInfer ( ty:: TyVar ( _) ) |
1897
1898
ty:: TyInfer ( ty:: FreshTy ( _) ) |
1898
1899
ty:: TyInfer ( ty:: FreshIntTy ( _) ) |
@@ -2073,7 +2074,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
2073
2074
{
2074
2075
self . in_snapshot ( |this, snapshot| {
2075
2076
let result =
2076
- this. match_projection_obligation_against_bounds_from_trait ( obligation,
2077
+ this. match_projection_obligation_against_definition_bounds ( obligation,
2077
2078
snapshot) ;
2078
2079
assert ! ( result) ;
2079
2080
} )
0 commit comments