mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-03 09:07:26 +00:00
fix: correct extend_to logic in parser
Previously we swapped to events in the buffer, but that might be wrong if there aer `forward_parent` links pointing to the swapped-out node. Let's do the same via parent links instead, keeping the nodes in place
This commit is contained in:
parent
6997adfee7
commit
7dc331faef
2 changed files with 11 additions and 9 deletions
|
@ -340,10 +340,14 @@ impl CompletedMarker {
|
|||
|
||||
/// Extends this completed marker *to the left* up to `m`.
|
||||
pub(crate) fn extend_to(self, p: &mut Parser, mut m: Marker) {
|
||||
assert!(m.pos <= self.pos);
|
||||
m.bomb.defuse();
|
||||
|
||||
p.events.swap(self.pos as usize, m.pos as usize);
|
||||
let idx = m.pos as usize;
|
||||
match &mut p.events[idx] {
|
||||
Event::Start { forward_parent, .. } => {
|
||||
*forward_parent = Some(self.pos - m.pos);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn kind(&self) -> SyntaxKind {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue