Skip to content

Commit 3e67dbb

Browse files
committed
Fix clippy
1 parent a12efc4 commit 3e67dbb

File tree

4 files changed

+30
-38
lines changed

4 files changed

+30
-38
lines changed

codegen/src/type_gen.rs

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -319,46 +319,42 @@ fn make_impl(w: &mut BufWriter<File>, types: &BTreeMap<u32, Type>) {
319319
.unwrap();
320320

321321
for (oid, type_) in types {
322-
write!(
322+
writeln!(
323323
w,
324-
" {} => Some(Inner::{}),
325-
",
324+
" {} => Some(Inner::{}),",
326325
oid, type_.variant
327326
)
328327
.unwrap();
329328
}
330329

331-
write!(
330+
writeln!(
332331
w,
333332
" _ => None,
334333
}}
335334
}}
336335
337336
pub fn oid(&self) -> Oid {{
338-
match *self {{
339-
",
337+
match *self {{",
340338
)
341339
.unwrap();
342340

343341
for (oid, type_) in types {
344-
write!(
342+
writeln!(
345343
w,
346-
" Inner::{} => {},
347-
",
344+
" Inner::{} => {},",
348345
type_.variant, oid
349346
)
350347
.unwrap();
351348
}
352349

353-
write!(
350+
writeln!(
354351
w,
355352
" Inner::Other(ref u) => u.oid,
356353
}}
357354
}}
358355
359356
pub fn kind(&self) -> &Kind {{
360-
match *self {{
361-
",
357+
match *self {{",
362358
)
363359
.unwrap();
364360

@@ -370,59 +366,54 @@ fn make_impl(w: &mut BufWriter<File>, types: &BTreeMap<u32, Type>) {
370366
_ => "Simple".to_owned(),
371367
};
372368

373-
write!(
369+
writeln!(
374370
w,
375371
" Inner::{} => {{
376372
&Kind::{}
377-
}}
378-
",
373+
}}",
379374
type_.variant, kind
380375
)
381376
.unwrap();
382377
}
383378

384-
write!(
379+
writeln!(
385380
w,
386381
r#" Inner::Other(ref u) => &u.kind,
387382
}}
388383
}}
389384
390385
pub fn name(&self) -> &str {{
391-
match *self {{
392-
"#,
386+
match *self {{"#,
393387
)
394388
.unwrap();
395389

396390
for type_ in types.values() {
397-
write!(
391+
writeln!(
398392
w,
399-
r#" Inner::{} => "{}",
400-
"#,
393+
r#" Inner::{} => "{}","#,
401394
type_.variant, type_.name
402395
)
403396
.unwrap();
404397
}
405398

406-
write!(
399+
writeln!(
407400
w,
408401
" Inner::Other(ref u) => &u.name,
409402
}}
410403
}}
411-
}}
412-
"
404+
}}"
413405
)
414406
.unwrap();
415407
}
416408

417409
fn make_consts(w: &mut BufWriter<File>, types: &BTreeMap<u32, Type>) {
418410
write!(w, "impl Type {{").unwrap();
419411
for type_ in types.values() {
420-
write!(
412+
writeln!(
421413
w,
422414
"
423415
/// {docs}
424-
pub const {ident}: Type = Type(Inner::{variant});
425-
",
416+
pub const {ident}: Type = Type(Inner::{variant});",
426417
docs = type_.doc,
427418
ident = type_.ident,
428419
variant = type_.variant

postgres/src/copy_out_reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl BufRead for CopyOutReader<'_> {
3838
let mut stream = self.stream.pinned();
3939
match self
4040
.connection
41-
.block_on({ async { stream.next().await.transpose() } })
41+
.block_on(async { stream.next().await.transpose() })
4242
{
4343
Ok(Some(cur)) => self.cur = cur,
4444
Err(e) => return Err(io::Error::new(io::ErrorKind::Other, e)),

tokio-postgres/src/error/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ impl DbError {
224224
///
225225
/// Might run to multiple lines.
226226
pub fn detail(&self) -> Option<&str> {
227-
self.detail.as_ref().map(|s| &**s)
227+
self.detail.as_deref()
228228
}
229229

230230
/// An optional suggestion what to do about the problem.
@@ -233,7 +233,7 @@ impl DbError {
233233
/// (potentially inappropriate) rather than hard facts. Might run to
234234
/// multiple lines.
235235
pub fn hint(&self) -> Option<&str> {
236-
self.hint.as_ref().map(|s| &**s)
236+
self.hint.as_deref()
237237
}
238238

239239
/// An optional error cursor position into either the original query string
@@ -248,20 +248,20 @@ impl DbError {
248248
/// language functions and internally-generated queries. The trace is one
249249
/// entry per line, most recent first.
250250
pub fn where_(&self) -> Option<&str> {
251-
self.where_.as_ref().map(|s| &**s)
251+
self.where_.as_deref()
252252
}
253253

254254
/// If the error was associated with a specific database object, the name
255255
/// of the schema containing that object, if any. (PostgreSQL 9.3+)
256256
pub fn schema(&self) -> Option<&str> {
257-
self.schema.as_ref().map(|s| &**s)
257+
self.schema.as_deref()
258258
}
259259

260260
/// If the error was associated with a specific table, the name of the
261261
/// table. (Refer to the schema name field for the name of the table's
262262
/// schema.) (PostgreSQL 9.3+)
263263
pub fn table(&self) -> Option<&str> {
264-
self.table.as_ref().map(|s| &**s)
264+
self.table.as_deref()
265265
}
266266

267267
/// If the error was associated with a specific table column, the name of
@@ -270,14 +270,14 @@ impl DbError {
270270
/// (Refer to the schema and table name fields to identify the table.)
271271
/// (PostgreSQL 9.3+)
272272
pub fn column(&self) -> Option<&str> {
273-
self.column.as_ref().map(|s| &**s)
273+
self.column.as_deref()
274274
}
275275

276276
/// If the error was associated with a specific data type, the name of the
277277
/// data type. (Refer to the schema name field for the name of the data
278278
/// type's schema.) (PostgreSQL 9.3+)
279279
pub fn datatype(&self) -> Option<&str> {
280-
self.datatype.as_ref().map(|s| &**s)
280+
self.datatype.as_deref()
281281
}
282282

283283
/// If the error was associated with a specific constraint, the name of the
@@ -287,12 +287,12 @@ impl DbError {
287287
/// (For this purpose, indexes are treated as constraints, even if they
288288
/// weren't created with constraint syntax.) (PostgreSQL 9.3+)
289289
pub fn constraint(&self) -> Option<&str> {
290-
self.constraint.as_ref().map(|s| &**s)
290+
self.constraint.as_deref()
291291
}
292292

293293
/// The file name of the source-code location where the error was reported.
294294
pub fn file(&self) -> Option<&str> {
295-
self.file.as_ref().map(|s| &**s)
295+
self.file.as_deref()
296296
}
297297

298298
/// The line number of the source-code location where the error was
@@ -303,7 +303,7 @@ impl DbError {
303303

304304
/// The name of the source-code routine reporting the error.
305305
pub fn routine(&self) -> Option<&str> {
306-
self.routine.as_ref().map(|s| &**s)
306+
self.routine.as_deref()
307307
}
308308
}
309309

tokio-postgres/src/generic_client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ impl GenericClient for Client {
146146
impl private::Sealed for Transaction<'_> {}
147147

148148
#[async_trait]
149+
#[allow(clippy::needless_lifetimes)]
149150
impl GenericClient for Transaction<'_> {
150151
async fn execute<T>(&self, query: &T, params: &[&(dyn ToSql + Sync)]) -> Result<u64, Error>
151152
where

0 commit comments

Comments
 (0)