Skip to content

Commit 21abb72

Browse files
committed
Update clippy to 1.88; use fallback resolver for clippy as well
1 parent 2a790b2 commit 21abb72

File tree

15 files changed

+65
-59
lines changed

15 files changed

+65
-59
lines changed

.github/workflows/rust.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ jobs:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- uses: actions/checkout@v4
27-
- uses: dtolnay/rust-toolchain@1.75.0
27+
- uses: dtolnay/rust-toolchain@1.88.0
2828
with:
2929
components: clippy
30+
- name: Update Cargo.lock
31+
run: cargo --config 'resolver.incompatible-rust-versions="fallback"' update
3032
- name: Check Clippy lints (reqwest)
31-
run: cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,reqwest-client-rustls -- -D warnings
33+
run: cargo clippy --manifest-path influxdb/Cargo.toml --locked --all-targets --no-default-features --features serde,derive,reqwest-client-rustls -- -D warnings
3234
- name: Check Clippy lints (surf)
33-
run: cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,hyper-client -- -D warnings
35+
run: cargo clippy --manifest-path influxdb/Cargo.toml --locked --all-targets --no-default-features --features serde,derive,hyper-client -- -D warnings
3436

3537
# this checks that the code is formatted with rustfmt
3638
rustfmt:

Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[workspace]
44
members = ["influxdb", "influxdb_derive", "benches"]
5+
resolver = "3"
56

67
[workspace.package]
78
authors = ["Gero Gerke <[email protected]>", "Dominic <[email protected]>"]
@@ -10,6 +11,15 @@ rust-version = "1.65"
1011
license = "MIT"
1112
repository = "https://github.com/influxdb-rs/influxdb-rust"
1213

14+
[workspace.lints.rust]
15+
bare_trait_objects = "forbid"
16+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin)', 'cfg(tarpaulin_include)'] }
17+
18+
[workspace.lints.clippy]
19+
multiple_bound_locations = "allow" # clippy has wrong opinions
20+
needless_doctest_main = "allow"
21+
needless_lifetimes = "allow" # False positive in client/mod.rs query fn
22+
1323
[patch.crates-io]
1424
influxdb = { path = "./influxdb" }
1525
influxdb_derive = { path = "./influxdb_derive" }

influxdb/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ readme = "README.md"
1313
include = ["src/**/*", "tests/**/*", "Cargo.toml", "LICENSE"]
1414
repository.workspace = true
1515

16+
[lints]
17+
workspace = true
18+
1619
[dependencies]
1720
chrono = { version = "0.4.23", features = ["serde"], default-features = false }
1821
futures-util = "0.3.17"

