From 28dd69ff1a170c6fa002c117fa8e3baea0a7cee8 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 6 Oct 2023 15:03:41 +0200 Subject: [PATCH 1/5] Fix: Run clippy with exact toolchains Signed-off-by: Matthias Beyer --- .github/workflows/msrv.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/msrv.yml b/.github/workflows/msrv.yml index c1d0766c..121c1243 100644 --- a/.github/workflows/msrv.yml +++ b/.github/workflows/msrv.yml @@ -96,7 +96,7 @@ jobs: matrix: rust: - 1.66.0 - - stable + - 1.73.0 steps: - name: Checkout sources uses: actions/checkout@v4.1.0 @@ -118,7 +118,7 @@ jobs: matrix: rust: - 1.66.0 - - stable + - 1.73.0 steps: - name: Checkout sources From 39457c8a00aa315ddcec62930037c364d98fdfc7 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 6 Oct 2023 15:04:30 +0200 Subject: [PATCH 2/5] Fix clippy: Remove redundant closures Signed-off-by: Matthias Beyer --- src/builder.rs | 2 +- src/file/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/builder.rs b/src/builder.rs index db6ee2fa..547e1180 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -225,7 +225,7 @@ impl ConfigBuilder { .state .sources .into_iter() - .map(|s| SourceType::Sync(s)) + .map(SourceType::Sync) .collect(), }, defaults: self.defaults, diff --git a/src/file/mod.rs b/src/file/mod.rs index b2915a70..0443a04b 100644 --- a/src/file/mod.rs +++ b/src/file/mod.rs @@ -128,7 +128,7 @@ where let (uri, contents, format) = match self .source .resolve(self.format.clone()) - .map_err(|err| ConfigError::Foreign(err)) + .map_err(ConfigError::Foreign) { Ok(result) => (result.uri, result.content, result.format), From 4a530b8d4f270ff97acf1187e1e860fe5af09397 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 6 Oct 2023 15:09:18 +0200 Subject: [PATCH 3/5] Fix clippy: Rewrite string building Clippy complained about how we build the strings here, so rewrite it. Signed-off-by: Matthias Beyer --- src/value.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/value.rs b/src/value.rs index cd7440d2..fe00e7e9 100644 --- a/src/value.rs +++ b/src/value.rs @@ -152,6 +152,8 @@ where impl Display for ValueKind { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use std::fmt::Write; + match *self { Self::String(ref value) => write!(f, "{}", value), Self::Boolean(value) => write!(f, "{}", value), @@ -161,15 +163,20 @@ impl Display for ValueKind { Self::U128(value) => write!(f, "{}", value), Self::Float(value) => write!(f, "{}", value), Self::Nil => write!(f, "nil"), - Self::Table(ref table) => write!(f, "{{ {} }}", { - table - .iter() - .map(|(k, v)| format!("{} => {}, ", k, v)) - .collect::() - }), - Self::Array(ref array) => write!(f, "{:?}", { - array.iter().map(|e| format!("{}, ", e)).collect::() - }), + Self::Table(ref table) => { + let mut s = String::new(); + for (k, v) in table.iter() { + write!(s, "{} => {}, ", k, v)? + } + write!(f, "{{ {s} }}") + } + Self::Array(ref array) => { + let mut s = String::new(); + for e in array.iter() { + write!(s, "{}, ", e)?; + } + write!(f, "{s:?}") + } } } } From 1c9f282b47fd3b2545fa9fb612048d01e21e8ebf Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 6 Oct 2023 15:04:30 +0200 Subject: [PATCH 4/5] Fix clippy: Remove redundant closures Signed-off-by: Matthias Beyer --- tests/async_builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/async_builder.rs b/tests/async_builder.rs index bead9d38..b91a1a3b 100644 --- a/tests/async_builder.rs +++ b/tests/async_builder.rs @@ -31,7 +31,7 @@ impl AsyncSource for AsyncFile { self.format .parse(Some(&self.path), &text) - .map_err(|e| ConfigError::Foreign(e)) + .map_err(ConfigError::Foreign) } } From d8697a892772d41ebad6e61bd0c5ac2cd0846a4e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 6 Oct 2023 15:04:30 +0200 Subject: [PATCH 5/5] Fix clippy: Remove redundant closures Signed-off-by: Matthias Beyer --- examples/async_source/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/async_source/main.rs b/examples/async_source/main.rs index f5459b91..07685ac9 100644 --- a/examples/async_source/main.rs +++ b/examples/async_source/main.rs @@ -68,7 +68,7 @@ impl AsyncSource for HttpSource { .and_then(|text| { self.format .parse(Some(&self.uri), &text) - .map_err(|e| ConfigError::Foreign(e)) + .map_err(ConfigError::Foreign) }) } }