Skip to content

Reduce the amount of code in unsafe blocks#1271

Merged
weihanglo merged 39 commits into
rust-lang:mainfrom
DanielEScherzer:less-unsafe
Jun 10, 2026
Merged

Reduce the amount of code in unsafe blocks#1271
weihanglo merged 39 commits into
rust-lang:mainfrom
DanielEScherzer:less-unsafe

Conversation

@DanielEScherzer

Copy link
Copy Markdown
Contributor

For statements that do not need to be marked as unsafe, pull them out of the blocks

@rustbot rustbot added the S-waiting-on-review Status: Waiting on review label Jun 1, 2026
Comment thread src/repo.rs
Comment on lines +388 to +397
let to;
let from;
let mode;
unsafe {
try_call!(raw::git_revparse(&mut raw, self.raw, spec));
let to = Binding::from_raw_opt(raw.to);
let from = Binding::from_raw_opt(raw.from);
let mode = RevparseMode::from_bits_truncate(raw.flags as u32);
Ok(Revspec::from_objects(from, to, mode))
to = Binding::from_raw_opt(raw.to);
from = Binding::from_raw_opt(raw.from);
mode = RevparseMode::from_bits_truncate(raw.flags as u32);
}
Ok(Revspec::from_objects(from, to, mode))

@weihanglo weihanglo Jun 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it, though this seems to be less ideal.

View changes since the review

@weihanglo weihanglo added this pull request to the merge queue Jun 10, 2026
Merged via the queue into rust-lang:main with commit 7415113 Jun 10, 2026
7 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Waiting on review label Jun 10, 2026
@DanielEScherzer DanielEScherzer deleted the less-unsafe branch June 10, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants