mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
fix: Fix ast-id up when merging raw attributes
This commit is contained in:
parent
ec3586eab9
commit
618cfd792c
6 changed files with 167 additions and 10 deletions
|
@ -124,13 +124,24 @@ impl RawAttrs {
|
|||
|
||||
pub(crate) fn merge(&self, other: Self) -> Self {
|
||||
// FIXME: This needs to fixup `AttrId`s
|
||||
match (&self.entries, &other.entries) {
|
||||
match (&self.entries, other.entries) {
|
||||
(None, None) => Self::EMPTY,
|
||||
(Some(entries), None) | (None, Some(entries)) => {
|
||||
Self { entries: Some(entries.clone()) }
|
||||
}
|
||||
(None, entries @ Some(_)) => Self { entries },
|
||||
(Some(entries), None) => Self { entries: Some(entries.clone()) },
|
||||
(Some(a), Some(b)) => {
|
||||
Self { entries: Some(a.iter().chain(b.iter()).cloned().collect()) }
|
||||
let last_ast_index = a.last().map_or(0, |it| it.id.ast_index + 1);
|
||||
Self {
|
||||
entries: Some(
|
||||
a.iter()
|
||||
.cloned()
|
||||
.chain(b.iter().map(|it| {
|
||||
let mut it = it.clone();
|
||||
it.id.ast_index += last_ast_index;
|
||||
it
|
||||
}))
|
||||
.collect(),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue