@@ -1158,20 +1158,17 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
11581158
11591159 // before we go into the whole skolemization thing, just
11601160 // 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 ( .. ) => { }
11631163 ty:: TyInfer ( ty:: TyVar ( _) ) => {
11641164 span_bug ! ( obligation. cause. span,
11651165 "Self=_ should have been handled by assemble_candidates" ) ;
11661166 }
1167- _ => { return ; }
1168- } ;
1169-
1170- debug ! ( "assemble_candidates_for_projected_tys: trait_def_id={:?}" ,
1171- trait_def_id) ;
1167+ _ => return
1168+ }
11721169
11731170 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,
11751172 snapshot)
11761173 } ) ;
11771174
@@ -1180,7 +1177,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
11801177 }
11811178 }
11821179
1183- fn match_projection_obligation_against_bounds_from_trait (
1180+ fn match_projection_obligation_against_definition_bounds (
11841181 & mut self ,
11851182 obligation : & TraitObligation < ' tcx > ,
11861183 snapshot : & infer:: CombinedSnapshot )
@@ -1190,28 +1187,29 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
11901187 self . infcx ( ) . resolve_type_vars_if_possible ( & obligation. predicate ) ;
11911188 let ( skol_trait_predicate, skol_map) =
11921189 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 : \
11941191 skol_trait_predicate={:?} skol_map={:?}",
11951192 skol_trait_predicate,
11961193 skol_map) ;
11971194
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) ,
12001198 _ => {
12011199 span_bug ! (
12021200 obligation. cause. span,
1203- "match_projection_obligation_against_bounds_from_trait () called \
1201+ "match_projection_obligation_against_definition_bounds () called \
12041202 but self-ty not a projection: {:?}",
12051203 skol_trait_predicate. trait_ref. self_ty( ) ) ;
12061204 }
12071205 } ;
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 ) ;
12111209
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 : \
12151213 bounds={:?}",
12161214 bounds) ;
12171215
@@ -1226,7 +1224,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
12261224 & skol_map,
12271225 snapshot) ) ) ;
12281226
1229- debug ! ( "match_projection_obligation_against_bounds_from_trait : \
1227+ debug ! ( "match_projection_obligation_against_definition_bounds : \
12301228 matching_bound={:?}",
12311229 matching_bound) ;
12321230 match matching_bound {
@@ -1472,7 +1470,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
14721470 }
14731471 }
14741472 ty:: TyParam ( ..) |
1475- ty:: TyProjection ( ..) => {
1473+ ty:: TyProjection ( ..) |
1474+ ty:: TyAnon ( ..) => {
14761475 // In these cases, we don't know what the actual
14771476 // type is. Therefore, we cannot break it down
14781477 // into its constituent types. So we don't
@@ -1796,7 +1795,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
17961795 } ) )
17971796 }
17981797
1799- ty:: TyProjection ( _) | ty:: TyParam ( _) => None ,
1798+ ty:: TyProjection ( _) | ty:: TyParam ( _) | ty :: TyAnon ( .. ) => None ,
18001799 ty:: TyInfer ( ty:: TyVar ( _) ) => Ambiguous ,
18011800
18021801 ty:: TyInfer ( ty:: FreshTy ( _) )
@@ -1842,7 +1841,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
18421841 Where ( ty:: Binder ( tys. to_vec ( ) ) )
18431842 }
18441843
1845- ty:: TyStruct ( ..) | ty:: TyEnum ( ..) | ty:: TyProjection ( ..) | ty:: TyParam ( ..) => {
1844+ ty:: TyStruct ( ..) | ty:: TyEnum ( ..) |
1845+ ty:: TyProjection ( ..) | ty:: TyParam ( ..) | ty:: TyAnon ( ..) => {
18461846 // Fallback to whatever user-defined impls exist in this case.
18471847 None
18481848 }
@@ -1893,6 +1893,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
18931893 ty:: TyTrait ( ..) |
18941894 ty:: TyParam ( ..) |
18951895 ty:: TyProjection ( ..) |
1896+ ty:: TyAnon ( ..) |
18961897 ty:: TyInfer ( ty:: TyVar ( _) ) |
18971898 ty:: TyInfer ( ty:: FreshTy ( _) ) |
18981899 ty:: TyInfer ( ty:: FreshIntTy ( _) ) |
@@ -2073,7 +2074,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
20732074 {
20742075 self . in_snapshot ( |this, snapshot| {
20752076 let result =
2076- this. match_projection_obligation_against_bounds_from_trait ( obligation,
2077+ this. match_projection_obligation_against_definition_bounds ( obligation,
20772078 snapshot) ;
20782079 assert ! ( result) ;
20792080 } )
0 commit comments