Skip to content

Commit d1b40aa

Browse files
committed
Drop lifetime for MergeFileResult
I feel comfortable not tying the lifetime here, since libgit2 fairly clearly keeps only owned data in git_merge_file_result, without any pointers to anything outside of it.
1 parent 197106b commit d1b40aa

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

Diff for: src/merge.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ pub struct MergeFileOptions {
3434
}
3535

3636
/// Information about file-level merging.
37-
pub struct MergeFileResult<'repo> {
37+
pub struct MergeFileResult {
3838
raw: raw::git_merge_file_result,
39-
_marker: marker::PhantomData<&'repo str>,
4039
}
4140

4241
impl<'repo> AnnotatedCommit<'repo> {
@@ -354,7 +353,7 @@ impl MergeFileOptions {
354353
}
355354
}
356355

357-
impl<'repo> MergeFileResult<'repo> {
356+
impl MergeFileResult {
358357
/// True if the output was automerged, false if the output contains
359358
/// conflict markers.
360359
pub fn is_automergeable(&self) -> bool {
@@ -381,31 +380,28 @@ impl<'repo> MergeFileResult<'repo> {
381380
}
382381

383382
/// The contents of the merge.
384-
pub fn content(&self) -> &'repo [u8] {
383+
pub fn content(&self) -> &[u8] {
385384
unsafe { std::slice::from_raw_parts(self.raw.ptr as *const u8, self.raw.len as usize) }
386385
}
387386
}
388387

389-
impl<'repo> Binding for MergeFileResult<'repo> {
388+
impl Binding for MergeFileResult {
390389
type Raw = raw::git_merge_file_result;
391-
unsafe fn from_raw(raw: raw::git_merge_file_result) -> MergeFileResult<'repo> {
392-
MergeFileResult {
393-
raw,
394-
_marker: marker::PhantomData,
395-
}
390+
unsafe fn from_raw(raw: raw::git_merge_file_result) -> MergeFileResult {
391+
MergeFileResult { raw }
396392
}
397393
fn raw(&self) -> raw::git_merge_file_result {
398394
unimplemented!()
399395
}
400396
}
401397

402-
impl<'repo> Drop for MergeFileResult<'repo> {
398+
impl Drop for MergeFileResult {
403399
fn drop(&mut self) {
404400
unsafe { raw::git_merge_file_result_free(&mut self.raw) }
405401
}
406402
}
407403

408-
impl<'repo> std::fmt::Debug for MergeFileResult<'repo> {
404+
impl std::fmt::Debug for MergeFileResult {
409405
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
410406
let mut ds = f.debug_struct("MergeFileResult");
411407
if let Some(path) = &self.path() {

Diff for: src/repo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2576,7 +2576,7 @@ impl Repository {
25762576
ours: &IndexEntry,
25772577
theirs: &IndexEntry,
25782578
opts: Option<&mut MergeFileOptions>,
2579-
) -> Result<MergeFileResult<'_>, Error> {
2579+
) -> Result<MergeFileResult, Error> {
25802580
unsafe {
25812581
let (ancestor, _ancestor_path) = ancestor.to_raw()?;
25822582
let (ours, _ours_path) = ours.to_raw()?;

0 commit comments

Comments
 (0)