11use rustc_ast:: ast:: Attribute ;
22use rustc_ast:: tokenstream:: TokenStream ;
33use rustc_index:: IndexVec ;
4- use rustc_middle:: ty as mir_ty;
54use rustc_span:: symbol:: { Ident , Symbol } ;
65
76use crate :: annot;
7+ use crate :: chc;
88use crate :: rty;
99
1010pub fn requires_path ( ) -> [ Symbol ; 2 ] {
@@ -31,64 +31,50 @@ pub fn callable_path() -> [Symbol; 2] {
3131 [ Symbol :: intern ( "thrust" ) , Symbol :: intern ( "callable" ) ]
3232}
3333
34- fn ty_to_term_kind ( ty : & mir_ty:: Ty < ' _ > ) -> annot:: TermKind {
35- match ty. kind ( ) {
36- mir_ty:: TyKind :: Ref ( _, ty, mir_ty:: Mutability :: Mut ) => {
37- annot:: TermKind :: mut_ ( ty_to_term_kind ( ty) )
38- }
39- mir_ty:: TyKind :: Ref ( _, ty, mir_ty:: Mutability :: Not ) => {
40- annot:: TermKind :: box_ ( ty_to_term_kind ( ty) )
41- }
42- mir_ty:: TyKind :: Adt ( def, _) if def. is_box ( ) => annot:: TermKind :: box_ ( ty_to_term_kind ( ty) ) ,
43- _ => annot:: TermKind :: other ( ) ,
44- }
45- }
46-
4734#[ derive( Debug , Clone , Default ) ]
4835pub struct ParamResolver {
49- params : IndexVec < rty:: FunctionParamIdx , ( Symbol , annot :: TermKind ) > ,
36+ params : IndexVec < rty:: FunctionParamIdx , ( Symbol , chc :: Sort ) > ,
5037}
5138
5239impl annot:: Resolver for ParamResolver {
5340 type Output = rty:: FunctionParamIdx ;
54- fn resolve ( & self , ident : Ident ) -> Option < ( Self :: Output , annot :: TermKind ) > {
41+ fn resolve ( & self , ident : Ident ) -> Option < ( Self :: Output , chc :: Sort ) > {
5542 self . params
5643 . iter_enumerated ( )
5744 . find ( |( _, ( name, _) ) | name == & ident. name )
58- . map ( |( idx, ( _, kind ) ) | ( idx, kind . clone ( ) ) )
45+ . map ( |( idx, ( _, sort ) ) | ( idx, sort . clone ( ) ) )
5946 }
6047}
6148
6249impl ParamResolver {
63- pub fn push_param ( & mut self , name : Symbol , ty : & mir_ty :: Ty < ' _ > ) {
64- self . params . push ( ( name, ty_to_term_kind ( ty ) ) ) ;
50+ pub fn push_param ( & mut self , name : Symbol , sort : chc :: Sort ) {
51+ self . params . push ( ( name, sort ) ) ;
6552 }
6653}
6754
6855#[ derive( Debug , Clone ) ]
6956pub struct ResultResolver {
7057 result_symbol : Symbol ,
71- result_kind : annot :: TermKind ,
58+ result_sort : chc :: Sort ,
7259}
7360
7461impl annot:: Resolver for ResultResolver {
7562 type Output = rty:: RefinedTypeVar < rty:: FunctionParamIdx > ;
76- fn resolve ( & self , ident : Ident ) -> Option < ( Self :: Output , annot :: TermKind ) > {
63+ fn resolve ( & self , ident : Ident ) -> Option < ( Self :: Output , chc :: Sort ) > {
7764 if ident. name == self . result_symbol {
78- Some ( ( rty:: RefinedTypeVar :: Value , self . result_kind . clone ( ) ) )
65+ Some ( ( rty:: RefinedTypeVar :: Value , self . result_sort . clone ( ) ) )
7966 } else {
8067 None
8168 }
8269 }
8370}
8471
8572impl ResultResolver {
86- pub fn new ( result_ty : & mir_ty :: Ty < ' _ > ) -> Self {
73+ pub fn new ( result_sort : chc :: Sort ) -> Self {
8774 let result_symbol = Symbol :: intern ( "result" ) ;
88- let result_kind = ty_to_term_kind ( result_ty) ;
8975 Self {
9076 result_symbol,
91- result_kind ,
77+ result_sort ,
9278 }
9379 }
9480}
0 commit comments