Skip to content

Commit

Permalink
Merge pull request diesel-rs#3927 from weiznich/lint_fixes
Browse files Browse the repository at this point in the history
Fix a few new lint warnings about dead code
  • Loading branch information
weiznich authored Feb 8, 2024
2 parents 1c24bf6 + 46df556 commit dfeec4b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 28 deletions.
1 change: 1 addition & 0 deletions diesel/src/pg/types/floats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub enum PgNumeric {
}

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

impl ::std::fmt::Display for InvalidNumericSign {
Expand Down
32 changes: 13 additions & 19 deletions diesel/src/sqlite/connection/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl Drop for RawConnection {
enum SqliteCallbackError {
Abort(&'static str),
DieselError(crate::result::Error),
Panic(Box<dyn std::any::Any + Send>, String),
Panic(String),
}

impl SqliteCallbackError {
Expand All @@ -273,7 +273,7 @@ impl SqliteCallbackError {
s = e.to_string();
&s
}
SqliteCallbackError::Panic(_, msg) => msg,
SqliteCallbackError::Panic(msg) => msg,
};
unsafe {
context_error_str(ctx, msg);
Expand Down Expand Up @@ -347,12 +347,7 @@ extern "C" fn run_custom_function<F, Ret, RetSqlType>(
}
Ok(())
})
.unwrap_or_else(|p| {
Err(SqliteCallbackError::Panic(
p,
data_ptr.function_name.clone(),
))
});
.unwrap_or_else(|p| Err(SqliteCallbackError::Panic(data_ptr.function_name.clone())));
if let Err(e) = result {
e.emit(ctx);
}
Expand Down Expand Up @@ -383,10 +378,10 @@ extern "C" fn run_aggregator_step_function<ArgsSqlType, RetSqlType, Args, Ret, A
run_aggregator_step::<A, Args, ArgsSqlType>(ctx, args)
})
.unwrap_or_else(|e| {
Err(SqliteCallbackError::Panic(
e,
format!("{}::step() panicked", std::any::type_name::<A>()),
))
Err(SqliteCallbackError::Panic(format!(
"{}::step() panicked",
std::any::type_name::<A>()
)))
});

match result {
Expand Down Expand Up @@ -496,11 +491,11 @@ extern "C" fn run_aggregator_final_function<ArgsSqlType, RetSqlType, Args, Ret,
}
Ok(())
})
.unwrap_or_else(|e| {
Err(SqliteCallbackError::Panic(
e,
format!("{}::finalize() panicked", std::any::type_name::<A>()),
))
.unwrap_or_else(|_e| {
Err(SqliteCallbackError::Panic(format!(
"{}::finalize() panicked",
std::any::type_name::<A>()
)))
});
if let Err(e) = result {
e.emit(ctx);
Expand Down Expand Up @@ -570,7 +565,6 @@ where
})
.unwrap_or_else(|p| {
Err(SqliteCallbackError::Panic(
p,
user_ptr
.map(|u| u.collation_name.clone())
.unwrap_or_default(),
Expand Down Expand Up @@ -601,7 +595,7 @@ where
);
std::process::abort()
}
Err(SqliteCallbackError::Panic(_, msg)) => {
Err(SqliteCallbackError::Panic(msg)) => {
eprintln!("Collation function {} panicked", msg);
std::process::abort()
}
Expand Down
6 changes: 3 additions & 3 deletions diesel_derives/src/parsers/belongs_to.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use syn::{Ident, TypePath};
use crate::util::{parse_eq, unknown_attribute, BELONGS_TO_NOTE};

enum Attr {
ForeignKey(Ident, Ident),
ForeignKey(Ident),
}

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

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

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

for attr in Punctuated::<Attr, Comma>::parse_terminated(input)? {
match attr {
Attr::ForeignKey(_, value) => foreign_key = Some(value),
Attr::ForeignKey(value) => foreign_key = Some(value),
}
}

Expand Down
6 changes: 3 additions & 3 deletions diesel_derives/src/parsers/mysql_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use syn::{Ident, LitStr};
use crate::util::{parse_eq, unknown_attribute, MYSQL_TYPE_NOTE};

enum Attr {
Name(Ident, LitStr),
Name(LitStr),
}

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

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

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

for attr in Punctuated::<Attr, Comma>::parse_terminated(input)? {
match attr {
Attr::Name(_, value) => name = Some(value),
Attr::Name(value) => name = Some(value),
}
}

Expand Down
6 changes: 3 additions & 3 deletions diesel_derives/src/parsers/sqlite_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use syn::{Ident, LitStr};
use crate::util::{parse_eq, unknown_attribute, SQLITE_TYPE_NOTE};

enum Attr {
Name(Ident, LitStr),
Name(LitStr),
}

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

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

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

for attr in Punctuated::<Attr, Comma>::parse_terminated(input)? {
match attr {
Attr::Name(_, value) => name = Some(value),
Attr::Name(value) => name = Some(value),
}
}

Expand Down
2 changes: 2 additions & 0 deletions diesel_tests/tests/insert_from_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ fn on_conflict_do_update_with_boxed_select() {

users
.select((id, name.concat(" says hi")))
.order(id)
.into_boxed()
.insert_into(posts)
.into_columns((user_id, title))
Expand All @@ -411,6 +412,7 @@ fn on_conflict_do_update_with_boxed_select() {

users
.select((id, name.concat(" says hi")))
.order(id)
.into_boxed()
.insert_into(posts)
.into_columns((user_id, title))
Expand Down

0 comments on commit dfeec4b

Please sign in to comment.