History

chore: Prepare for Rust edition bump to 2024 (without autofix) (#27791)

Successor to #27779 - in this PR I've applied changes manually, without futzing with if let lifetimes at all. Release Notes: - N/A

Piotr Osiewicz committed 1 year ago

Commit 0729d241 parent d51aa2f162 files · +2316 −1920Browse files

Showing the changes to crates/buffer_diff/src/buffer_diff.rs (1 of 162 files). Show all

Unified · Split

crates/buffer_diff/src/buffer_diff.rs+64−61
@@ -433,79 +433,82 @@ impl BufferDiffInner { · 432 unmodified lines
433 433
434 let max_point = buffer.max_point();434 let max_point = buffer.max_point();
435 let mut summaries = buffer.summaries_for_anchors_with_payload::<Point, _, _>(anchor_iter);435 let mut summaries = buffer.summaries_for_anchors_with_payload::<Point, _, _>(anchor_iter);
436 iter::from_fn(move || loop {436 iter::from_fn(move || {
437 let (start_point, (start_anchor, start_base)) = summaries.next()?;437 loop {
438 let (mut end_point, (mut end_anchor, end_base)) = summaries.next()?;438 let (start_point, (start_anchor, start_base)) = summaries.next()?;
439 439 let (mut end_point, (mut end_anchor, end_base)) = summaries.next()?;
440 if !start_anchor.is_valid(buffer) {
441 continue;
442 }
443
444 if end_point.column > 0 && end_point < max_point {
445 end_point.row += 1;
446 end_point.column = 0;
447 end_anchor = buffer.anchor_before(end_point);
448 }
449
450 let mut secondary_status = DiffHunkSecondaryStatus::NoSecondaryHunk;
451
452 let mut has_pending = false;
453 if start_anchor
454 .cmp(&pending_hunks_cursor.start().buffer_range.start, buffer)
455 .is_gt()
456 {
457 pending_hunks_cursor.seek_forward(&start_anchor, Bias::Left, buffer);
458 }
459 440
460 if let Some(pending_hunk) = pending_hunks_cursor.item() {441 if !start_anchor.is_valid(buffer) {
461 let mut pending_range = pending_hunk.buffer_range.to_point(buffer);442 continue;
462 if pending_range.end.column > 0 {
463 pending_range.end.row += 1;
464 pending_range.end.column = 0;
465 }443 }
466 444
467 if pending_range == (start_point..end_point) {445 if end_point.column > 0 && end_point < max_point {
468 if !buffer.has_edits_since_in_range(446 end_point.row += 1;
469 &pending_hunk.buffer_version,447 end_point.column = 0;
470 start_anchor..end_anchor,448 end_anchor = buffer.anchor_before(end_point);
471 ) {
472 has_pending = true;
473 secondary_status = pending_hunk.new_status;
474 }
475 }449 }
476 }
477 450
478 if let (Some(secondary_cursor), false) = (secondary_cursor.as_mut(), has_pending) {451 let mut secondary_status = DiffHunkSecondaryStatus::NoSecondaryHunk;
452
453 let mut has_pending = false;
479 if start_anchor454 if start_anchor
480 .cmp(&secondary_cursor.start().buffer_range.start, buffer)455 .cmp(&pending_hunks_cursor.start().buffer_range.start, buffer)
481 .is_gt()456 .is_gt()
482 {457 {
483 secondary_cursor.seek_forward(&start_anchor, Bias::Left, buffer);458 pending_hunks_cursor.seek_forward(&start_anchor, Bias::Left, buffer);
484 }459 }
485 460
486 if let Some(secondary_hunk) = secondary_cursor.item() {461 if let Some(pending_hunk) = pending_hunks_cursor.item() {
487 let mut secondary_range = secondary_hunk.buffer_range.to_point(buffer);462 let mut pending_range = pending_hunk.buffer_range.to_point(buffer);
488 if secondary_range.end.column > 0 {463 if pending_range.end.column > 0 {
489 secondary_range.end.row += 1;464 pending_range.end.row += 1;
490 secondary_range.end.column = 0;465 pending_range.end.column = 0;
466 }
467
468 if pending_range == (start_point..end_point) {
469 if !buffer.has_edits_since_in_range(
470 &pending_hunk.buffer_version,
471 start_anchor..end_anchor,
472 ) {
473 has_pending = true;
474 secondary_status = pending_hunk.new_status;
475 }
491 }476 }
492 if secondary_range.is_empty() && secondary_hunk.diff_base_byte_range.is_empty()477 }
478
479 if let (Some(secondary_cursor), false) = (secondary_cursor.as_mut(), has_pending) {
480 if start_anchor
481 .cmp(&secondary_cursor.start().buffer_range.start, buffer)
482 .is_gt()
493 {483 {
494 // ignore484 secondary_cursor.seek_forward(&start_anchor, Bias::Left, buffer);
495 } else if secondary_range == (start_point..end_point) {485 }
496 secondary_status = DiffHunkSecondaryStatus::HasSecondaryHunk;486
497 } else if secondary_range.start <= end_point {487 if let Some(secondary_hunk) = secondary_cursor.item() {
498 secondary_status = DiffHunkSecondaryStatus::OverlapsWithSecondaryHunk;488 let mut secondary_range = secondary_hunk.buffer_range.to_point(buffer);
489 if secondary_range.end.column > 0 {
490 secondary_range.end.row += 1;
491 secondary_range.end.column = 0;
492 }
493 if secondary_range.is_empty()
494 && secondary_hunk.diff_base_byte_range.is_empty()
495 {
496 // ignore
497 } else if secondary_range == (start_point..end_point) {
498 secondary_status = DiffHunkSecondaryStatus::HasSecondaryHunk;
499 } else if secondary_range.start <= end_point {
500 secondary_status = DiffHunkSecondaryStatus::OverlapsWithSecondaryHunk;
501 }
499 }502 }
500 }503 }
501 }
502 504
503 return Some(DiffHunk {505 return Some(DiffHunk {
504 range: start_point..end_point,506 range: start_point..end_point,
505 diff_base_byte_range: start_base..end_base,507 diff_base_byte_range: start_base..end_base,
506 buffer_range: start_anchor..end_anchor,508 buffer_range: start_anchor..end_anchor,
507 secondary_status,509 secondary_status,
508 });510 });
511 }
509 })512 })
510 }513 }
511 514
@@ -776,7 +779,7 @@ impl BufferDiff { · 264 unmodified lines
776 language: Option<Arc<Language>>,779 language: Option<Arc<Language>>,
777 language_registry: Option<Arc<LanguageRegistry>>,780 language_registry: Option<Arc<LanguageRegistry>>,
778 cx: &mut App,781 cx: &mut App,
779 ) -> impl Future<Output = BufferDiffInner> {782 ) -> impl Future<Output = BufferDiffInner> + use<> {
780 let base_text_pair;783 let base_text_pair;
781 let base_text_exists;784 let base_text_exists;
782 let base_text_snapshot;785 let base_text_snapshot;
@@ -818,7 +821,7 @@ impl BufferDiff { · 35 unmodified lines
818 base_text: Option<Arc<String>>,821 base_text: Option<Arc<String>>,
819 base_text_snapshot: language::BufferSnapshot,822 base_text_snapshot: language::BufferSnapshot,
820 cx: &App,823 cx: &App,
821 ) -> impl Future<Output = BufferDiffInner> {824 ) -> impl Future<Output = BufferDiffInner> + use<> {
822 let base_text_exists = base_text.is_some();825 let base_text_exists = base_text.is_some();
823 let base_text_pair = base_text.map(|text| (text, base_text_snapshot.as_rope().clone()));826 let base_text_pair = base_text.map(|text| (text, base_text_snapshot.as_rope().clone()));
824 cx.background_spawn(async move {827 cx.background_spawn(async move {
@@ -2071,7 +2074,7 @@ mod tests { · 1246 unmodified lines
2071 )2074 )
2072 });2075 });
2073 let working_copy = working_copy.read_with(cx, |working_copy, _| working_copy.snapshot());2076 let working_copy = working_copy.read_with(cx, |working_copy, _| working_copy.snapshot());
2074 let mut index_text = if rng.gen() {2077 let mut index_text = if rng.r#gen() {
2075 Rope::from(head_text.as_str())2078 Rope::from(head_text.as_str())
2076 } else {2079 } else {
2077 working_copy.as_rope().clone()2080 working_copy.as_rope().clone()

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t