# HG changeset patch # User Georges Racinet <georges.racinet@octobus.net> # Date 1680451524 -7200 # Sun Apr 02 18:05:24 2023 +0200 # Node ID 555e544f724443f5e405c2de74b4edc4f1250204 # Parent 8a82701d0b1735a1c9af92adc31ed23aa8477eba RHGitaly: fixed Clippy warnings Some warnings have been fixed lower in the stack. However, the Camel Case rule for acronyms hurts my eyes in the case of TCP (and leads to plain wrong output when it ends up in startup logs through `fmt::Debug`). We had to change the way the generated code is included. This also has the nice effect of ignoring `gitaly.rs` in `rustfmt`, thus making `cargo fmt --check` work for us. The missing `Eq` impl when deriving `PartialEq` is new in Rust 1.63 diff --git a/rust/rhgitaly/clippy.toml b/rust/rhgitaly/clippy.toml new file mode 100644 --- /dev/null +++ b/rust/rhgitaly/clippy.toml @@ -0,0 +1,3 @@ +# MSRV is as Mercurial's, defined as the version in Debian testing +# (currrently bookworm) +msrv = "1.61" diff --git a/rust/rhgitaly/src/lib.rs b/rust/rhgitaly/src/lib.rs --- a/rust/rhgitaly/src/lib.rs +++ b/rust/rhgitaly/src/lib.rs @@ -9,8 +9,11 @@ // The generated module is derived from the Protobuf "package" name // Hence as soon as we start compiling the HGitaly-specific proto files, // we'll also get a `hgitaly` module. -#[path = "generated/gitaly.rs"] -pub mod gitaly; +// using `include!` lets us add attributes, in this case to control clippy +pub mod gitaly { + #![allow(unknown_lints)] + include! {"generated/gitaly.rs"} +} pub mod config; pub mod repository; diff --git a/rust/rhgitaly/src/main.rs b/rust/rhgitaly/src/main.rs --- a/rust/rhgitaly/src/main.rs +++ b/rust/rhgitaly/src/main.rs @@ -28,6 +28,7 @@ } #[derive(Debug)] +#[allow(clippy::upper_case_acronyms)] enum BindAddress { Unix(PathBuf), TCP(SocketAddr), diff --git a/rust/rhgitaly/src/repository.rs b/rust/rhgitaly/src/repository.rs --- a/rust/rhgitaly/src/repository.rs +++ b/rust/rhgitaly/src/repository.rs @@ -9,7 +9,7 @@ use super::config::Config; use super::gitaly::Repository; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum PathError { UnknownStorage(String), }