Skip to content

Commit dfeec4b

Browse files
authored
Merge pull request diesel-rs#3927 from weiznich/lint_fixes
Fix a few new lint warnings about dead code
2 parents 1c24bf6 + 46df556 commit dfeec4b

File tree

6 files changed

+25
-28
lines changed

6 files changed

+25
-28
lines changed

diesel/src/pg/types/floats/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub enum PgNumeric {
3737
}
3838

3939
#[derive(Debug, Clone, Copy)]
40+
#[allow(dead_code)] // that's used by debug in the error impl
4041
struct InvalidNumericSign(u16);
4142

4243
impl ::std::fmt::Display for InvalidNumericSign {

diesel/src/sqlite/connection/raw.rs

+13-19
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl Drop for RawConnection {
261261
enum SqliteCallbackError {
262262
Abort(&'static str),
263263
DieselError(crate::result::Error),
264-
Panic(Box<dyn std::any::Any + Send>, String),
264+
Panic(String),
265265
}
266266

267267
impl SqliteCallbackError {
@@ -273,7 +273,7 @@ impl SqliteCallbackError {
273273
s = e.to_string();
274274
&s
275275
}
276-
SqliteCallbackError::Panic(_, msg) => msg,
276+
SqliteCallbackError::Panic(msg) => msg,
277277
};
278278
unsafe {
279279
context_error_str(ctx, msg);
@@ -347,12 +347,7 @@ extern "C" fn run_custom_function<F, Ret, RetSqlType>(
347347
}
348348
Ok(())
349349
})
350-
.unwrap_or_else(|p| {
351-
Err(SqliteCallbackError::Panic(
352-
p,
353-
data_ptr.function_name.clone(),
354-
))
355-
});
350+
.unwrap_or_else(|p| Err(SqliteCallbackError::Panic(data_ptr.function_name.clone())));
356351
if let Err(e) = result {
357352
e.emit(ctx);
358353
}
@@ -383,10 +378,10 @@ extern "C" fn run_aggregator_step_function<ArgsSqlType, RetSqlType, Args, Ret, A
383378
run_aggregator_step::<A, Args, ArgsSqlType>(ctx, args)
384379
})
385380
.unwrap_or_else(|e| {
386-
Err(SqliteCallbackError::Panic(
387-
e,
388-
format!("{}::step() panicked", std::any::type_name::<A>()),
389-
))
381+
Err(SqliteCallbackError::Panic(format!(
382+
"{}::step() panicked",
383+
std::any::type_name::<A>()
384+
)))
390385
});
391386

