Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a few new lint warnings about dead code #3927

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading