From 5f690e4bcef945f8bba50fd600cdc354c774a76c Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Mon, 15 Jun 2026 10:39:27 -0700 Subject: [PATCH] [Clippy] Add clippy to CI, allow current violations at a module level Add clippy to CI so that future changes do not increase the number of violations. The existing violations are allowlisted on a module level (i.e. at the top of files with inner attributes, or above the start of nested inline test modules with outer attributes). CI runs clippy on both Window and Linux because some lints may fire on one but not the other; see, e.g. #1238. Existing violations will be addressed in subsequent pull requests. --- .github/workflows/main.yml | 28 ++++++++++++++++++++++++++++ examples/add.rs | 1 + examples/clone.rs | 2 ++ examples/diff.rs | 3 +++ examples/init.rs | 1 + examples/log.rs | 2 ++ examples/pull.rs | 3 +++ examples/rev-list.rs | 1 + examples/tag.rs | 1 + libgit2-sys/build.rs | 3 +++ libgit2-sys/lib.rs | 1 + src/apply.rs | 4 ++++ src/blame.rs | 5 +++++ src/blob.rs | 2 ++ src/branch.rs | 2 ++ src/buf.rs | 2 ++ src/build.rs | 5 +++++ src/call.rs | 1 + src/cherrypick.rs | 2 ++ src/commit.rs | 4 ++++ src/config.rs | 3 +++ src/cred.rs | 9 +++++++++ src/diff.rs | 7 +++++++ src/email.rs | 2 ++ src/error.rs | 2 ++ src/index.rs | 2 ++ src/indexer.rs | 3 +++ src/lib.rs | 3 +++ src/mailmap.rs | 1 + src/merge.rs | 3 +++ src/message.rs | 5 +++++ src/odb.rs | 7 +++++++ src/oid_array.rs | 2 ++ src/opts.rs | 2 ++ src/packbuilder.rs | 3 +++ src/pathspec.rs | 1 + src/rebase.rs | 4 ++++ src/reference.rs | 3 +++ src/reflog.rs | 2 ++ src/remote.rs | 7 +++++++ src/remote_callbacks.rs | 2 ++ src/repo.rs | 11 +++++++++++ src/revert.rs | 2 ++ src/stash.rs | 3 +++ src/status.rs | 3 +++ src/string_array.rs | 2 ++ src/submodule.rs | 6 ++++++ src/tag.rs | 5 +++++ src/test.rs | 2 ++ src/transport.rs | 4 ++++ src/tree.rs | 6 ++++++ src/util.rs | 5 +++++ src/worktree.rs | 3 +++ tests/end_to_end.rs | 4 ++++ tests/global_state.rs | 2 ++ 55 files changed, 204 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 132a3575ed..50125f30ed 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,6 +47,34 @@ jobs: - run: cargo run -p systest - run: cargo run -p systest --features unstable-sha256 + clippy: + name: Clippy + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + build: [stable, beta, windows] + include: + - build: stable + os: ubuntu-latest + rust: stable + - build: beta + os: ubuntu-latest + rust: beta + - build: windows + os: windows-2022 + rust: stable + steps: + - uses: actions/checkout@master + with: + submodules: true + - name: Install Rust (rustup) + run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} + shell: bash + - name: Install Clippy (rustup) + run: rustup component add clippy + - run: cargo clippy --all-targets --all-features -- -Dwarnings + rustfmt: name: Rustfmt runs-on: ubuntu-latest diff --git a/examples/add.rs b/examples/add.rs index 57c9bb10a9..82f988147f 100644 --- a/examples/add.rs +++ b/examples/add.rs @@ -14,6 +14,7 @@ #![deny(warnings)] #![allow(trivial_casts)] +#![allow(clippy::needless_borrows_for_generic_args)] use clap::Parser; use git2::Repository; diff --git a/examples/clone.rs b/examples/clone.rs index f6d00b14b6..0511b75655 100644 --- a/examples/clone.rs +++ b/examples/clone.rs @@ -13,6 +13,8 @@ */ #![deny(warnings)] +#![allow(clippy::explicit_auto_deref)] +#![allow(clippy::manual_checked_ops)] use clap::Parser; use git2::build::{CheckoutBuilder, RepoBuilder}; diff --git a/examples/diff.rs b/examples/diff.rs index 87f9da5c11..23792abff9 100644 --- a/examples/diff.rs +++ b/examples/diff.rs @@ -13,6 +13,9 @@ */ #![deny(warnings)] +#![allow(clippy::explicit_auto_deref)] +#![allow(clippy::needless_borrows_for_generic_args)] +#![allow(clippy::redundant_closure)] use clap::Parser; use git2::{Blob, Diff, DiffOptions, Error, Object, ObjectType, Oid, Repository}; diff --git a/examples/init.rs b/examples/init.rs index 6a3bf2ed53..5a4a1ad7dd 100644 --- a/examples/init.rs +++ b/examples/init.rs @@ -13,6 +13,7 @@ */ #![deny(warnings)] +#![allow(clippy::manual_strip)] use clap::Parser; use git2::ObjectFormat; diff --git a/examples/log.rs b/examples/log.rs index 22c7a5d785..a5059fc6b7 100644 --- a/examples/log.rs +++ b/examples/log.rs @@ -13,6 +13,8 @@ */ #![deny(warnings)] +#![allow(clippy::manual_strip)] +#![allow(clippy::needless_borrowed_reference)] use clap::Parser; use git2::{Commit, DiffOptions, ObjectType, Repository, Signature, Time}; diff --git a/examples/pull.rs b/examples/pull.rs index ac1b4b7e0e..5bc66ac431 100644 --- a/examples/pull.rs +++ b/examples/pull.rs @@ -12,6 +12,9 @@ * . */ +#![allow(clippy::needless_borrow)] +#![allow(clippy::needless_question_mark)] + use clap::Parser; use git2::Repository; use std::io::{self, Write}; diff --git a/examples/rev-list.rs b/examples/rev-list.rs index 2eaed78e9a..be0987fc85 100644 --- a/examples/rev-list.rs +++ b/examples/rev-list.rs @@ -14,6 +14,7 @@ */ #![deny(warnings)] +#![allow(clippy::manual_strip)] use clap::Parser; use git2::{Error, Oid, Repository, Revwalk}; diff --git a/examples/tag.rs b/examples/tag.rs index 86fa9aca11..e8c64ae4ee 100644 --- a/examples/tag.rs +++ b/examples/tag.rs @@ -13,6 +13,7 @@ */ #![deny(warnings)] +#![allow(clippy::explicit_auto_deref)] use clap::Parser; use git2::{Commit, Error, Repository, Tag}; diff --git a/libgit2-sys/build.rs b/libgit2-sys/build.rs index 8407f114b7..6a31eb7bc0 100644 --- a/libgit2-sys/build.rs +++ b/libgit2-sys/build.rs @@ -1,3 +1,6 @@ +#![allow(clippy::needless_borrows_for_generic_args)] +#![allow(clippy::unnecessary_map_or)] + use std::env; use std::fs; use std::io; diff --git a/libgit2-sys/lib.rs b/libgit2-sys/lib.rs index 40de36c54e..a6703d26bf 100644 --- a/libgit2-sys/lib.rs +++ b/libgit2-sys/lib.rs @@ -1,5 +1,6 @@ #![doc(html_root_url = "https://docs.rs/libgit2-sys/0.18")] #![allow(non_camel_case_types, unused_extern_crates)] +#![allow(clippy::legacy_numeric_constants)] // This is required to link libz when libssh2-sys is not included. extern crate libz_sys as libz; diff --git a/src/apply.rs b/src/apply.rs index 34dc811a01..406e96286f 100644 --- a/src/apply.rs +++ b/src/apply.rs @@ -1,6 +1,9 @@ //! git_apply support //! see original: +#![allow(clippy::missing_safety_doc)] +#![allow(clippy::new_without_default)] + use crate::{panic, raw, util::Binding, DiffDelta, DiffHunk}; use libc::c_int; use std::{ffi::c_void, mem}; @@ -149,6 +152,7 @@ impl<'cb> ApplyOptions<'cb> { } #[cfg(test)] +#[allow(clippy::needless_borrows_for_generic_args)] mod tests { use super::*; use std::{fs::File, io::Write, path::Path}; diff --git a/src/blame.rs b/src/blame.rs index 52c0255198..8290c176ea 100644 --- a/src/blame.rs +++ b/src/blame.rs @@ -1,3 +1,5 @@ +#![allow(clippy::redundant_closure)] + use crate::util::{self, Binding}; use crate::{raw, signature, Error, Oid, Repository, Signature}; use libc::c_char; @@ -388,6 +390,9 @@ impl<'blame> FusedIterator for BlameIter<'blame> {} impl<'blame> ExactSizeIterator for BlameIter<'blame> {} #[cfg(test)] +#[allow(clippy::bool_assert_comparison)] +#[allow(clippy::needless_borrow)] +#[allow(clippy::needless_borrows_for_generic_args)] mod tests { use std::fs::{self, File}; use std::path::Path; diff --git a/src/blob.rs b/src/blob.rs index 68cc72c294..c73862ddd9 100644 --- a/src/blob.rs +++ b/src/blob.rs @@ -1,3 +1,5 @@ +#![allow(clippy::io_other_error)] + use std::io; use std::marker; use std::mem; diff --git a/src/branch.rs b/src/branch.rs index b0a3cb470a..ffcccecfb6 100644 --- a/src/branch.rs +++ b/src/branch.rs @@ -1,3 +1,5 @@ +#![allow(clippy::missing_safety_doc)] + use std::ffi::CString; use std::marker; use std::ptr; diff --git a/src/buf.rs b/src/buf.rs index 4e40cc91bb..754fd93ad5 100644 --- a/src/buf.rs +++ b/src/buf.rs @@ -1,3 +1,5 @@ +#![allow(clippy::explicit_auto_deref)] + use std::ops::{Deref, DerefMut}; use std::ptr; use std::slice; diff --git a/src/build.rs b/src/build.rs index c1c9cfd227..0b27006718 100644 --- a/src/build.rs +++ b/src/build.rs @@ -1,5 +1,8 @@ //! Builder-pattern objects for configuration various git operations. +#![allow(clippy::manual_non_exhaustive)] +#![allow(clippy::missing_safety_doc)] + use libc::{c_char, c_int, c_uint, c_void, size_t}; use std::ffi::{CStr, CString}; use std::mem; @@ -767,6 +770,8 @@ impl TreeUpdateBuilder { } #[cfg(test)] +#[allow(clippy::needless_borrow)] +#[allow(clippy::needless_borrows_for_generic_args)] mod tests { use super::{CheckoutBuilder, RepoBuilder, TreeUpdateBuilder}; use crate::{CheckoutNotificationType, FileMode, Repository}; diff --git a/src/call.rs b/src/call.rs index 9aa3ae667f..210d5e3409 100644 --- a/src/call.rs +++ b/src/call.rs @@ -1,3 +1,4 @@ +#![allow(clippy::needless_lifetimes)] #![macro_use] use crate::Error; diff --git a/src/cherrypick.rs b/src/cherrypick.rs index 51005264ba..81e11e94a2 100644 --- a/src/cherrypick.rs +++ b/src/cherrypick.rs @@ -1,3 +1,5 @@ +#![allow(clippy::new_without_default)] + use std::mem; use crate::build::CheckoutBuilder; diff --git a/src/commit.rs b/src/commit.rs index 860bbc2d66..7acaaddbc3 100644 --- a/src/commit.rs +++ b/src/commit.rs @@ -1,3 +1,5 @@ +#![allow(clippy::redundant_closure)] + use std::iter::FusedIterator; use std::marker; use std::mem; @@ -413,6 +415,8 @@ impl<'repo> Drop for Commit<'repo> { } #[cfg(test)] +#[allow(clippy::bool_assert_comparison)] +#[allow(clippy::let_and_return)] mod tests { #[test] fn smoke() { diff --git a/src/config.rs b/src/config.rs index 68729abfd6..f4ab82dd64 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,3 +1,5 @@ +#![allow(clippy::should_implement_trait)] + use std::ffi::CString; use std::marker; use std::path::{Path, PathBuf}; @@ -639,6 +641,7 @@ impl<'cfg> Drop for ConfigEntry<'cfg> { } #[cfg(test)] +#[allow(clippy::bool_assert_comparison)] mod tests { use std::fs::File; use tempfile::TempDir; diff --git a/src/cred.rs b/src/cred.rs index cfec9d9d7a..999570fdaa 100644 --- a/src/cred.rs +++ b/src/cred.rs @@ -1,3 +1,10 @@ +#![allow(clippy::manual_strip)] +#![allow(clippy::match_result_ok)] +#![allow(clippy::missing_safety_doc)] +#![allow(clippy::needless_borrowed_reference)] +#![allow(clippy::needless_borrows_for_generic_args)] +#![allow(clippy::should_implement_trait)] + #[cfg(feature = "cred")] use log::{debug, trace}; use std::ffi::CString; @@ -495,6 +502,8 @@ impl CredentialHelper { #[cfg(test)] #[cfg(feature = "cred")] +#[allow(clippy::unused_io_amount)] +#[allow(clippy::useless_conversion)] mod test { use std::env; use std::fs::File; diff --git a/src/diff.rs b/src/diff.rs index 13c35c29da..ad74a2696a 100644 --- a/src/diff.rs +++ b/src/diff.rs @@ -1,3 +1,7 @@ +#![allow(clippy::empty_docs)] +#![allow(clippy::missing_safety_doc)] +#![allow(clippy::new_without_default)] + use libc::{c_char, c_int, c_void, size_t}; use std::ffi::CString; use std::iter::FusedIterator; @@ -1588,6 +1592,9 @@ impl DiffPatchidOptions { } #[cfg(test)] +#[allow(clippy::assign_op_pattern)] +#[allow(clippy::needless_borrows_for_generic_args)] +#[allow(clippy::while_let_on_iterator)] mod tests { #[cfg(feature = "unstable-sha256")] use crate::Diff; diff --git a/src/email.rs b/src/email.rs index 8b5f46f9f4..14218b06d7 100644 --- a/src/email.rs +++ b/src/email.rs @@ -1,3 +1,5 @@ +#![allow(clippy::too_many_arguments)] + use std::ffi::CString; use std::{mem, ptr}; diff --git a/src/error.rs b/src/error.rs index 01e2742c1f..ba4d3afb8f 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,3 +1,5 @@ +#![allow(clippy::should_implement_trait)] + use libc::c_int; use std::env::JoinPathsError; use std::error; diff --git a/src/index.rs b/src/index.rs index 8972cb9492..01ed103402 100644 --- a/src/index.rs +++ b/src/index.rs @@ -882,6 +882,8 @@ impl Binding for IndexEntry { } #[cfg(test)] +#[allow(clippy::needless_borrow)] +#[allow(clippy::needless_borrows_for_generic_args)] mod tests { use std::fs::{self, File}; use std::path::Path; diff --git a/src/indexer.rs b/src/indexer.rs index 72984582a7..045d22cf90 100644 --- a/src/indexer.rs +++ b/src/indexer.rs @@ -1,3 +1,5 @@ +#![allow(clippy::io_other_error)] + use std::ffi::CStr; use std::path::Path; use std::{io, marker, mem, ptr}; @@ -242,6 +244,7 @@ impl Drop for Indexer<'_> { } #[cfg(test)] +#[allow(clippy::unused_io_amount)] mod tests { use crate::{Buf, Indexer}; use std::io::prelude::*; diff --git a/src/lib.rs b/src/lib.rs index 91f253611d..e44b4a39c3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -70,6 +70,9 @@ #![deny(missing_docs)] #![warn(rust_2018_idioms)] #![cfg_attr(test, deny(warnings))] +#![allow(clippy::needless_lifetimes)] +#![allow(clippy::should_implement_trait)] +#![allow(clippy::unnecessary_cast)] use bitflags::bitflags; use libgit2_sys as raw; diff --git a/src/mailmap.rs b/src/mailmap.rs index affb0b2f1a..1166d01a55 100644 --- a/src/mailmap.rs +++ b/src/mailmap.rs @@ -93,6 +93,7 @@ impl Mailmap { } #[cfg(test)] +#[allow(clippy::needless_borrow)] mod tests { use super::*; diff --git a/src/merge.rs b/src/merge.rs index 75264315ca..7263bfa3a2 100644 --- a/src/merge.rs +++ b/src/merge.rs @@ -1,3 +1,6 @@ +#![allow(clippy::missing_safety_doc)] +#![allow(clippy::redundant_closure)] + use libc::{c_char, c_uint, c_ushort, size_t}; use std::ffi::CString; use std::marker; diff --git a/src/message.rs b/src/message.rs index 3edfd4e5f0..cbd929fffd 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,3 +1,7 @@ +#![allow(clippy::len_without_is_empty)] +#![allow(clippy::needless_borrow)] +#![allow(clippy::redundant_closure)] + use core::ops::Range; use std::ffi::CStr; use std::ffi::CString; @@ -237,6 +241,7 @@ fn to_bytes_tuple(trailers: &MessageTrailers, index: usize) -> (&[u8], &[u8]) { } #[cfg(test)] +#[allow(clippy::char_lit_as_u8)] mod tests { #[test] diff --git a/src/odb.rs b/src/odb.rs index f6af9c5c13..d854093159 100644 --- a/src/odb.rs +++ b/src/odb.rs @@ -1,3 +1,8 @@ +#![allow(clippy::io_other_error)] +#![allow(clippy::len_without_is_empty)] +#![allow(clippy::single_match)] +#![allow(clippy::should_implement_trait)] + use std::io; use std::marker; use std::ptr; @@ -579,6 +584,8 @@ pub(crate) extern "C" fn write_pack_progress_cb( } #[cfg(test)] +#[allow(clippy::bool_assert_comparison)] +#[allow(clippy::unused_io_amount)] mod tests { use crate::{Buf, ObjectType, Oid, Repository}; use std::io::prelude::*; diff --git a/src/oid_array.rs b/src/oid_array.rs index 0d87ce9954..87abef2974 100644 --- a/src/oid_array.rs +++ b/src/oid_array.rs @@ -1,5 +1,7 @@ //! Bindings to libgit2's raw `git_oidarray` type +#![allow(clippy::extra_unused_lifetimes)] + use std::ops::Deref; use crate::oid::Oid; diff --git a/src/opts.rs b/src/opts.rs index 232d81e996..facf5896e5 100644 --- a/src/opts.rs +++ b/src/opts.rs @@ -1,5 +1,7 @@ //! Bindings to libgit2's git_libgit2_opts function. +#![allow(clippy::missing_safety_doc)] + use std::ffi::CString; use std::ptr; diff --git a/src/packbuilder.rs b/src/packbuilder.rs index 4f673957c4..8d4c3279d2 100644 --- a/src/packbuilder.rs +++ b/src/packbuilder.rs @@ -1,3 +1,5 @@ +#![allow(clippy::redundant_closure)] + use libc::{c_int, c_uint, c_void, size_t}; use std::marker; use std::path::Path; @@ -296,6 +298,7 @@ extern "C" fn progress_c( } #[cfg(test)] +#[allow(clippy::bool_assert_comparison)] mod tests { use crate::Buf; diff --git a/src/pathspec.rs b/src/pathspec.rs index 19939ecac6..3ba0594267 100644 --- a/src/pathspec.rs +++ b/src/pathspec.rs @@ -337,6 +337,7 @@ impl<'list> FusedIterator for PathspecFailedEntries<'list> {} impl<'list> ExactSizeIterator for PathspecFailedEntries<'list> {} #[cfg(test)] +#[allow(clippy::needless_borrows_for_generic_args)] mod tests { use super::Pathspec; use crate::PathspecFlags; diff --git a/src/rebase.rs b/src/rebase.rs index 9c89b1133a..1020812110 100644 --- a/src/rebase.rs +++ b/src/rebase.rs @@ -1,3 +1,7 @@ +#![allow(clippy::len_without_is_empty)] +#![allow(clippy::needless_option_take)] +#![allow(clippy::redundant_closure)] + use std::ffi::CString; use std::{marker, mem, ptr, str}; diff --git a/src/reference.rs b/src/reference.rs index 1c51873d2a..f69f9b6b10 100644 --- a/src/reference.rs +++ b/src/reference.rs @@ -1,3 +1,5 @@ +#![allow(clippy::redundant_closure)] + use std::cmp::Ordering; use std::ffi::CString; use std::marker; @@ -517,6 +519,7 @@ impl<'repo, 'references> Iterator for ReferenceNames<'repo, 'references> { } #[cfg(test)] +#[allow(clippy::octal_escapes)] mod tests { use crate::{ObjectType, Reference, ReferenceType}; diff --git a/src/reflog.rs b/src/reflog.rs index 919234ba6f..69d971e7af 100644 --- a/src/reflog.rs +++ b/src/reflog.rs @@ -1,3 +1,5 @@ +#![allow(clippy::redundant_closure)] + use libc::size_t; use std::iter::FusedIterator; use std::marker; diff --git a/src/remote.rs b/src/remote.rs index 290b5517da..377e66a068 100644 --- a/src/remote.rs +++ b/src/remote.rs @@ -1,3 +1,8 @@ +#![allow(clippy::derivable_impls)] +#![allow(clippy::empty_line_after_doc_comments)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::unwrap_or_default)] + use raw::git_strarray; use std::iter::FusedIterator; use std::marker; @@ -825,6 +830,8 @@ impl RemoteRedirect { } #[cfg(test)] +#[allow(clippy::needless_borrow)] +#[allow(clippy::octal_escapes)] mod tests { use crate::{AutotagOption, PushOptions, RemoteUpdateFlags}; use crate::{Direction, FetchOptions, ObjectFormat, Remote, RemoteCallbacks, Repository}; diff --git a/src/remote_callbacks.rs b/src/remote_callbacks.rs index e4b39b0b85..1d988bb7f7 100644 --- a/src/remote_callbacks.rs +++ b/src/remote_callbacks.rs @@ -1,3 +1,5 @@ +#![allow(clippy::doc_overindented_list_items)] + use libc::{c_char, c_int, c_uint, c_void, size_t}; use std::ffi::CStr; use std::mem; diff --git a/src/repo.rs b/src/repo.rs index 072a622455..e7af75b5c8 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -1,3 +1,11 @@ +#![allow(clippy::explicit_auto_deref)] +#![allow(clippy::missing_safety_doc)] +#![allow(clippy::needless_borrow)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::zero_ptr)] + use libc::{c_char, c_int, c_uint, c_void, size_t}; use std::env; use std::ffi::{CStr, CString, OsStr}; @@ -3654,6 +3662,9 @@ impl RepositoryInitOptions { } #[cfg(test)] +#[allow(clippy::assertions_on_constants)] +#[allow(clippy::bool_assert_comparison)] +#[allow(clippy::needless_borrows_for_generic_args)] mod tests { use crate::build::CheckoutBuilder; use crate::AttrCheckFlags; diff --git a/src/revert.rs b/src/revert.rs index 55d702600e..78bfe5d7cc 100644 --- a/src/revert.rs +++ b/src/revert.rs @@ -1,3 +1,5 @@ +#![allow(clippy::new_without_default)] + use std::mem; use crate::build::CheckoutBuilder; diff --git a/src/stash.rs b/src/stash.rs index cd9ee36f58..74f375e568 100644 --- a/src/stash.rs +++ b/src/stash.rs @@ -1,3 +1,5 @@ +#![allow(clippy::missing_safety_doc)] + use crate::build::CheckoutBuilder; use crate::util::{self, Binding}; use crate::{panic, raw, IntoCString, Oid, Signature, StashApplyProgress, StashFlags}; @@ -210,6 +212,7 @@ extern "C" fn stash_apply_progress_cb( } #[cfg(test)] +#[allow(clippy::needless_borrow)] mod tests { use crate::stash::{StashApplyOptions, StashSaveOptions}; use crate::test::repo_init; diff --git a/src/status.rs b/src/status.rs index a8a1bf4f0b..5da7253fb2 100644 --- a/src/status.rs +++ b/src/status.rs @@ -1,3 +1,5 @@ +#![allow(clippy::missing_safety_doc)] + use libc::{c_char, c_uint, size_t}; use std::ffi::CString; use std::iter::FusedIterator; @@ -364,6 +366,7 @@ impl<'statuses> Binding for StatusEntry<'statuses> { } #[cfg(test)] +#[allow(clippy::needless_borrows_for_generic_args)] mod tests { use super::StatusOptions; use std::fs::File; diff --git a/src/string_array.rs b/src/string_array.rs index d320193ac3..7ac04cf70d 100644 --- a/src/string_array.rs +++ b/src/string_array.rs @@ -1,5 +1,7 @@ //! Bindings to libgit2's raw `git_strarray` type +#![allow(clippy::redundant_closure)] + use std::iter::FusedIterator; use std::ops::Range; use std::str; diff --git a/src/submodule.rs b/src/submodule.rs index 20b0b4532e..878a74fa85 100644 --- a/src/submodule.rs +++ b/src/submodule.rs @@ -1,3 +1,7 @@ +#![allow(clippy::empty_line_after_doc_comments)] +#![allow(clippy::let_and_return)] +#![allow(clippy::redundant_closure)] + use std::marker; use std::mem; use std::os::raw::c_int; @@ -329,6 +333,8 @@ impl<'cb> Default for SubmoduleUpdateOptions<'cb> { } #[cfg(test)] +#[allow(clippy::needless_borrows_for_generic_args)] +#[allow(clippy::unnecessary_to_owned)] mod tests { use std::fs; use std::path::Path; diff --git a/src/tag.rs b/src/tag.rs index dfa2a78242..a82ec2441c 100644 --- a/src/tag.rs +++ b/src/tag.rs @@ -1,3 +1,6 @@ +#![allow(clippy::from_over_into)] +#![allow(clippy::redundant_closure)] + use std::ffi::CString; use std::marker; use std::mem; @@ -153,6 +156,8 @@ impl<'repo> Drop for Tag<'repo> { } #[cfg(test)] +#[allow(clippy::bool_assert_comparison)] +#[allow(clippy::octal_escapes)] mod tests { use crate::Tag; diff --git a/src/test.rs b/src/test.rs index a1a303d6cc..7ff69c4978 100644 --- a/src/test.rs +++ b/src/test.rs @@ -1,3 +1,5 @@ +#![allow(clippy::needless_borrows_for_generic_args)] + use std::fs::File; use std::io; use std::path::{Path, PathBuf}; diff --git a/src/transport.rs b/src/transport.rs index 085f5397db..a105f71bd6 100644 --- a/src/transport.rs +++ b/src/transport.rs @@ -1,5 +1,8 @@ //! Interfaces for adding custom transports to libgit2 +#![allow(clippy::missing_safety_doc)] +#![allow(clippy::missing_transmute_annotations)] + use libc::{c_char, c_int, c_uint, c_void, size_t}; use std::ffi::{CStr, CString}; use std::io; @@ -369,6 +372,7 @@ extern "C" fn stream_free(stream: *mut raw::git_smart_subtransport_stream) { } #[cfg(test)] +#[allow(clippy::needless_borrow)] mod tests { use super::*; use crate::{ErrorClass, ErrorCode}; diff --git a/src/tree.rs b/src/tree.rs index f6953ffe20..6b72390032 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -1,3 +1,6 @@ +#![allow(clippy::from_over_into)] +#![allow(clippy::manual_unwrap_or)] + use libc::{c_char, c_int, c_void}; use std::cmp::Ordering; use std::ffi::{CStr, CString}; @@ -401,6 +404,9 @@ impl<'tree> FusedIterator for TreeIter<'tree> {} impl<'tree> ExactSizeIterator for TreeIter<'tree> {} #[cfg(test)] +#[allow(clippy::needless_borrows_for_generic_args)] +#[allow(clippy::redundant_field_names)] +#[allow(clippy::single_match)] mod tests { use super::{TreeWalkMode, TreeWalkResult}; use crate::{Object, ObjectType, Repository, Tree, TreeEntry}; diff --git a/src/util.rs b/src/util.rs index c9cfaa6740..5460d1e727 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,3 +1,8 @@ +#![allow(clippy::missing_safety_doc)] +#![allow(clippy::needless_lifetimes)] +#![allow(clippy::needless_range_loop)] +#![allow(clippy::needless_return)] + use libc::{c_char, c_int, size_t}; use std::cmp::Ordering; use std::ffi::{CString, OsStr, OsString}; diff --git a/src/worktree.rs b/src/worktree.rs index 0a328124e1..b99731c4e1 100644 --- a/src/worktree.rs +++ b/src/worktree.rs @@ -1,3 +1,6 @@ +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] + use crate::buf::Buf; use crate::reference::Reference; use crate::repo::Repository; diff --git a/tests/end_to_end.rs b/tests/end_to_end.rs index 1a8b0f45da..086e538d7c 100644 --- a/tests/end_to_end.rs +++ b/tests/end_to_end.rs @@ -1,4 +1,8 @@ //! Tests for some end-to-end logic about certain operations + +#![allow(clippy::needless_borrow)] +#![allow(unused_variables)] + use git2::{ Error, ReferenceType, Repository, RepositoryInitOptions, StashFlags, Status, StatusOptions, }; diff --git a/tests/global_state.rs b/tests/global_state.rs index 192acdbd3a..04275ed085 100644 --- a/tests/global_state.rs +++ b/tests/global_state.rs @@ -1,6 +1,8 @@ //! Test for some global state set up by libgit2's `git_libgit2_init` function //! that need to be synchronized within a single process. +#![allow(clippy::needless_borrows_for_generic_args)] + use git2::opts; use git2::{ConfigLevel, IntoCString};