392387
match result {
@@ -496,11 +491,11 @@ extern "C" fn run_aggregator_final_function<ArgsSqlType, RetSqlType, Args, Ret,
496491
}
497492
Ok(())
498493
})
499-
.unwrap_or_else(|e| {
500-
Err(SqliteCallbackError::Panic(
501-
e,
502-
format!("{}::finalize() panicked", std::any::type_name::<A>()),
503-
))
494+
.unwrap_or_else(|_e| {
495+
Err(SqliteCallbackError::Panic(format!(
496+
"{}::finalize() panicked",
497+
std::any::type_name::<A>()
498+
)))
504499
});
505500
if let Err(e) = result {
506501
e.emit(ctx);
@@ -570,7 +565,6 @@ where
570565
})
571566
.unwrap_or_else(|p| {
572567
Err(SqliteCallbackError::Panic(
573-
p,
574568
user_ptr
575569
.map(|u| u.collation_name.clone())
576570
.unwrap_or_default(),
@@ -601,7 +595,7 @@ where
601595
);
602596
std::process::abort()
603597
}
604-
Err(SqliteCallbackError::Panic(_, msg)) => {
598+
Err(SqliteCallbackError::Panic(msg)) => {
605599
eprintln!("Collation function {} panicked", msg);
606600
std::process::abort()
607601
}

diesel_derives/src/parsers/belongs_to.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use syn::{Ident, TypePath};
66
use crate::util::{parse_eq, unknown_attribute, BELONGS_TO_NOTE};
77

88
enum Attr {
9-
ForeignKey(Ident, Ident),
9+
ForeignKey(Ident),
1010
}
1111

1212
impl Parse for Attr {
@@ -15,7 +15,7 @@ impl Parse for Attr {
1515
let name_str = name.to_string();
1616

1717
match &*name_str {
18-
"foreign_key" => Ok(Attr::ForeignKey(name, parse_eq(input, BELONGS_TO_NOTE)?)),
18+
"foreign_key" => Ok(Attr::ForeignKey(parse_eq(input, BELONGS_TO_NOTE)?)),
1919

2020
_ => Err(unknown_attribute(&name, &["foreign_key"])),
2121
}
@@ -39,7 +39,7 @@ impl Parse for BelongsTo {
3939

4040
for attr in Punctuated::<Attr, Comma>::parse_terminated(input)? {
4141
match attr {
42-
Attr::ForeignKey(_, value) => foreign_key = Some(value),
42+
Attr::ForeignKey(value) => foreign_key = Some(value),
4343
}
4444
}
4545

diesel_derives/src/parsers/mysql_type.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use syn::{Ident, LitStr};
66
use crate::util::{parse_eq, unknown_attribute, MYSQL_TYPE_NOTE};
77

88
enum Attr {
9-
Name(Ident, LitStr),
9+
Name(LitStr),
1010
}
1111

1212
impl Parse for Attr {
@@ -15,7 +15,7 @@ impl Parse for Attr {
1515
let name_str = name.to_string();
1616

1717
match &*name_str {
18-
"name" => Ok(Attr::Name(name, parse_eq(input, MYSQL_TYPE_NOTE)?)),
18+
"name" => Ok(Attr::Name(parse_eq(input, MYSQL_TYPE_NOTE)?)),
1919

2020
_ => Err(unknown_attribute(&name, &["name"])),
2121
}
@@ -32,7 +32,7 @@ impl Parse for MysqlType {
3232

3333
for attr in Punctuated::<Attr, Comma>::parse_terminated(input)? {
3434
match attr {
35-
Attr::Name(_, value) => name = Some(value),
35+
Attr::Name(value) => name = Some(value),
3636
}
3737
}
3838

diesel_derives/src/parsers/sqlite_type.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use syn::{Ident, LitStr};
66
use crate::util::{parse_eq, unknown_attribute, SQLITE_TYPE_NOTE};
77

88
enum Attr {
9-
Name(Ident, LitStr),
9+
Name(LitStr),
1010
}
1111

1212
impl Parse for Attr {
@@ -15,7 +15,7 @@ impl Parse for Attr {
1515
let name_str = name.to_string();
1616

1717
match &*name_str {
18-
"name" => Ok(Attr::Name(name, parse_eq(input, SQLITE_TYPE_NOTE)?)),
18+
"name" => Ok(Attr::Name(parse_eq(input, SQLITE_TYPE_NOTE)?)),
1919

2020
_ => Err(unknown_attribute(&name, &["name"])),
2121
}
@@ -32,7 +32,7 @@ impl Parse for SqliteType {
3232

3333
for attr in Punctuated::<Attr, Comma>::parse_terminated(input)? {
3434
match attr {
35-
Attr::Name(_, value) => name = Some(value),
35+
Attr::Name(value) => name = Some(value),
3636
}
3737
}
3838

diesel_tests/tests/insert_from_select.rs

+2
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ fn on_conflict_do_update_with_boxed_select() {
395395

396396
users
397397
.select((id, name.concat(" says hi")))
398+
.order(id)
398399
.into_boxed()
399400
.insert_into(posts)
400401
.into_columns((user_id, title))
@@ -411,6 +412,7 @@ fn on_conflict_do_update_with_boxed_select() {
411412

412413
users
413414
.select((id, name.concat(" says hi")))
415+
.order(id)
414416
.into_boxed()
415417
.insert_into(posts)
416418
.into_columns((user_id, title))

0 commit comments

Comments
 (0)