@@ -478,7 +478,7 @@ pub fn normalize_projection_type<'a, 'b, 'gcx, 'tcx>(
478
478
let def_id = projection_ty. item_def_id ;
479
479
let ty_var = selcx. infcx ( ) . next_ty_var (
480
480
TypeVariableOrigin :: NormalizeProjectionType ( tcx. def_span ( def_id) ) ) ;
481
- let projection = ty:: Binder ( ty:: ProjectionPredicate {
481
+ let projection = ty:: Binder :: dummy ( ty:: ProjectionPredicate {
482
482
projection_ty,
483
483
ty : ty_var
484
484
} ) ;
@@ -982,8 +982,7 @@ fn assemble_candidates_from_predicates<'cx, 'gcx, 'tcx, I>(
982
982
predicate) ;
983
983
match predicate {
984
984
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 ;
987
986
988
987
let is_match = same_def_id && infcx. probe ( |_| {
989
988
let data_poly_trait_ref =
@@ -1241,7 +1240,7 @@ fn confirm_object_candidate<'cx, 'gcx, 'tcx>(
1241
1240
// item with the correct name
1242
1241
let env_predicates = env_predicates. filter_map ( |p| match p {
1243
1242
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 {
1245
1244
Some ( data)
1246
1245
} else {
1247
1246
None
@@ -1302,28 +1301,28 @@ fn confirm_generator_candidate<'cx, 'gcx, 'tcx>(
1302
1301
1303
1302
let gen_def_id = tcx. lang_items ( ) . gen_trait ( ) . unwrap ( ) ;
1304
1303
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 =
1307
1305
tcx. generator_trait_ref_and_outputs ( gen_def_id,
1308
1306
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
+ } ;
1319
1317
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
+ } ) ;
1327
1326
1328
1327
confirm_param_env_candidate ( selcx, obligation, predicate)
1329
1328
. with_addl_obligations ( vtable. nested )
@@ -1400,21 +1399,21 @@ fn confirm_callable_candidate<'cx, 'gcx, 'tcx>(
1400
1399
// the `Output` associated type is declared on `FnOnce`
1401
1400
let fn_once_def_id = tcx. lang_items ( ) . fn_once_trait ( ) . unwrap ( ) ;
1402
1401
1403
- // Note: we unwrap the binder here but re-create it below (1)
1404
- let ty:: Binder ( ( trait_ref, ret_type) ) =
1402
+ let predicate =
1405
1403
tcx. closure_trait_ref_and_return_type ( fn_once_def_id,
1406
1404
obligation. predicate . self_ty ( ) ,
1407
1405
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
+ } ) ;
1418
1417
1419
1418
confirm_param_env_candidate ( selcx, obligation, predicate)
1420
1419
}
0 commit comments