@@ -35,17 +35,17 @@ impl<'a> InferenceContext<'a> {
35
35
let remaining_segments_for_ty = path. segments ( ) . take ( path. segments ( ) . len ( ) - 1 ) ;
36
36
let ctx = crate :: lower:: TyLoweringContext :: new ( self . db , & self . resolver ) ;
37
37
let ( ty, _) = ctx. lower_ty_relative_path ( ty, None , remaining_segments_for_ty) ;
38
- self . resolve_ty_assoc_item ( ty, last. name , id) ?
38
+ self . resolve_ty_assoc_item ( ty, last. name , id) . map ( | ( it , substs ) | ( it , Some ( substs ) ) ) ?
39
39
} else {
40
40
// FIXME: report error, unresolved first path segment
41
41
let value_or_partial =
42
42
self . resolver . resolve_path_in_value_ns ( self . db . upcast ( ) , path. mod_path ( ) ) ?;
43
43
44
44
match value_or_partial {
45
45
ResolveValueResult :: ValueNs ( it) => ( it, None ) ,
46
- ResolveValueResult :: Partial ( def, remaining_index) => {
47
- self . resolve_assoc_item ( def, path, remaining_index, id) ?
48
- }
46
+ ResolveValueResult :: Partial ( def, remaining_index) => self
47
+ . resolve_assoc_item ( def, path, remaining_index, id)
48
+ . map ( | ( it , substs ) | ( it , Some ( substs ) ) ) ? ,
49
49
}
50
50
} ;
51
51
@@ -113,7 +113,7 @@ impl<'a> InferenceContext<'a> {
113
113
path : & Path ,
114
114
remaining_index : usize ,
115
115
id : ExprOrPatId ,
116
- ) -> Option < ( ValueNs , Option < Substitution > ) > {
116
+ ) -> Option < ( ValueNs , Substitution ) > {
117
117
assert ! ( remaining_index < path. segments( ) . len( ) ) ;
118
118
// there may be more intermediate segments between the resolved one and
119
119
// the end. Only the last segment needs to be resolved to a value; from
@@ -166,7 +166,7 @@ impl<'a> InferenceContext<'a> {
166
166
trait_ref : TraitRef ,
167
167
segment : PathSegment < ' _ > ,
168
168
id : ExprOrPatId ,
169
- ) -> Option < ( ValueNs , Option < Substitution > ) > {
169
+ ) -> Option < ( ValueNs , Substitution ) > {
170
170
let trait_ = trait_ref. hir_trait_id ( ) ;
171
171
let item =
172
172
self . db . trait_data ( trait_) . items . iter ( ) . map ( |( _name, id) | ( * id) ) . find_map ( |item| {
@@ -202,16 +202,15 @@ impl<'a> InferenceContext<'a> {
202
202
} ;
203
203
204
204
self . write_assoc_resolution ( id, item, trait_ref. substitution . clone ( ) ) ;
205
- Some ( ( def, Some ( trait_ref. substitution ) ) )
205
+ Some ( ( def, trait_ref. substitution ) )
206
206
}
207
207
208
- // FIXME: Change sig to -> Option<(ValueNs, Substitution)>, subs aren't optional from here anymore
209
208
fn resolve_ty_assoc_item (
210
209
& mut self ,
211
210
ty : Ty ,
212
211
name : & Name ,
213
212
id : ExprOrPatId ,
214
- ) -> Option < ( ValueNs , Option < Substitution > ) > {
213
+ ) -> Option < ( ValueNs , Substitution ) > {
215
214
if let TyKind :: Error = ty. kind ( Interner ) {
216
215
return None ;
217
216
}
@@ -280,15 +279,15 @@ impl<'a> InferenceContext<'a> {
280
279
if !visible {
281
280
self . push_diagnostic ( InferenceDiagnostic :: PrivateAssocItem { id, item } ) ;
282
281
}
283
- Some ( ( def, Some ( substs) ) )
282
+ Some ( ( def, substs) )
284
283
}
285
284
286
285
fn resolve_enum_variant_on_ty (
287
286
& mut self ,
288
287
ty : & Ty ,
289
288
name : & Name ,
290
289
id : ExprOrPatId ,
291
- ) -> Option < ( ValueNs , Option < Substitution > ) > {
290
+ ) -> Option < ( ValueNs , Substitution ) > {
292
291
let ty = self . resolve_ty_shallow ( ty) ;
293
292
let ( enum_id, subst) = match ty. as_adt ( ) {
294
293
Some ( ( AdtId :: EnumId ( e) , subst) ) => ( e, subst) ,
@@ -298,6 +297,6 @@ impl<'a> InferenceContext<'a> {
298
297
let local_id = enum_data. variant ( name) ?;
299
298
let variant = EnumVariantId { parent : enum_id, local_id } ;
300
299
self . write_variant_resolution ( id, variant. into ( ) ) ;
301
- Some ( ( ValueNs :: EnumVariantId ( variant) , Some ( subst. clone ( ) ) ) )
300
+ Some ( ( ValueNs :: EnumVariantId ( variant) , subst. clone ( ) ) )
302
301
}
303
302
}
0 commit comments