@@ -45,7 +45,7 @@ use hir_def::{
4545 TupleFieldId , TupleId , VariantId ,
4646 attrs:: AttrFlags ,
4747 expr_store:: { Body , ExpressionStore , HygieneId , path:: Path } ,
48- hir:: { BindingId , ExprId , ExprOrPatId , LabelId , PatId } ,
48+ hir:: { BindingId , ExprId , ExprOrPatId , LabelId , PatId , TypeRefIdOrConstRef } ,
4949 lang_item:: LangItems ,
5050 layout:: Integer ,
5151 resolver:: { HasResolver , ResolveValueResult , Resolver , TypeNs , ValueNs } ,
@@ -95,7 +95,7 @@ use crate::{
9595 } ,
9696 method_resolution:: CandidateId ,
9797 next_solver:: {
98- AliasTy , Const , ConstKind , DbInterner , ErrorGuaranteed , GenericArgs , Region ,
98+ AliasTy , Const , ConstKind , DbInterner , ErrorGuaranteed , GenericArgs , Region , StoredConst ,
9999 StoredGenericArg , StoredGenericArgs , StoredTy , StoredTys , Term , Ty , TyKind , Tys ,
100100 abi:: Safety ,
101101 infer:: { InferCtxt , ObligationInspector , traits:: ObligationCause } ,
@@ -705,6 +705,7 @@ pub struct InferenceResult {
705705 pub ( crate ) type_of_pat : ArenaMap < PatId , StoredTy > ,
706706 pub ( crate ) type_of_binding : ArenaMap < BindingId , StoredTy > ,
707707 pub ( crate ) type_of_type_placeholder : FxHashMap < TypeRefId , StoredTy > ,
708+ pub ( crate ) const_of_const_placeholder : FxHashMap < TypeRefIdOrConstRef , StoredConst > ,
708709 pub ( crate ) type_of_opaque : FxHashMap < InternedOpaqueTyId , StoredTy > ,
709710
710711 /// Whether there are any type-mismatching errors in the result.
@@ -1007,6 +1008,7 @@ impl InferenceResult {
10071008 type_of_pat : Default :: default ( ) ,
10081009 type_of_binding : Default :: default ( ) ,
10091010 type_of_type_placeholder : Default :: default ( ) ,
1011+ const_of_const_placeholder : Default :: default ( ) ,
10101012 type_of_opaque : Default :: default ( ) ,
10111013 skipped_ref_pats : Default :: default ( ) ,
10121014 has_errors : Default :: default ( ) ,
@@ -1082,6 +1084,16 @@ impl InferenceResult {
10821084 pub fn type_of_type_placeholder < ' db > ( & self , type_ref : TypeRefId ) -> Option < Ty < ' db > > {
10831085 self . type_of_type_placeholder . get ( & type_ref) . map ( |ty| ty. as_ref ( ) )
10841086 }
1087+ pub fn placeholder_consts < ' db > (
1088+ & self ,
1089+ ) -> impl Iterator < Item = ( TypeRefIdOrConstRef , Const < ' db > ) > {
1090+ self . const_of_const_placeholder
1091+ . iter ( )
1092+ . map ( |( & type_ref_or_const, const_) | ( type_ref_or_const, const_. as_ref ( ) ) )
1093+ }
1094+ pub fn const_of_const_placeholder < ' db > ( & self , expr : TypeRefIdOrConstRef ) -> Option < Const < ' db > > {
1095+ self . const_of_const_placeholder . get ( & expr) . map ( |ty| ty. as_ref ( ) )
1096+ }
10851097 pub fn type_of_expr_or_pat < ' db > ( & self , id : ExprOrPatId ) -> Option < Ty < ' db > > {
10861098 match id {
10871099 ExprOrPatId :: ExprId ( id) => self . type_of_expr . get ( id) . map ( |it| it. as_ref ( ) ) ,
@@ -1365,6 +1377,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> {
13651377 type_of_pat,
13661378 type_of_binding,
13671379 type_of_type_placeholder,
1380+ const_of_const_placeholder,
13681381 type_of_opaque,
13691382 has_errors : _,
13701383 diagnostics : _,
@@ -1396,6 +1409,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> {
13961409 merge_arena_maps ( type_of_pat, & other. type_of_pat ) ;
13971410 merge_arena_maps ( type_of_binding, & other. type_of_binding ) ;
13981411 merge_hash_maps ( type_of_type_placeholder, & other. type_of_type_placeholder ) ;
1412+ merge_hash_maps ( const_of_const_placeholder, & other. const_of_const_placeholder ) ;
13991413 merge_hash_maps ( type_of_opaque, & other. type_of_opaque ) ;
14001414 merge_hash_maps ( expr_adjustments, & other. expr_adjustments ) ;
14011415 merge_hash_maps ( pat_adjustments, & other. pat_adjustments ) ;
@@ -1531,6 +1545,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> {
15311545 type_of_pat,
15321546 type_of_binding,
15331547 type_of_type_placeholder,
1548+ const_of_const_placeholder,
15341549 type_of_opaque,
15351550 skipped_ref_pats,
15361551 closures_data,
@@ -1569,6 +1584,10 @@ impl<'body, 'db> InferenceContext<'body, 'db> {
15691584 resolver. resolve_completely ( ty) ;
15701585 }
15711586 type_of_type_placeholder. shrink_to_fit ( ) ;
1587+ for const_ in const_of_const_placeholder. values_mut ( ) {
1588+ resolver. resolve_completely ( const_) ;
1589+ }
1590+ const_of_const_placeholder. shrink_to_fit ( ) ;
15721591 type_of_opaque. shrink_to_fit ( ) ;
15731592
15741593 if let Some ( nodes_with_type_mismatches) = nodes_with_type_mismatches {
@@ -1868,6 +1887,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> {
18681887 InferenceTyDiagnosticSource :: Body => Some ( & mut InferenceTyLoweringVarsCtx {
18691888 table : & mut self . table ,
18701889 type_of_type_placeholder : & mut self . result . type_of_type_placeholder ,
1890+ const_of_const_placeholder : & mut self . result . const_of_const_placeholder ,
18711891 } as _ ) ,
18721892 InferenceTyDiagnosticSource :: Signature => None ,
18731893 } ;
@@ -2203,6 +2223,7 @@ impl<'body, 'db> InferenceContext<'body, 'db> {
22032223 let mut vars_ctx = InferenceTyLoweringVarsCtx {
22042224 table : & mut self . table ,
22052225 type_of_type_placeholder : & mut self . result . type_of_type_placeholder ,
2226+ const_of_const_placeholder : & mut self . result . const_of_const_placeholder ,
22062227 } ;
22072228 let mut ctx = TyLoweringContext :: new (
22082229 self . db ,
0 commit comments