Skip to content

Commit 4d873b2

Browse files
reconcile: clarify return type of assignments
This function never returns `Error`, so remove `Return` from its return type. (This function seems to never have been able to return `Error` since its creation in 0e13f5c (Refactor, 2025-06-04).) This helps analysis of the situations in which its callers can return `Error`. This analysis will be done in a subsequent commit.
1 parent 1b1927a commit 4d873b2

File tree

2 files changed

+15
-24
lines changed

2 files changed

+15
-24
lines changed

crates/but-hunk-assignment/src/lib.rs

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ pub fn assign(
275275
&applied_stacks,
276276
MultipleOverlapping::SetMostLines,
277277
true,
278-
)?;
278+
);
279279

280280
// Reconcile with the requested changes
281281
let with_requests = reconcile::assignments(
@@ -284,7 +284,7 @@ pub fn assign(
284284
&applied_stacks,
285285
MultipleOverlapping::SetMostLines,
286286
true,
287-
)?;
287+
);
288288

289289
// Reconcile with hunk locks
290290
let lock_assignments = hunk_dependency_assignments(deps)?;
@@ -294,7 +294,7 @@ pub fn assign(
294294
&applied_stacks,
295295
MultipleOverlapping::SetNone,
296296
false,
297-
)?;
297+
);
298298

299299
state::set_assignments(db, with_locks.clone())?;
300300

@@ -410,7 +410,7 @@ fn reconcile_with_worktree_and_locks(
410410
&applied_stacks,
411411
MultipleOverlapping::SetMostLines,
412412
true,
413-
)?;
413+
);
414414

415415
let lock_assignments = hunk_dependency_assignments(deps)?;
416416
let with_locks = reconcile::assignments(
@@ -419,7 +419,7 @@ fn reconcile_with_worktree_and_locks(
419419
&applied_stacks,
420420
MultipleOverlapping::SetNone,
421421
set_assignment_from_locks,
422-
)?;
422+
);
423423

424424
Ok(with_locks)
425425
}
@@ -718,8 +718,7 @@ mod tests {
718718
&applied_stacks,
719719
MultipleOverlapping::SetMostLines,
720720
true,
721-
)
722-
.unwrap();
721+
);
723722
assert_eq(
724723
result,
725724
vec![
@@ -740,8 +739,7 @@ mod tests {
740739
&applied_stacks,
741740
MultipleOverlapping::SetMostLines,
742741
true,
743-
)
744-
.unwrap();
742+
);
745743
assert_eq(
746744
result,
747745
vec![HunkAssignment::new("foo.rs", 10, 5, None, Some(1))],
@@ -759,8 +757,7 @@ mod tests {
759757
&applied_stacks,
760758
MultipleOverlapping::SetMostLines,
761759
true,
762-
)
763-
.unwrap();
760+
);
764761
assert_eq(
765762
result,
766763
vec![HunkAssignment::new("foo.rs", 12, 7, Some(1), Some(1))],
@@ -781,8 +778,7 @@ mod tests {
781778
&applied_stacks,
782779
MultipleOverlapping::SetMostLines,
783780
true,
784-
)
785-
.unwrap();
781+
);
786782
assert_eq(
787783
result,
788784
vec![HunkAssignment::new("foo.rs", 5, 18, Some(2), Some(2))],
@@ -803,8 +799,7 @@ mod tests {
803799
&applied_stacks,
804800
MultipleOverlapping::SetNone,
805801
true,
806-
)
807-
.unwrap();
802+
);
808803
assert_eq(
809804
result,
810805
vec![HunkAssignment::new("foo.rs", 5, 18, None, Some(2))],
@@ -822,8 +817,7 @@ mod tests {
822817
&applied_stacks,
823818
MultipleOverlapping::SetMostLines,
824819
false,
825-
)
826-
.unwrap();
820+
);
827821
// TODO: This is actually broken
828822
assert_eq!(
829823
result,
@@ -987,8 +981,7 @@ mod tests {
987981
&applied_stacks,
988982
MultipleOverlapping::SetMostLines,
989983
true,
990-
)
991-
.unwrap();
984+
);
992985

993986
// Binary file should maintain its stack assignment
994987
assert_eq!(
@@ -1032,8 +1025,7 @@ mod tests {
10321025
&applied_stacks,
10331026
MultipleOverlapping::SetMostLines,
10341027
true,
1035-
)
1036-
.unwrap();
1028+
);
10371029

10381030
assert_eq!(
10391031
result[0].stack_id,

crates/but-hunk-assignment/src/reconcile.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::cmp::Ordering;
22

3-
use anyhow::Result;
43
use but_core::ref_metadata::StackId;
54
use itertools::Itertools;
65

@@ -57,7 +56,7 @@ pub(crate) fn assignments(
5756
applied_stack_ids: &[StackId],
5857
multiple_overlapping_resolution: MultipleOverlapping,
5958
update_unassigned: bool,
60-
) -> Result<Vec<HunkAssignment>> {
59+
) -> Vec<HunkAssignment> {
6160
let mut reconciled = vec![];
6261
for new_assignment in new {
6362
let mut new_assignment = new_assignment.clone();
@@ -93,5 +92,5 @@ pub(crate) fn assignments(
9392
}
9493
reconciled.push(new_assignment);
9594
}
96-
Ok(reconciled)
95+
reconciled
9796
}

0 commit comments

Comments
 (0)