@@ -14,7 +14,6 @@ use middle::ty::{mod, AsPredicate, RegionEscape, Ty, ToPolyTraitRef};
14
14
use std:: collections:: HashSet ;
15
15
use std:: collections:: hash_map:: Entry :: { Occupied , Vacant } ;
16
16
use std:: default:: Default ;
17
- use std:: rc:: Rc ;
18
17
use syntax:: ast;
19
18
use util:: common:: ErrorReported ;
20
19
use util:: ppaux:: Repr ;
@@ -102,26 +101,30 @@ impl<'tcx> FulfillmentContext<'tcx> {
102
101
}
103
102
}
104
103
105
- pub fn normalize_associated_type < ' a > ( & mut self ,
104
+ /// "Normalize" a projection type `<SomeType as SomeTrait>::X` by
105
+ /// creating a fresh type variable `$0` as well as a projection
106
+ /// predicate `<SomeType as SomeTrait>::X == $0`. When the
107
+ /// inference engine runs, it will attempt to find an impl of
108
+ /// `SomeTrait` or a where clause that lets us unify `$0` with
109
+ /// something concrete. If this fails, we'll unify `$0` with
110
+ /// `projection_ty` again.
111
+ pub fn normalize_projection_type < ' a > ( & mut self ,
106
112
infcx : & InferCtxt < ' a , ' tcx > ,
107
- trait_ref : Rc < ty:: TraitRef < ' tcx > > ,
108
- item_name : ast:: Name ,
113
+ projection_ty : ty:: ProjectionTy < ' tcx > ,
109
114
cause : ObligationCause < ' tcx > )
110
115
-> Ty < ' tcx >
111
116
{
112
- debug ! ( "normalize_associated_type(trait_ref={}, item_name={})" ,
113
- trait_ref. repr( infcx. tcx) ,
114
- item_name. repr( infcx. tcx) ) ;
117
+ debug ! ( "normalize_associated_type(projection_ty={})" ,
118
+ projection_ty. repr( infcx. tcx) ) ;
115
119
116
- assert ! ( !trait_ref . has_escaping_regions( ) ) ;
120
+ assert ! ( !projection_ty . has_escaping_regions( ) ) ;
117
121
118
122
// FIXME(#20304) -- cache
119
123
120
124
let ty_var = infcx. next_ty_var ( ) ;
121
125
let projection =
122
126
ty:: Binder ( ty:: ProjectionPredicate {
123
- projection_ty : ty:: ProjectionTy { trait_ref : trait_ref,
124
- item_name : item_name } ,
127
+ projection_ty : projection_ty,
125
128
ty : ty_var
126
129
} ) ;
127
130
let obligation = Obligation :: new ( cause, projection. as_predicate ( ) ) ;
0 commit comments