1
1
use rustc_middle:: traits:: ObligationCause ;
2
- use rustc_middle:: ty:: { self , Ty } ;
2
+ use rustc_middle:: ty;
3
3
4
4
use super :: InferCtxt ;
5
+ use crate :: infer:: Term ;
5
6
use crate :: traits:: { Obligation , PredicateObligations } ;
6
7
7
8
impl < ' tcx > InferCtxt < ' tcx > {
@@ -11,24 +12,32 @@ impl<'tcx> InferCtxt<'tcx> {
11
12
/// of the given projection. This allows us to proceed with projections
12
13
/// while they cannot be resolved yet due to missing information or
13
14
/// 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 (
15
16
& self ,
16
17
param_env : ty:: ParamEnv < ' tcx > ,
17
- projection_ty : ty:: AliasTy < ' tcx > ,
18
+ alias_term : ty:: AliasTerm < ' tcx > ,
18
19
cause : ObligationCause < ' tcx > ,
19
20
recursion_depth : usize ,
20
21
obligations : & mut PredicateObligations < ' tcx > ,
21
- ) -> Ty < ' tcx > {
22
+ ) -> Term < ' tcx > {
22
23
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
+
24
32
let projection =
25
33
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 ,
28
36
} ) ) ;
29
37
let obligation =
30
38
Obligation :: with_depth ( self . tcx , cause, recursion_depth, param_env, projection) ;
31
39
obligations. push ( obligation) ;
32
- ty_var
40
+
41
+ infer_var
33
42
}
34
43
}
0 commit comments