@@ -33,9 +33,9 @@ use std::{cell::OnceCell, convert::identity, iter};
3333use base_db:: Crate ;
3434use either:: Either ;
3535use hir_def:: {
36- AdtId , AnonConstId , AssocItemId , ConstId , ConstParamId , DefWithBodyId , ExpressionStoreOwner ,
37- FieldId , FunctionId , GenericDefId , GenericParamId , ItemContainerId , LocalFieldId , Lookup ,
38- TraitId , TupleFieldId , TupleId , TypeAliasId , TypeOrConstParamId , VariantId ,
36+ AdtId , AssocItemId , ConstId , ConstParamId , DefWithBodyId , ExpressionStoreOwner , FieldId ,
37+ FunctionId , GenericDefId , GenericParamId , ItemContainerId , LocalFieldId , Lookup , TraitId ,
38+ TupleFieldId , TupleId , TypeAliasId , TypeOrConstParamId , VariantId ,
3939 expr_store:: { ConstExprOrigin , ExpressionStore , HygieneId , path:: Path } ,
4040 hir:: { BindingAnnotation , BindingId , ExprId , ExprOrPatId , LabelId , PatId } ,
4141 lang_item:: LangItems ,
@@ -146,6 +146,10 @@ pub fn infer_query_with_inspect<'db>(
146146
147147 ctx. infer_mut_body ( body. body_expr ) ;
148148
149+ finalize_infer ( ctx)
150+ }
151+
152+ fn finalize_infer ( mut ctx : InferenceContext < ' _ , ' _ > ) -> InferenceResult {
149153 ctx. handle_opaque_type_uses ( ) ;
150154
151155 ctx. type_inference_fallback ( ) ;
@@ -213,9 +217,7 @@ fn infer_signature_query(db: &dyn HirDatabase, def: GenericDefId) -> InferenceRe
213217 ctx. infer_expr ( root_expr, & expected, ExprIsRead :: Yes ) ;
214218 }
215219
216- ctx. type_inference_fallback ( ) ;
217- ctx. table . select_obligations_where_possible ( ) ;
218- ctx. resolve_all ( )
220+ finalize_infer ( ctx)
219221}
220222
221223fn infer_signature_cycle_result (
@@ -618,24 +620,6 @@ impl InferenceResult {
618620}
619621
620622impl InferenceResult {
621- /// Look up inference results for a specific anonymous const in a signature.
622- ///
623- /// This delegates to [`Self::for_signature`] on the anon const's owner.
624- /// The returned `InferenceResult` contains types for *all* expressions in
625- /// the owner's signature store, not just this anon const's sub-tree.
626- /// Callers should index into it with `loc.expr` to get the root expression's
627- /// type.
628- // FIXME: This function doesn't make sense in that we can't return a full inference result here
629- // as the anon const is just part of an inference result.
630- pub fn for_anon_const ( db : & dyn HirDatabase , id : AnonConstId ) -> & InferenceResult {
631- match id. lookup ( db) . owner {
632- ExpressionStoreOwner :: Signature ( generic_def_id) => {
633- Self :: for_signature ( db, generic_def_id)
634- }
635- ExpressionStoreOwner :: Body ( def_with_body_id) => Self :: for_body ( db, def_with_body_id) ,
636- }
637- }
638-
639623 fn new ( error_ty : Ty < ' _ > ) -> Self {
640624 Self {
641625 method_resolutions : Default :: default ( ) ,
@@ -943,8 +927,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> {
943927 db. trait_environment_for_body ( def_with_body_id)
944928 }
945929 } ;
946- let table =
947- unify:: InferenceTable :: new ( db, trait_env, resolver. krate ( ) , owner. as_def_with_body ( ) ) ;
930+ let table = unify:: InferenceTable :: new ( db, trait_env, resolver. krate ( ) , Some ( owner) ) ;
948931 let types = crate :: next_solver:: default_types ( db) ;
949932 InferenceContext {
950933 result : InferenceResult :: new ( types. types . error ) ,
0 commit comments