From b33af8d31815bedbd95c5c43f13e989102b2dd5e Mon Sep 17 00:00:00 2001 From: laurent Date: Mon, 9 Dec 2024 23:17:38 +0100 Subject: [PATCH 1/2] Clippy fixes. --- src/nn/func.rs | 8 ++++---- src/nn/var_store.rs | 2 +- src/tensor/safetensors.rs | 2 +- torch-sys/build.rs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/nn/func.rs b/src/nn/func.rs index 56047b49..123be59c 100644 --- a/src/nn/func.rs +++ b/src/nn/func.rs @@ -6,7 +6,7 @@ pub struct Func<'a> { f: Box Tensor + Send>, } -impl<'a> std::fmt::Debug for Func<'a> { +impl std::fmt::Debug for Func<'_> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "func") } @@ -19,7 +19,7 @@ where Func { f: Box::new(f) } } -impl<'a> super::module::Module for Func<'a> { +impl super::module::Module for Func<'_> { fn forward(&self, xs: &Tensor) -> Tensor { (*self.f)(xs) } @@ -31,7 +31,7 @@ pub struct FuncT<'a> { f: Box Tensor + Send>, } -impl<'a> std::fmt::Debug for FuncT<'a> { +impl std::fmt::Debug for FuncT<'_> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "funcT") } @@ -44,7 +44,7 @@ where FuncT { f: Box::new(f) } } -impl<'a> super::module::ModuleT for FuncT<'a> { +impl super::module::ModuleT for FuncT<'_> { fn forward_t(&self, xs: &Tensor, train: bool) -> Tensor { (*self.f)(xs, train) } diff --git a/src/nn/var_store.rs b/src/nn/var_store.rs index e78c83a0..145f0b41 100644 --- a/src/nn/var_store.rs +++ b/src/nn/var_store.rs @@ -828,7 +828,7 @@ impl<'a> Path<'a> { } } -impl<'a> Entry<'a> { +impl Entry<'_> { /// Returns the existing entry if, otherwise create a new variable. /// /// If this entry name matches the name of a variables stored in the diff --git a/src/tensor/safetensors.rs b/src/tensor/safetensors.rs index b445463b..8ce0389f 100644 --- a/src/tensor/safetensors.rs +++ b/src/tensor/safetensors.rs @@ -83,7 +83,7 @@ impl<'a> TryFrom<&'a Tensor> for SafeView<'a> { } } -impl<'a> View for SafeView<'a> { +impl View for SafeView<'_> { fn dtype(&self) -> Dtype { self.dtype } diff --git a/torch-sys/build.rs b/torch-sys/build.rs index c0148505..b8f44b53 100644 --- a/torch-sys/build.rs +++ b/torch-sys/build.rs @@ -377,9 +377,9 @@ impl SystemInfo { .pic(true) .warnings(false) .includes(&self.libtorch_include_dirs) - .flag(format!("-Wl,-rpath={}", self.libtorch_lib_dir.display())) + .flag(&format!("-Wl,-rpath={}", self.libtorch_lib_dir.display())) .flag("-std=c++17") - .flag(format!("-D_GLIBCXX_USE_CXX11_ABI={}", self.cxx11_abi)) + .flag(&format!("-D_GLIBCXX_USE_CXX11_ABI={}", self.cxx11_abi)) .flag("-DGLOG_USE_GLOG_EXPORT") .files(&c_files) .compile("tch"); From eb8d34f1c9413080327dc1485bb4afa7e5d6a102 Mon Sep 17 00:00:00 2001 From: laurent Date: Mon, 9 Dec 2024 23:21:43 +0100 Subject: [PATCH 2/2] Bump the cc version to avoid some clippy issues. --- torch-sys/Cargo.toml | 2 +- torch-sys/build.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/torch-sys/Cargo.toml b/torch-sys/Cargo.toml index 289bf176..44fcaed0 100644 --- a/torch-sys/Cargo.toml +++ b/torch-sys/Cargo.toml @@ -17,7 +17,7 @@ libc = "0.2.0" [build-dependencies] anyhow = "^1.0.60" -cc = "1.0.61" +cc = "1.2" ureq = { version = "2.6", optional = true, features = ["json"] } serde_json = { version = "1.0", optional = true } serde = { version = "1.0", optional = true, features = ["derive"] } diff --git a/torch-sys/build.rs b/torch-sys/build.rs index b8f44b53..c0148505 100644 --- a/torch-sys/build.rs +++ b/torch-sys/build.rs @@ -377,9 +377,9 @@ impl SystemInfo { .pic(true) .warnings(false) .includes(&self.libtorch_include_dirs) - .flag(&format!("-Wl,-rpath={}", self.libtorch_lib_dir.display())) + .flag(format!("-Wl,-rpath={}", self.libtorch_lib_dir.display())) .flag("-std=c++17") - .flag(&format!("-D_GLIBCXX_USE_CXX11_ABI={}", self.cxx11_abi)) + .flag(format!("-D_GLIBCXX_USE_CXX11_ABI={}", self.cxx11_abi)) .flag("-DGLOG_USE_GLOG_EXPORT") .files(&c_files) .compile("tch");