@@ -41,10 +41,7 @@ use super::{
41
41
ApplicationTy , InEnvironment , ProjectionTy , Substs , TraitEnvironment , TraitRef , Ty , TypeCtor ,
42
42
TypeWalk , Uncertain ,
43
43
} ;
44
- use crate :: {
45
- db:: HirDatabase , ty:: infer:: diagnostics:: InferenceDiagnostic , AssocItem , DefWithBody ,
46
- VariantDef ,
47
- } ;
44
+ use crate :: { db:: HirDatabase , ty:: infer:: diagnostics:: InferenceDiagnostic , VariantDef } ;
48
45
49
46
macro_rules! ty_app {
50
47
( $ctor: pat, $param: pat) => {
@@ -62,15 +59,15 @@ mod pat;
62
59
mod coerce;
63
60
64
61
/// The entry point of type inference.
65
- pub fn infer_query ( db : & impl HirDatabase , def : DefWithBody ) -> Arc < InferenceResult > {
62
+ pub fn infer_query ( db : & impl HirDatabase , def : DefWithBodyId ) -> Arc < InferenceResult > {
66
63
let _p = profile ( "infer_query" ) ;
67
- let resolver = DefWithBodyId :: from ( def) . resolver ( db) ;
64
+ let resolver = def. resolver ( db) ;
68
65
let mut ctx = InferenceContext :: new ( db, def, resolver) ;
69
66
70
- match & def {
71
- DefWithBody :: Const ( c) => ctx. collect_const ( & db. const_data ( c. id ) ) ,
72
- DefWithBody :: Function ( f) => ctx. collect_fn ( & db. function_data ( f. id ) ) ,
73
- DefWithBody :: Static ( s) => ctx. collect_const ( & db. static_data ( s. id ) ) ,
67
+ match def {
68
+ DefWithBodyId :: ConstId ( c) => ctx. collect_const ( & db. const_data ( c) ) ,
69
+ DefWithBodyId :: FunctionId ( f) => ctx. collect_fn ( & db. function_data ( f) ) ,
70
+ DefWithBodyId :: StaticId ( s) => ctx. collect_const ( & db. static_data ( s) ) ,
74
71
}
75
72
76
73
ctx. infer_body ( ) ;
@@ -129,7 +126,7 @@ pub struct InferenceResult {
129
126
/// For each struct literal, records the variant it resolves to.
130
127
variant_resolutions : FxHashMap < ExprOrPatId , VariantDef > ,
131
128
/// For each associated item record what it resolves to
132
- assoc_resolutions : FxHashMap < ExprOrPatId , AssocItem > ,
129
+ assoc_resolutions : FxHashMap < ExprOrPatId , AssocItemId > ,
133
130
diagnostics : Vec < InferenceDiagnostic > ,
134
131
pub ( super ) type_of_expr : ArenaMap < ExprId , Ty > ,
135
132
pub ( super ) type_of_pat : ArenaMap < PatId , Ty > ,
@@ -152,10 +149,10 @@ impl InferenceResult {
152
149
pub fn variant_resolution_for_pat ( & self , id : PatId ) -> Option < VariantDef > {
153
150
self . variant_resolutions . get ( & id. into ( ) ) . copied ( )
154
151
}
155
- pub fn assoc_resolutions_for_expr ( & self , id : ExprId ) -> Option < AssocItem > {
152
+ pub fn assoc_resolutions_for_expr ( & self , id : ExprId ) -> Option < AssocItemId > {
156
153
self . assoc_resolutions . get ( & id. into ( ) ) . copied ( )
157
154
}
158
- pub fn assoc_resolutions_for_pat ( & self , id : PatId ) -> Option < AssocItem > {
155
+ pub fn assoc_resolutions_for_pat ( & self , id : PatId ) -> Option < AssocItemId > {
159
156
self . assoc_resolutions . get ( & id. into ( ) ) . copied ( )
160
157
}
161
158
pub fn type_mismatch_for_expr ( & self , expr : ExprId ) -> Option < & TypeMismatch > {
@@ -191,7 +188,7 @@ impl Index<PatId> for InferenceResult {
191
188
#[ derive( Clone , Debug ) ]
192
189
struct InferenceContext < ' a , D : HirDatabase > {
193
190
db : & ' a D ,
194
- owner : DefWithBody ,
191
+ owner : DefWithBodyId ,
195
192
body : Arc < Body > ,
196
193
resolver : Resolver ,
197
194
var_unification_table : InPlaceUnificationTable < TypeVarId > ,
@@ -209,7 +206,7 @@ struct InferenceContext<'a, D: HirDatabase> {
209
206
}
210
207
211
208
impl < ' a , D : HirDatabase > InferenceContext < ' a , D > {
212
- fn new ( db : & ' a D , owner : DefWithBody , resolver : Resolver ) -> Self {
209
+ fn new ( db : & ' a D , owner : DefWithBodyId , resolver : Resolver ) -> Self {
213
210
InferenceContext {
214
211
result : InferenceResult :: default ( ) ,
215
212
var_unification_table : InPlaceUnificationTable :: new ( ) ,
0 commit comments