File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -291,15 +291,12 @@ impl SourceAnalyzer {
291
291
}
292
292
}
293
293
294
- if let Some ( pat) = parent ( )
295
- . and_then ( ast:: RecordPat :: cast)
296
- . map ( ast:: Pat :: from)
297
- . or_else ( || parent ( ) . and_then ( ast:: TupleStructPat :: cast) . map ( ast:: Pat :: from) )
298
- {
294
+ let record_pat = parent ( ) . and_then ( ast:: RecordPat :: cast) . map ( ast:: Pat :: from) ;
295
+ let tuple_struct_pat = || parent ( ) . and_then ( ast:: TupleStructPat :: cast) . map ( ast:: Pat :: from) ;
296
+ if let Some ( pat) = record_pat. or_else ( tuple_struct_pat) {
299
297
let pat_id = self . pat_id ( & pat) ?;
300
- if let Some ( VariantId :: EnumVariantId ( variant) ) =
301
- self . infer . as_ref ( ) ?. variant_resolution_for_pat ( pat_id)
302
- {
298
+ let variant_res_for_pat = self . infer . as_ref ( ) ?. variant_resolution_for_pat ( pat_id) ;
299
+ if let Some ( VariantId :: EnumVariantId ( variant) ) = variant_res_for_pat {
303
300
return Some ( PathResolution :: Def ( ModuleDef :: Variant ( variant. into ( ) ) ) ) ;
304
301
}
305
302
}
@@ -335,6 +332,9 @@ impl SourceAnalyzer {
335
332
}
336
333
}
337
334
} else if is_path_of_attr {
335
+ // Case where we are resolving the final path segment of a path in an attribute
336
+ // in this case we have to check for inert/builtin attributes and tools and prioritize
337
+ // resolution of attributes over other namesapces
338
338
let name_ref = path. as_single_name_ref ( ) ;
339
339
let builtin =
340
340
name_ref. as_ref ( ) . map ( ast:: NameRef :: text) . as_deref ( ) . and_then ( BuiltinAttr :: by_name) ;
Original file line number Diff line number Diff line change @@ -447,7 +447,7 @@ impl NameRefClass {
447
447
}
448
448
}
449
449
450
- if let Some ( path) = name_ref . syntax ( ) . ancestors ( ) . find_map ( ast :: Path :: cast ) {
450
+ if let Some ( path) = ast :: PathSegment :: cast ( parent . clone ( ) ) . map ( |it| it . parent_path ( ) ) {
451
451
if path. qualifier ( ) . is_none ( ) {
452
452
if let Some ( macro_call) = path. syntax ( ) . parent ( ) . and_then ( ast:: MacroCall :: cast) {
453
453
// Only use this to resolve single-segment macro calls like `foo!()`. Multi-segment
You can’t perform that action at this time.
0 commit comments