mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 20:43:21 +00:00
Merge #5942
5942: Actually assert disjointness
r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
74e7422b69
1 changed files with 6 additions and 3 deletions
|
@ -119,7 +119,7 @@ impl TextEdit {
|
|||
return Err(other);
|
||||
}
|
||||
self.indels.extend(other.indels);
|
||||
assert!(check_disjoint(&mut self.indels));
|
||||
assert_disjoint(&mut self.indels);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ impl TextEditBuilder {
|
|||
}
|
||||
pub fn finish(self) -> TextEdit {
|
||||
let mut indels = self.indels;
|
||||
assert!(check_disjoint(&mut indels));
|
||||
assert_disjoint(&mut indels);
|
||||
TextEdit { indels }
|
||||
}
|
||||
pub fn invalidates_offset(&self, offset: TextSize) -> bool {
|
||||
|
@ -178,11 +178,14 @@ impl TextEditBuilder {
|
|||
fn indel(&mut self, indel: Indel) {
|
||||
self.indels.push(indel);
|
||||
if self.indels.len() <= 16 {
|
||||
check_disjoint(&mut self.indels);
|
||||
assert_disjoint(&mut self.indels);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_disjoint(indels: &mut [impl std::borrow::Borrow<Indel>]) {
|
||||
assert!(check_disjoint(indels));
|
||||
}
|
||||
fn check_disjoint(indels: &mut [impl std::borrow::Borrow<Indel>]) -> bool {
|
||||
indels.sort_by_key(|indel| (indel.borrow().delete.start(), indel.borrow().delete.end()));
|
||||
indels
|
||||
|
|
Loading…
Reference in a new issue