11use rustc_middle:: traits:: ObligationCause ;
2- use rustc_middle:: ty:: { self , Ty } ;
2+ use rustc_middle:: ty;
33
44use super :: InferCtxt ;
5+ use crate :: infer:: Term ;
56use crate :: traits:: { Obligation , PredicateObligations } ;
67
78impl < ' tcx > InferCtxt < ' tcx > {
@@ -11,24 +12,32 @@ impl<'tcx> InferCtxt<'tcx> {
1112 /// of the given projection. This allows us to proceed with projections
1213 /// while they cannot be resolved yet due to missing information or
1314 /// simply due to the lack of access to the trait resolution machinery.
14- pub fn projection_ty_to_infer (
15+ pub fn projection_term_to_infer (
1516 & self ,
1617 param_env : ty:: ParamEnv < ' tcx > ,
17- projection_ty : ty:: AliasTy < ' tcx > ,
18+ alias_term : ty:: AliasTerm < ' tcx > ,
1819 cause : ObligationCause < ' tcx > ,
1920 recursion_depth : usize ,
2021 obligations : & mut PredicateObligations < ' tcx > ,
21- ) -> Ty < ' tcx > {
22+ ) -> Term < ' tcx > {
2223 debug_assert ! ( !self . next_trait_solver( ) ) ;
23- let ty_var = self . next_ty_var ( self . tcx . def_span ( projection_ty. def_id ) ) ;
24+
25+ let span = self . tcx . def_span ( alias_term. def_id ) ;
26+ let infer_var = if alias_term. kind ( self . tcx ) . is_type ( ) {
27+ self . next_ty_var ( span) . into ( )
28+ } else {
29+ self . next_const_var ( span) . into ( )
30+ } ;
31+
2432 let projection =
2533 ty:: PredicateKind :: Clause ( ty:: ClauseKind :: Projection ( ty:: ProjectionPredicate {
26- projection_term : projection_ty . into ( ) ,
27- term : ty_var . into ( ) ,
34+ projection_term : alias_term ,
35+ term : infer_var ,
2836 } ) ) ;
2937 let obligation =
3038 Obligation :: with_depth ( self . tcx , cause, recursion_depth, param_env, projection) ;
3139 obligations. push ( obligation) ;
32- ty_var
40+
41+ infer_var
3342 }
3443}
0 commit comments