mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Merge #11230
11230: fix: Fix attribute stripping ignoring doc comments r=Veykril a=Veykril Follow up to https://github.com/rust-analyzer/rust-analyzer/pull/11225#pullrequestreview-846779237 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
41a0e95d61
5 changed files with 35 additions and 18 deletions
|
@ -68,7 +68,7 @@ use once_cell::unsync::Lazy;
|
|||
use rustc_hash::FxHashSet;
|
||||
use stdx::{format_to, impl_from};
|
||||
use syntax::{
|
||||
ast::{self, HasAttrs as _, HasName},
|
||||
ast::{self, HasAttrs as _, HasDocComments, HasName},
|
||||
AstNode, AstPtr, SmolStr, SyntaxKind, SyntaxNodePtr,
|
||||
};
|
||||
use tt::{Ident, Leaf, Literal, TokenTree};
|
||||
|
@ -612,10 +612,13 @@ impl Module {
|
|||
}
|
||||
MacroCallKind::Attr { ast_id, invoc_attr_index, attr_name, .. } => {
|
||||
let node = ast_id.to_node(db.upcast());
|
||||
let attr =
|
||||
node.attrs().nth((*invoc_attr_index) as usize).unwrap_or_else(
|
||||
|| panic!("cannot find attribute #{}", invoc_attr_index),
|
||||
);
|
||||
let attr = node
|
||||
.doc_comments_and_attrs()
|
||||
.nth((*invoc_attr_index) as usize)
|
||||
.and_then(Either::right)
|
||||
.unwrap_or_else(|| {
|
||||
panic!("cannot find attribute #{}", invoc_attr_index)
|
||||
});
|
||||
(
|
||||
ast_id.with_value(SyntaxNodePtr::from(AstPtr::new(&attr))),
|
||||
Some(attr_name.clone()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue