@@ -478,7 +478,7 @@ pub fn normalize_projection_type<'a, 'b, 'gcx, 'tcx>(
478478 let def_id = projection_ty. item_def_id ;
479479 let ty_var = selcx. infcx ( ) . next_ty_var (
480480 TypeVariableOrigin :: NormalizeProjectionType ( tcx. def_span ( def_id) ) ) ;
481- let projection = ty:: Binder ( ty:: ProjectionPredicate {
481+ let projection = ty:: Binder :: dummy ( ty:: ProjectionPredicate {
482482 projection_ty,
483483 ty : ty_var
484484 } ) ;
@@ -982,8 +982,7 @@ fn assemble_candidates_from_predicates<'cx, 'gcx, 'tcx, I>(
982982 predicate) ;
983983 match predicate {
984984 ty:: Predicate :: Projection ( data) => {
985- let same_def_id =
986- data. 0 . projection_ty . item_def_id == obligation. predicate . item_def_id ;
985+ let same_def_id = data. projection_def_id ( ) == obligation. predicate . item_def_id ;
987986
988987 let is_match = same_def_id && infcx. probe ( |_| {
989988 let data_poly_trait_ref =
@@ -1241,7 +1240,7 @@ fn confirm_object_candidate<'cx, 'gcx, 'tcx>(
12411240 // item with the correct name
12421241 let env_predicates = env_predicates. filter_map ( |p| match p {
12431242 ty:: Predicate :: Projection ( data) =>
1244- if data. 0 . projection_ty . item_def_id == obligation. predicate . item_def_id {
1243+ if data. projection_def_id ( ) == obligation. predicate . item_def_id {
12451244 Some ( data)
12461245 } else {
12471246 None
@@ -1302,28 +1301,28 @@ fn confirm_generator_candidate<'cx, 'gcx, 'tcx>(
13021301
13031302 let gen_def_id = tcx. lang_items ( ) . gen_trait ( ) . unwrap ( ) ;
13041303
1305- // Note: we unwrap the binder here but re-create it below (1)
1306- let ty:: Binder ( ( trait_ref, yield_ty, return_ty) ) =
1304+ let predicate =
13071305 tcx. generator_trait_ref_and_outputs ( gen_def_id,
13081306 obligation. predicate . self_ty ( ) ,
1309- gen_sig) ;
1310-
1311- let name = tcx. associated_item ( obligation. predicate . item_def_id ) . name ;
1312- let ty = if name == Symbol :: intern ( "Return" ) {
1313- return_ty
1314- } else if name == Symbol :: intern ( "Yield" ) {
1315- yield_ty
1316- } else {
1317- bug ! ( )
1318- } ;
1307+ gen_sig)
1308+ . map_bound ( | ( trait_ref , yield_ty , return_ty ) | {
1309+ let name = tcx. associated_item ( obligation. predicate . item_def_id ) . name ;
1310+ let ty = if name == Symbol :: intern ( "Return" ) {
1311+ return_ty
1312+ } else if name == Symbol :: intern ( "Yield" ) {
1313+ yield_ty
1314+ } else {
1315+ bug ! ( )
1316+ } ;
13191317
1320- let predicate = ty:: Binder ( ty:: ProjectionPredicate { // (1) recreate binder here
1321- projection_ty : ty:: ProjectionTy {
1322- substs : trait_ref. substs ,
1323- item_def_id : obligation. predicate . item_def_id ,
1324- } ,
1325- ty : ty
1326- } ) ;
1318+ ty:: ProjectionPredicate {
1319+ projection_ty : ty:: ProjectionTy {
1320+ substs : trait_ref. substs ,
1321+ item_def_id : obligation. predicate . item_def_id ,
1322+ } ,
1323+ ty : ty
1324+ }
1325+ } ) ;
13271326
13281327 confirm_param_env_candidate ( selcx, obligation, predicate)
13291328 . with_addl_obligations ( vtable. nested )
@@ -1400,21 +1399,21 @@ fn confirm_callable_candidate<'cx, 'gcx, 'tcx>(
14001399 // the `Output` associated type is declared on `FnOnce`
14011400 let fn_once_def_id = tcx. lang_items ( ) . fn_once_trait ( ) . unwrap ( ) ;
14021401
1403- // Note: we unwrap the binder here but re-create it below (1)
1404- let ty:: Binder ( ( trait_ref, ret_type) ) =
1402+ let predicate =
14051403 tcx. closure_trait_ref_and_return_type ( fn_once_def_id,
14061404 obligation. predicate . self_ty ( ) ,
14071405 fn_sig,
1408- flag) ;
1409-
1410- let predicate = ty:: Binder ( ty:: ProjectionPredicate { // (1) recreate binder here
1411- projection_ty : ty:: ProjectionTy :: from_ref_and_name (
1412- tcx,
1413- trait_ref,
1414- Symbol :: intern ( FN_OUTPUT_NAME ) ,
1415- ) ,
1416- ty : ret_type
1417- } ) ;
1406+ flag)
1407+ . map_bound ( |( trait_ref, ret_type) | {
1408+ ty:: ProjectionPredicate {
1409+ projection_ty : ty:: ProjectionTy :: from_ref_and_name (
1410+ tcx,
1411+ trait_ref,
1412+ Symbol :: intern ( FN_OUTPUT_NAME ) ,
1413+ ) ,
1414+ ty : ret_type
1415+ }
1416+ } ) ;
14181417
14191418 confirm_param_env_candidate ( selcx, obligation, predicate)
14201419}
0 commit comments