@@ -365,9 +365,7 @@ pub fn normalize_projection_type<'a, 'b, 'gcx, 'tcx>(
365
365
// information is available.
366
366
367
367
let tcx = selcx. infcx ( ) . tcx ;
368
- let def_id = tcx. associated_items ( projection_ty. trait_ref . def_id ) . find ( |i|
369
- i. name == projection_ty. item_name ( tcx) && i. kind == ty:: AssociatedKind :: Type
370
- ) . map ( |i| i. def_id ) . unwrap ( ) ;
368
+ let def_id = projection_ty. item_def_id ;
371
369
let ty_var = selcx. infcx ( ) . next_ty_var (
372
370
TypeVariableOrigin :: NormalizeProjectionType ( tcx. def_span ( def_id) ) ) ;
373
371
let projection = ty:: Binder ( ty:: ProjectionPredicate {
@@ -447,8 +445,8 @@ fn opt_normalize_projection_type<'a, 'b, 'gcx, 'tcx>(
447
445
// normalization. In that case, I think we will want this code:
448
446
//
449
447
// ```
450
- // let ty = selcx.tcx().mk_projection(projection_ty.trait_ref ,
451
- // projection_ty.item_name(tcx) ;
448
+ // let ty = selcx.tcx().mk_projection(projection_ty.item_def_id ,
449
+ // projection_ty.substs ;
452
450
// return Some(NormalizedTy { value: v, obligations: vec![] });
453
451
// ```
454
452
@@ -585,15 +583,13 @@ fn normalize_to_error<'a, 'gcx, 'tcx>(selcx: &mut SelectionContext<'a, 'gcx, 'tc
585
583
depth : usize )
586
584
-> NormalizedTy < ' tcx >
587
585
{
588
- let trait_ref = projection_ty. trait_ref . to_poly_trait_ref ( ) ;
586
+ let trait_ref = projection_ty. trait_ref ( selcx . tcx ( ) ) . to_poly_trait_ref ( ) ;
589
587
let trait_obligation = Obligation { cause : cause,
590
588
recursion_depth : depth,
591
589
param_env,
592
590
predicate : trait_ref. to_predicate ( ) } ;
593
591
let tcx = selcx. infcx ( ) . tcx ;
594
- let def_id = tcx. associated_items ( projection_ty. trait_ref . def_id ) . find ( |i|
595
- i. name == projection_ty. item_name ( tcx) && i. kind == ty:: AssociatedKind :: Type
596
- ) . map ( |i| i. def_id ) . unwrap ( ) ;
592
+ let def_id = projection_ty. item_def_id ;
597
593
let new_value = selcx. infcx ( ) . next_ty_var (
598
594
TypeVariableOrigin :: NormalizeProjectionType ( tcx. def_span ( def_id) ) ) ;
599
595
Normalized {
@@ -654,7 +650,7 @@ fn project_type<'cx, 'gcx, 'tcx>(
654
650
selcx. infcx ( ) . report_overflow_error ( & obligation, true ) ;
655
651
}
656
652
657
- let obligation_trait_ref = & obligation. predicate . trait_ref ;
653
+ let obligation_trait_ref = & obligation. predicate . trait_ref ( selcx . tcx ( ) ) ;
658
654
659
655
debug ! ( "project: obligation_trait_ref={:?}" , obligation_trait_ref) ;
660
656
@@ -743,12 +739,10 @@ fn project_type<'cx, 'gcx, 'tcx>(
743
739
& obligation_trait_ref,
744
740
candidate) ) )
745
741
}
746
- None => {
747
- Ok ( ProjectedTy :: NoProgress (
748
- selcx. tcx ( ) . mk_projection (
749
- obligation. predicate . trait_ref . clone ( ) ,
750
- obligation. predicate . item_name ( selcx. tcx ( ) ) ) ) )
751
- }
742
+ None => Ok ( ProjectedTy :: NoProgress (
743
+ selcx. tcx ( ) . mk_projection (
744
+ obligation. predicate . item_def_id ,
745
+ obligation. predicate . substs ) ) )
752
746
}
753
747
}
754
748
@@ -788,10 +782,11 @@ fn assemble_candidates_from_trait_def<'cx, 'gcx, 'tcx>(
788
782
{
789
783
debug ! ( "assemble_candidates_from_trait_def(..)" ) ;
790
784
785
+ let tcx = selcx. tcx ( ) ;
791
786
// Check whether the self-type is itself a projection.
792
787
let ( def_id, substs) = match obligation_trait_ref. self_ty ( ) . sty {
793
788
ty:: TyProjection ( ref data) => {
794
- ( data. trait_ref . def_id , data. trait_ref . substs )
789
+ ( data. trait_ref ( tcx ) . def_id , data. substs )
795
790
}
796
791
ty:: TyAnon ( def_id, substs) => ( def_id, substs) ,
797
792
ty:: TyInfer ( ty:: TyVar ( _) ) => {
@@ -804,9 +799,9 @@ fn assemble_candidates_from_trait_def<'cx, 'gcx, 'tcx>(
804
799
} ;
805
800
806
801
// If so, extract what we know from the trait and try to come up with a good answer.
807
- let trait_predicates = selcx . tcx ( ) . predicates_of ( def_id) ;
808
- let bounds = trait_predicates. instantiate ( selcx . tcx ( ) , substs) ;
809
- let bounds = elaborate_predicates ( selcx . tcx ( ) , bounds. predicates ) ;
802
+ let trait_predicates = tcx. predicates_of ( def_id) ;
803
+ let bounds = trait_predicates. instantiate ( tcx, substs) ;
804
+ let bounds = elaborate_predicates ( tcx, bounds. predicates ) ;
810
805
assemble_candidates_from_predicates ( selcx,
811
806
obligation,
812
807
obligation_trait_ref,
@@ -1202,7 +1197,7 @@ fn confirm_callable_candidate<'cx, 'gcx, 'tcx>(
1202
1197
// Note: we unwrap the binder here but re-create it below (1)
1203
1198
let ty:: Binder ( ( trait_ref, ret_type) ) =
1204
1199
tcx. closure_trait_ref_and_return_type ( fn_once_def_id,
1205
- obligation. predicate . trait_ref . self_ty ( ) ,
1200
+ obligation. predicate . self_ty ( ) ,
1206
1201
fn_sig,
1207
1202
flag) ;
1208
1203
@@ -1227,7 +1222,7 @@ fn confirm_param_env_candidate<'cx, 'gcx, 'tcx>(
1227
1222
let infcx = selcx. infcx ( ) ;
1228
1223
let cause = obligation. cause . clone ( ) ;
1229
1224
let param_env = obligation. param_env ;
1230
- let trait_ref = obligation. predicate . trait_ref ;
1225
+ let trait_ref = obligation. predicate . trait_ref ( infcx . tcx ) ;
1231
1226
match infcx. match_poly_projection_predicate ( cause, param_env, poly_projection, trait_ref) {
1232
1227
Ok ( InferOk { value : ty_match, obligations } ) => {
1233
1228
Progress {
@@ -1267,7 +1262,7 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>(
1267
1262
// just return TyError.
1268
1263
debug ! ( "confirm_impl_candidate: no associated type {:?} for {:?}" ,
1269
1264
assoc_ty. item. name,
1270
- obligation. predicate. trait_ref ) ;
1265
+ obligation. predicate) ;
1271
1266
tcx. types . err
1272
1267
} else {
1273
1268
tcx. type_of ( assoc_ty. item . def_id )
0 commit comments