influxdb/src/client/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl Client {
162162
.send()
163163
.await
164164
.map_err(|err| Error::ProtocolError {
165-
error: format!("{}", err),
165+
error: err.to_string(),
166166
})?;
167167

168168
const BUILD_HEADER: &str = "X-Influxdb-Build";
@@ -276,13 +276,13 @@ impl Client {
276276
let body = res.body_string();
277277

278278
let s = body.await.map_err(|_| Error::DeserializationError {
279-
error: "response could not be converted to UTF-8".to_string(),
279+
error: "response could not be converted to UTF-8".into(),
280280
})?;
281281

282282
// todo: improve error parsing without serde
283283
if s.contains("\"error\"") || s.contains("\"Error\"") {
284284
return Err(Error::DatabaseError {
285-
error: format!("influxdb error: \"{}\"", s),
285+
error: format!("influxdb error: {s:?}"),
286286
});
287287
}
288288

@@ -291,7 +291,7 @@ impl Client {
291291

292292
fn auth_if_needed(&self, rb: RequestBuilder) -> RequestBuilder {
293293
if let Some(ref token) = self.token {
294-
rb.header("Authorization", format!("Token {}", token))
294+
rb.header("Authorization", format!("Token {token}"))
295295
} else {
296296
rb
297297
}
@@ -314,7 +314,7 @@ mod tests {
314314
#[test]
315315
fn test_client_debug_redacted_password() {
316316
let client = Client::new("https://localhost:8086", "db").with_auth("user", "pass");
317-
let actual = format!("{:#?}", client);
317+
let actual = format!("{client:#?}");
318318
let expected = indoc! { r#"
319319
Client {
320320
url: "https://localhost:8086",

influxdb/src/integrations/serde_integration/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl DatabaseQueryResult {
7171
{
7272
serde_json::from_value::<Return<T>>(self.results.remove(0)).map_err(|err| {
7373
Error::DeserializationError {
74-
error: format!("could not deserialize: {}", err),
74+
error: format!("could not deserialize: {err}"),
7575
}
7676
})
7777
}
@@ -85,7 +85,7 @@ impl DatabaseQueryResult {
8585
{
8686
serde_json::from_value::<TaggedReturn<TAG, T>>(self.results.remove(0)).map_err(|err| {
8787
Error::DeserializationError {
88-
error: format!("could not deserialize: {}", err),
88+
error: format!("could not deserialize: {err}"),
8989
}
9090
})
9191
}
@@ -123,17 +123,15 @@ pub struct TaggedSeries<TAG, T> {
123123
impl Client {
124124
pub async fn json_query(&self, q: ReadQuery) -> Result<DatabaseQueryResult, Error> {
125125
let query = q.build().map_err(|err| Error::InvalidQueryError {
126-
error: format!("{}", err),
126+
error: err.to_string(),
127127
})?;
128128

129129
let read_query = query.get();
130130
let read_query_lower = read_query.to_lowercase();
131131

132132
if !read_query_lower.contains("select") && !read_query_lower.contains("show") {
133133
let error = Error::InvalidQueryError {
134-
error: String::from(
135-
"Only SELECT and SHOW queries supported with JSON deserialization",
136-
),
134+
error: "Only SELECT and SHOW queries supported with JSON deserialization".into(),
137135
};
138136
return Err(error);
139137
}
@@ -143,7 +141,7 @@ impl Client {
143141
parameters.insert("q", read_query);
144142
let mut request_builder = self.client.get(url);
145143
if let Some(ref token) = self.token {
146-
request_builder = request_builder.header("Authorization", format!("Token {}", token))
144+
request_builder = request_builder.header("Authorization", format!("Token {token}"))
147145
}
148146
let request_builder = request_builder.query(&parameters);
149147

@@ -179,7 +177,7 @@ impl Client {
179177
// Json has another structure, let's try actually parsing it to the type we're deserializing
180178
serde_json::from_slice::<DatabaseQueryResult>(&body).map_err(|err| {
181179
Error::DeserializationError {
182-
error: format!("serde error: {}", err),
180+
error: format!("serde error: {err}"),
183181
}
184182
})
185183
}

influxdb/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@
9494
//!
9595
//! [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9696
97-
#![allow(clippy::needless_doctest_main)]
98-
#![allow(clippy::needless_lifetimes)] // False positive in client/mod.rs query fn
99-
#![forbid(bare_trait_objects)]
100-
10197
macro_rules! cargo_toml {
10298
(indent=$indent:literal, $firstfeat:literal $(, $feature:literal)*) => {
10399
cargo_toml_private!($indent, "", $firstfeat $(, $feature)*)
@@ -107,6 +103,7 @@ macro_rules! cargo_toml {
107103
cargo_toml_private!($indent, "default-features = false, ", $firstfeat $(, $feature)*)
108104
};
109105
}
106+
use cargo_toml;
110107

111108
macro_rules! cargo_toml_private {
112109
($indent:literal, $deffeats:literal, $firstfeat:literal $(, $feature:literal)*) => {
@@ -129,6 +126,7 @@ macro_rules! cargo_toml_private {
129126
)
130127
};
131128
}
129+
use cargo_toml_private;
132130

133131
#[cfg(all(feature = "reqwest", feature = "surf"))]
134132
compile_error!("You need to choose between reqwest and surf; enabling both is not supported");

influxdb/src/query/line_proto_term.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ impl LineProtoTerm<'_> {
4949
}
5050
.to_string(),
5151
Float(v) => v.to_string(),
52-
SignedInteger(v) => format!("{}i", v),
52+
SignedInteger(v) => format!("{v}i"),
5353
UnsignedInteger(v) => {
5454
if use_v2 {
55-
format!("{}u", v)
55+
format!("{v}u")
5656
} else {
57-
format!("{}i", v)
57+
format!("{v}i")
5858
}
5959
}
6060
Text(v) => format!(r#""{}""#, Self::escape_any(v, &QUOTES_SLASHES)),
@@ -71,10 +71,10 @@ impl LineProtoTerm<'_> {
7171
"false"
7272
}
7373
}
74-
.to_string(),
75-
Float(v) => format!(r#"{}"#, v),
76-
SignedInteger(v) => format!(r#"{}"#, v),
77-
UnsignedInteger(v) => format!(r#"{}"#, v),
74+
.into(),
75+
Float(v) => v.to_string(),
76+
SignedInteger(v) => v.to_string(),
77+
UnsignedInteger(v) => v.to_string(),
7878
Text(v) => Self::escape_any(v, &SLASHES),
7979
}
8080
}

influxdb/src/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl fmt::Display for Timestamp {
5252
use Timestamp::*;
5353
match self {
5454
Nanoseconds(ts) | Microseconds(ts) | Milliseconds(ts) | Seconds(ts) | Minutes(ts)
55-
| Hours(ts) => write!(f, "{}", ts),
55+
| Hours(ts) => write!(f, "{ts}"),
5656
}
5757
}
5858
}

influxdb/src/query/write_query.rs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,11 @@ impl Display for Type {
122122
use Type::*;
123123

124124
match self {
125-
Boolean(x) => write!(f, "{}", x),
126-
Float(x) => write!(f, "{}", x),
127-
SignedInteger(x) => write!(f, "{}", x),
128-
UnsignedInteger(x) => write!(f, "{}", x),
129-
Text(text) => write!(f, "{text}", text = text),
125+
Boolean(x) => write!(f, "{x}"),
126+
Float(x) => write!(f, "{x}"),
127+
SignedInteger(x) => write!(f, "{x}"),
128+
UnsignedInteger(x) => write!(f, "{x}"),
129+
Text(text) => write!(f, "{text}"),
130130
}
131131
}
132132
}
@@ -187,11 +187,7 @@ impl Query for WriteQuery {
187187
} else {
188188
LineProtoTerm::TagValue(value).escape()
189189
};
190-
format!(
191-
"{tag}={value}",
192-
tag = escaped_tag_key,
193-
value = escaped_tag_value,
194-
)
190+
format!("{escaped_tag_key}={escaped_tag_value}")
195191
})
196192
.collect::<Vec<String>>()
197193
.join(",");
@@ -213,11 +209,7 @@ impl Query for WriteQuery {
213209
} else {
214210
LineProtoTerm::FieldValue(value).escape()
215211
};
216-
format!(
217-
"{field}={value}",
218-
field = escaped_field_key,
219-
value = escaped_field_value,
220-
)
212+
format!("{escaped_field_key}={escaped_field_value}")
221213
})
222214
.collect::<Vec<String>>()
223215
.join(",");

influxdb/tests/derive_integration_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ async fn test_write_and_read_option() {
104104

105105
let query = ReadQuery::new("SELECT time, pressure, wind_strength FROM weather_reading");
106106
let result = client.json_query(query).await.and_then(|mut db_result| {
107-
println!("{:?}", db_result);
107+
println!("{db_result:?}");
108108
db_result.deserialize_next::<WeatherReadingWithoutIgnored>()
109109
});
110110
assert_result_ok(&result);

0 commit comments

Comments
 (0)