@@ -40,33 +40,7 @@ impl InferenceContext<'_> {
40
40
}
41
41
42
42
fn resolve_value_path ( & mut self , path : & Path , id : ExprOrPatId ) -> Option < ValuePathResolution > {
43
- let ( value, self_subst) = if let Some ( type_ref) = path. type_anchor ( ) {
44
- let last = path. segments ( ) . last ( ) ?;
45
-
46
- // Don't use `self.make_ty()` here as we need `orig_ns`.
47
- let ctx =
48
- crate :: lower:: TyLoweringContext :: new ( self . db , & self . resolver , self . owner . into ( ) ) ;
49
- let ( ty, orig_ns) = ctx. lower_ty_ext ( type_ref) ;
50
- let ty = self . table . insert_type_vars ( ty) ;
51
- let ty = self . table . normalize_associated_types_in ( ty) ;
52
-
53
- let remaining_segments_for_ty = path. segments ( ) . take ( path. segments ( ) . len ( ) - 1 ) ;
54
- let ( ty, _) = ctx. lower_ty_relative_path ( ty, orig_ns, remaining_segments_for_ty) ;
55
- let ty = self . table . insert_type_vars ( ty) ;
56
- let ty = self . table . normalize_associated_types_in ( ty) ;
57
- self . resolve_ty_assoc_item ( ty, last. name , id) . map ( |( it, substs) | ( it, Some ( substs) ) ) ?
58
- } else {
59
- // FIXME: report error, unresolved first path segment
60
- let value_or_partial =
61
- self . resolver . resolve_path_in_value_ns ( self . db . upcast ( ) , path) ?;
62
-
63
- match value_or_partial {
64
- ResolveValueResult :: ValueNs ( it, _) => ( it, None ) ,
65
- ResolveValueResult :: Partial ( def, remaining_index, _) => self
66
- . resolve_assoc_item ( def, path, remaining_index, id)
67
- . map ( |( it, substs) | ( it, Some ( substs) ) ) ?,
68
- }
69
- } ;
43
+ let ( value, self_subst) = self . resolve_value_path_inner ( path, id) ?;
70
44
71
45
let value_def = match value {
72
46
ValueNs :: LocalBinding ( pat) => match self . result . type_of_binding . get ( pat) {
@@ -144,6 +118,41 @@ impl InferenceContext<'_> {
144
118
Some ( ValuePathResolution :: GenericDef ( value_def, generic_def, substs) )
145
119
}
146
120
121
+ pub ( super ) fn resolve_value_path_inner (
122
+ & mut self ,
123
+ path : & Path ,
124
+ id : ExprOrPatId ,
125
+ ) -> Option < ( ValueNs , Option < chalk_ir:: Substitution < Interner > > ) > {
126
+ let ( value, self_subst) = if let Some ( type_ref) = path. type_anchor ( ) {
127
+ let last = path. segments ( ) . last ( ) ?;
128
+
129
+ // Don't use `self.make_ty()` here as we need `orig_ns`.
130
+ let ctx =
131
+ crate :: lower:: TyLoweringContext :: new ( self . db , & self . resolver , self . owner . into ( ) ) ;
132
+ let ( ty, orig_ns) = ctx. lower_ty_ext ( type_ref) ;
133
+ let ty = self . table . insert_type_vars ( ty) ;
134
+ let ty = self . table . normalize_associated_types_in ( ty) ;
135
+
136
+ let remaining_segments_for_ty = path. segments ( ) . take ( path. segments ( ) . len ( ) - 1 ) ;
137
+ let ( ty, _) = ctx. lower_ty_relative_path ( ty, orig_ns, remaining_segments_for_ty) ;
138
+ let ty = self . table . insert_type_vars ( ty) ;
139
+ let ty = self . table . normalize_associated_types_in ( ty) ;
140
+ self . resolve_ty_assoc_item ( ty, last. name , id) . map ( |( it, substs) | ( it, Some ( substs) ) ) ?
141
+ } else {
142
+ // FIXME: report error, unresolved first path segment
143
+ let value_or_partial =
144
+ self . resolver . resolve_path_in_value_ns ( self . db . upcast ( ) , path) ?;
145
+
146
+ match value_or_partial {
147
+ ResolveValueResult :: ValueNs ( it, _) => ( it, None ) ,
148
+ ResolveValueResult :: Partial ( def, remaining_index, _) => self
149
+ . resolve_assoc_item ( def, path, remaining_index, id)
150
+ . map ( |( it, substs) | ( it, Some ( substs) ) ) ?,
151
+ }
152
+ } ;
153
+ Some ( ( value, self_subst) )
154
+ }
155
+
147
156
fn add_required_obligations_for_value_path ( & mut self , def : GenericDefId , subst : & Substitution ) {
148
157
let predicates = self . db . generic_predicates ( def) ;
149
158
for predicate in predicates. iter ( ) {
0 commit comments