Auto merge of #13604 - Veykril:hover-attr, r=Veykril

fix: Fix hover in attributed items not preferring similar kinded tokens
This commit is contained in:
bors 2022-11-11 12:48:48 +00:00
commit add85397ae

View file

@ -119,7 +119,14 @@ pub(crate) fn hover(
});
}
let in_attr = matches!(original_token.parent().and_then(ast::TokenTree::cast), Some(tt) if tt.syntax().ancestors().any(|it| ast::Meta::can_cast(it.kind())));
let in_attr = original_token
.parent_ancestors()
.filter_map(ast::Item::cast)
.any(|item| sema.is_attr_macro_call(&item))
&& !matches!(
original_token.parent().and_then(ast::TokenTree::cast),
Some(tt) if tt.syntax().ancestors().any(|it| ast::Meta::can_cast(it.kind()))
);
// prefer descending the same token kind in attribute expansions, in normal macros text
// equivalency is more important
let descended = if in_attr {