@@ -88,54 +88,52 @@ pub(crate) use closure::{CaptureKind, CapturedItem, CapturedItemWithoutTy};
8888
8989/// The entry point of type inference.
9090pub ( crate ) fn infer_query ( db : & dyn HirDatabase , def : DefWithBodyId ) -> Arc < InferenceResult > {
91- crate :: next_solver:: with_new_cache ( || {
92- let _p = tracing:: info_span!( "infer_query" ) . entered ( ) ;
93- let resolver = def. resolver ( db) ;
94- let body = db. body ( def) ;
95- let mut ctx = InferenceContext :: new ( db, def, & body, resolver) ;
96-
97- match def {
98- DefWithBodyId :: FunctionId ( f) => {
99- ctx. collect_fn ( f) ;
100- }
101- DefWithBodyId :: ConstId ( c) => ctx. collect_const ( c, & db. const_signature ( c) ) ,
102- DefWithBodyId :: StaticId ( s) => ctx. collect_static ( & db. static_signature ( s) ) ,
103- DefWithBodyId :: VariantId ( v) => {
104- ctx. return_ty = TyBuilder :: builtin (
105- match db. enum_signature ( v. lookup ( db) . parent ) . variant_body_type ( ) {
106- hir_def:: layout:: IntegerType :: Pointer ( signed) => match signed {
107- true => BuiltinType :: Int ( BuiltinInt :: Isize ) ,
108- false => BuiltinType :: Uint ( BuiltinUint :: Usize ) ,
109- } ,
110- hir_def:: layout:: IntegerType :: Fixed ( size, signed) => match signed {
111- true => BuiltinType :: Int ( match size {
112- Integer :: I8 => BuiltinInt :: I8 ,
113- Integer :: I16 => BuiltinInt :: I16 ,
114- Integer :: I32 => BuiltinInt :: I32 ,
115- Integer :: I64 => BuiltinInt :: I64 ,
116- Integer :: I128 => BuiltinInt :: I128 ,
117- } ) ,
118- false => BuiltinType :: Uint ( match size {
119- Integer :: I8 => BuiltinUint :: U8 ,
120- Integer :: I16 => BuiltinUint :: U16 ,
121- Integer :: I32 => BuiltinUint :: U32 ,
122- Integer :: I64 => BuiltinUint :: U64 ,
123- Integer :: I128 => BuiltinUint :: U128 ,
124- } ) ,
125- } ,
91+ let _p = tracing:: info_span!( "infer_query" ) . entered ( ) ;
92+ let resolver = def. resolver ( db) ;
93+ let body = db. body ( def) ;
94+ let mut ctx = InferenceContext :: new ( db, def, & body, resolver) ;
95+
96+ match def {
97+ DefWithBodyId :: FunctionId ( f) => {
98+ ctx. collect_fn ( f) ;
99+ }
100+ DefWithBodyId :: ConstId ( c) => ctx. collect_const ( c, & db. const_signature ( c) ) ,
101+ DefWithBodyId :: StaticId ( s) => ctx. collect_static ( & db. static_signature ( s) ) ,
102+ DefWithBodyId :: VariantId ( v) => {
103+ ctx. return_ty = TyBuilder :: builtin (
104+ match db. enum_signature ( v. lookup ( db) . parent ) . variant_body_type ( ) {
105+ hir_def:: layout:: IntegerType :: Pointer ( signed) => match signed {
106+ true => BuiltinType :: Int ( BuiltinInt :: Isize ) ,
107+ false => BuiltinType :: Uint ( BuiltinUint :: Usize ) ,
126108 } ,
127- ) ;
128- }
109+ hir_def:: layout:: IntegerType :: Fixed ( size, signed) => match signed {
110+ true => BuiltinType :: Int ( match size {
111+ Integer :: I8 => BuiltinInt :: I8 ,
112+ Integer :: I16 => BuiltinInt :: I16 ,
113+ Integer :: I32 => BuiltinInt :: I32 ,
114+ Integer :: I64 => BuiltinInt :: I64 ,
115+ Integer :: I128 => BuiltinInt :: I128 ,
116+ } ) ,
117+ false => BuiltinType :: Uint ( match size {
118+ Integer :: I8 => BuiltinUint :: U8 ,
119+ Integer :: I16 => BuiltinUint :: U16 ,
120+ Integer :: I32 => BuiltinUint :: U32 ,
121+ Integer :: I64 => BuiltinUint :: U64 ,
122+ Integer :: I128 => BuiltinUint :: U128 ,
123+ } ) ,
124+ } ,
125+ } ,
126+ ) ;
129127 }
128+ }
130129
131- ctx. infer_body ( ) ;
130+ ctx. infer_body ( ) ;
132131
133- ctx. infer_mut_body ( ) ;
132+ ctx. infer_mut_body ( ) ;
134133
135- ctx. infer_closures ( ) ;
134+ ctx. infer_closures ( ) ;
136135
137- Arc :: new ( ctx. resolve_all ( ) )
138- } )
136+ Arc :: new ( ctx. resolve_all ( ) )
139137}
140138
141139pub ( crate ) fn infer_cycle_result ( _: & dyn HirDatabase , _: DefWithBodyId ) -> Arc < InferenceResult > {
0 commit comments