1- use crate :: {
2- prelude:: * ,
3- ty:: { TypeVarId , TypeVars } ,
4- } ;
1+ use crate :: prelude:: * ;
52
63use hir:: * ;
74
8- #[ derive( Clone , Debug ) ]
95pub struct Thir < ' hir > {
10- pub hir : & ' hir Hir ,
11- pub types : HashMap < TypeVarId , TypeId > ,
12- pub type_vars : TypeVars ,
13- }
14-
15- impl Deref for Thir < ' _ > {
16- type Target = Hir ;
17-
18- fn deref ( & self ) -> & Self :: Target {
19- self . hir
20- }
21- }
22-
23- impl < ' hir > Thir < ' hir > {
24- pub fn new ( hir : & ' hir Hir , types : HashMap < TypeVarId , TypeId > , type_vars : TypeVars ) -> Self {
25- Self {
26- hir,
27- types,
28- type_vars,
29- }
30- }
31-
32- pub fn type_of ( & self , id : impl Into < TypeVar > ) -> TypeId {
33- let var = self . type_vars . get ( id. into ( ) ) ;
34- self . types [ & var]
35- }
36- }
37-
38- pub struct Thir2 < ' hir > {
396 pub hir : & ' hir Hir ,
407 pub identifier_tys : BTreeMap < IdentifierBindingId , TypeId > ,
418 pub expression_tys : IndexedVec < ExpressionId , TypeId > ,
429}
4310
44- impl Deref for Thir2 < ' _ > {
11+ impl Deref for Thir < ' _ > {
4512 type Target = Hir ;
4613
4714 fn deref ( & self ) -> & Self :: Target {
4815 self . hir
4916 }
5017}
5118
52- impl < ' hir > Thir2 < ' hir > {
19+ impl < ' hir > Thir < ' hir > {
5320 pub fn new (
5421 hir : & ' hir Hir ,
5522 identifiers_tys : BTreeMap < IdentifierBindingId , TypeId > ,
@@ -68,17 +35,17 @@ impl<'hir> Thir2<'hir> {
6835}
6936
7037pub trait ThirIndex : Copy {
71- fn type_of ( self , thir : & Thir2 < ' _ > ) -> TypeId ;
38+ fn type_of ( self , thir : & Thir < ' _ > ) -> TypeId ;
7239}
7340
7441impl ThirIndex for IdentifierBindingId {
75- fn type_of ( self , thir : & Thir2 < ' _ > ) -> TypeId {
42+ fn type_of ( self , thir : & Thir < ' _ > ) -> TypeId {
7643 thir. identifier_tys [ & self ]
7744 }
7845}
7946
8047impl ThirIndex for ExpressionId {
81- fn type_of ( self , thir : & Thir2 < ' _ > ) -> TypeId {
48+ fn type_of ( self , thir : & Thir < ' _ > ) -> TypeId {
8249 thir. expression_tys [ self ]
8350 }
8451}
0 commit comments