Clippy: the gix NIF's casts, conversion and counter loop go

4bc5ec8 · Gabe Morell · 2026-11-05 00:26

4 files +10 -11
Message
{commit_body(@commit)}

Files changed

modified native/gitgud_gix/src/lib.rs
+10 −11
@@ -123,12 +123,12 @@ fn unix_to_datetime_term<'a>(env: Env<'a>, secs: i64) -> Term<'a> {
123 123 &[
124 124 (atoms::struct_key(), atoms::elixir_datetime().encode(env)),
125 125 (atoms::calendar(), atoms::calendar_iso().encode(env)),
126 − (atoms::year(), (dt.year() as i32).encode(env)),
127 − (atoms::month(), (dt.month() as u32).encode(env)),
128 − (atoms::day(), (dt.day() as u32).encode(env)),
129 − (atoms::hour(), (dt.hour() as u32).encode(env)),
130 − (atoms::minute(), (dt.minute() as u32).encode(env)),
131 − (atoms::second(), (dt.second() as u32).encode(env)),
126 + (atoms::year(), dt.year().encode(env)),
127 + (atoms::month(), dt.month().encode(env)),
128 + (atoms::day(), dt.day().encode(env)),
129 + (atoms::hour(), dt.hour().encode(env)),
130 + (atoms::minute(), dt.minute().encode(env)),
131 + (atoms::second(), dt.second().encode(env)),
132 132 (atoms::microsecond(), microsec_tuple),
133 133 (atoms::std_offset(), 0i32.encode(env)),
134 134 (atoms::utc_offset(), 0i32.encode(env)),
@@ -404,7 +404,7 @@ fn log<'a>(
404 404 break;
405 405 }
406 406
407 − let id: gix::ObjectId = info.id.into();
407 + let id: gix::ObjectId = info.id;
408 408 match commit_to_map(env, &repo, id) {
409 409 Ok(m) => commits.push(m),
410 410 Err(_) => continue,
@@ -498,13 +498,10 @@ fn last_touched<'a>(
498 498 let mut dir_tree_cache: HashMap<gix::ObjectId, Option<gix::ObjectId>> = HashMap::new();
499 499 let mut entry_cache: HashMap<gix::ObjectId, HashMap<String, gix::ObjectId>> = HashMap::new();
500 500
501 − let mut walked = 0usize;
502 −
503 − for info in walker {
501 + for (walked, info) in walker.enumerate() {
504 502 if pending.is_empty() || walked >= LAST_TOUCHED_MAX_COMMITS {
505 503 break;
506 504 }
507 − walked += 1;
508 505
509 506 let info = match info {
510 507 Ok(i) => i,
@@ -839,6 +836,8 @@ fn tree_of(repo: &gix::Repository, id: gix::ObjectId) -> Option<gix::ObjectId> {
839 836 // author/committer timestamp; the Elixir side unwraps the `DateTime`
840 837 // rather than teach Rust the struct.
841 838 #[rustler::nif(schedule = "DirtyCpu")]
839 +// A NIF's arguments are the Elixir call's; bundling them would only move the unpacking into Elixir.
840 +#[allow(clippy::too_many_arguments)]
842 841 fn nif_commit_tree<'a>(
843 842 env: Env<'a>,
844 843 path: String,

Parents: bb0fa26