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
433433
434434 let max_point = buffer.max_point();
435435 let mut summaries = buffer.summaries_for_anchors_with_payload::<Point, _, _>(anchor_iter);
436− iter::from_fn(move || loop {
437− let (start_point, (start_anchor, start_base)) = summaries.next()?;
438− let (mut end_point, (mut end_anchor, end_base)) = summaries.next()?;
439−
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− }
436+ iter::from_fn(move || {
437+ loop {
438+ let (start_point, (start_anchor, start_base)) = summaries.next()?;
439+ let (mut end_point, (mut end_anchor, end_base)) = summaries.next()?;
459440
460− if let Some(pending_hunk) = pending_hunks_cursor.item() {
461− let mut pending_range = pending_hunk.buffer_range.to_point(buffer);
462− if pending_range.end.column > 0 {
463− pending_range.end.row += 1;
464− pending_range.end.column = 0;
441+ if !start_anchor.is_valid(buffer) {
442+ continue;
465443 }
466444
467− if pending_range == (start_point..end_point) {
468− if !buffer.has_edits_since_in_range(
469− &pending_hunk.buffer_version,
470− start_anchor..end_anchor,
471− ) {
472− has_pending = true;
473− secondary_status = pending_hunk.new_status;
474− }
445+ if end_point.column > 0 && end_point < max_point {
446+ end_point.row += 1;
447+ end_point.column = 0;
448+ end_anchor = buffer.anchor_before(end_point);
475449 }
476− }
477450
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;
479454 if start_anchor
480− .cmp(&secondary_cursor.start().buffer_range.start, buffer)
455+ .cmp(&pending_hunks_cursor.start().buffer_range.start, buffer)
481456 .is_gt()
482457 {
483− secondary_cursor.seek_forward(&start_anchor, Bias::Left, buffer);
458+ pending_hunks_cursor.seek_forward(&start_anchor, Bias::Left, buffer);
484459 }
485460
486− if let Some(secondary_hunk) = secondary_cursor.item() {
487− let mut secondary_range = secondary_hunk.buffer_range.to_point(buffer);
488− if secondary_range.end.column > 0 {
489− secondary_range.end.row += 1;
490− secondary_range.end.column = 0;
461+ if let Some(pending_hunk) = pending_hunks_cursor.item() {
462+ let mut pending_range = pending_hunk.buffer_range.to_point(buffer);
463+ if pending_range.end.column > 0 {
464+ pending_range.end.row += 1;
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+ }
491476 }
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()
493483 {
494− // ignore
495− } else if secondary_range == (start_point..end_point) {
496− secondary_status = DiffHunkSecondaryStatus::HasSecondaryHunk;
497− } else if secondary_range.start <= end_point {
498− secondary_status = DiffHunkSecondaryStatus::OverlapsWithSecondaryHunk;
484+ secondary_cursor.seek_forward(&start_anchor, Bias::Left, buffer);
485+ }
486+
487+ if let Some(secondary_hunk) = secondary_cursor.item() {
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+ }
499502 }
500503 }
501− }
502504
503− return Some(DiffHunk {
504− range: start_point..end_point,
505− diff_base_byte_range: start_base..end_base,
506− buffer_range: start_anchor..end_anchor,
507− secondary_status,
508− });
505+ return Some(DiffHunk {
506+ range: start_point..end_point,
507+ diff_base_byte_range: start_base..end_base,
508+ buffer_range: start_anchor..end_anchor,
509+ secondary_status,
510+ });
511+ }
509512 })
510513 }
511514
@@ -776,7 +779,7 @@ impl BufferDiff { · 264 unmodified lines
776779 language: Option<Arc<Language>>,
777780 language_registry: Option<Arc<LanguageRegistry>>,
778781 cx: &mut App,
779− ) -> impl Future<Output = BufferDiffInner> {
782+ ) -> impl Future<Output = BufferDiffInner> + use<> {
780783 let base_text_pair;
781784 let base_text_exists;
782785 let base_text_snapshot;
@@ -818,7 +821,7 @@ impl BufferDiff { · 35 unmodified lines
818821 base_text: Option<Arc<String>>,
819822 base_text_snapshot: language::BufferSnapshot,
820823 cx: &App,
821− ) -> impl Future<Output = BufferDiffInner> {
824+ ) -> impl Future<Output = BufferDiffInner> + use<> {
822825 let base_text_exists = base_text.is_some();
823826 let base_text_pair = base_text.map(|text| (text, base_text_snapshot.as_rope().clone()));
824827 cx.background_spawn(async move {
@@ -2071,7 +2074,7 @@ mod tests { · 1246 unmodified lines
20712074 )
20722075 });
20732076 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() {
20752078 Rope::from(head_text.as_str())
20762079 } else {
20772080 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