Fix some clippy lints

This commit is contained in:
Jonas Platte 2020-11-17 20:47:21 +01:00 committed by Austin Bonander
parent 672f724aac
commit 3c7c266eac
11 changed files with 25 additions and 32 deletions

View file

@ -3,7 +3,7 @@ use console::style;
use std::fs::{self, File};
use std::io::{Read, Write};
const MIGRATION_FOLDER: &'static str = "migrations";
const MIGRATION_FOLDER: &str = "migrations";
pub struct Migration {
pub name: String,

View file

@ -54,7 +54,7 @@ impl<'a, T> Stream for TryAsyncStream<'a, T> {
pin_mut!(receiver);
// then we check to see if we have anything to return
return receiver.poll_next(cx);
receiver.poll_next(cx)
}
}

View file

@ -122,6 +122,6 @@ impl Decode<'_, MySql> for i32 {
impl Decode<'_, MySql> for i64 {
fn decode(value: MySqlValueRef<'_>) -> Result<Self, BoxDynError> {
int_decode(value)?.try_into().map_err(Into::into)
int_decode(value)
}
}

View file

@ -145,6 +145,6 @@ impl Decode<'_, MySql> for u32 {
impl Decode<'_, MySql> for u64 {
fn decode(value: MySqlValueRef<'_>) -> Result<Self, BoxDynError> {
uint_decode(value)?.try_into().map_err(Into::into)
uint_decode(value)
}
}

View file

@ -33,7 +33,7 @@ pub struct PgArgumentBuffer {
patches: Vec<(
usize, // offset
usize, // argument index
Box<dyn Fn(&mut [u8], &PgTypeInfo) -> () + 'static + Send + Sync>,
Box<dyn Fn(&mut [u8], &PgTypeInfo) + 'static + Send + Sync>,
)>,
// Whenever an `Encode` impl encounters a `PgTypeInfo` object that does not have an OID

View file

@ -317,10 +317,10 @@ impl PgConnection {
}
_ => {
Err(err_protocol!(
return Err(err_protocol!(
"execute: unexpected message: {:?}",
message.format
))?;
));
}
}
}

View file

@ -995,20 +995,18 @@ impl PartialEq<PgType> for PgType {
if let (Some(a), Some(b)) = (self.try_oid(), other.try_oid()) {
// If there are OIDs available, use OIDs to perform a direct match
a == b
} else if (matches!(self, PgType::DeclareWithName(_))
&& matches!(other, PgType::DeclareWithOid(_)))
|| (matches!(other, PgType::DeclareWithName(_))
&& matches!(self, PgType::DeclareWithOid(_)))
{
// One is a declare-with-name and the other is a declare-with-id
// This only occurs in the TEXT protocol with custom types
// Just opt-out of type checking here
true
} else {
if (matches!(self, PgType::DeclareWithName(_))
&& matches!(other, PgType::DeclareWithOid(_)))
|| (matches!(other, PgType::DeclareWithName(_))
&& matches!(self, PgType::DeclareWithOid(_)))
{
// One is a declare-with-name and the other is a declare-with-id
// This only occurs in the TEXT protocol with custom types
// Just opt-out of type checking here
true
} else {
// Otherwise, perform a match on the name
self.name().eq_ignore_ascii_case(other.name())
}
// Otherwise, perform a match on the name
self.name().eq_ignore_ascii_case(other.name())
}
}
}

View file

@ -177,7 +177,7 @@ pub fn check_transparent_attributes(
Ok(attributes)
}
pub fn check_enum_attributes<'a>(input: &'a DeriveInput) -> syn::Result<SqlxContainerAttributes> {
pub fn check_enum_attributes(input: &DeriveInput) -> syn::Result<SqlxContainerAttributes> {
let attributes = parse_container_attributes(&input.attrs)?;
assert_attribute!(

View file

@ -38,11 +38,9 @@ impl ToTokens for QuotedMigration {
// mostly copied from sqlx-core/src/migrate/source.rs
pub(crate) fn expand_migrator_from_dir(dir: LitStr) -> crate::Result<proc_macro2::TokenStream> {
let path = crate::common::resolve_path(&dir.value(), dir.span())?;
let mut s = fs::read_dir(path)?;
let mut migrations = Vec::new();
while let Some(entry) = s.next() {
for entry in fs::read_dir(path)? {
let entry = entry?;
if !entry.metadata()?.is_file() {
// not a file; ignore

View file

@ -86,7 +86,7 @@ fn expand_from_db(input: QueryMacroInput, db_url: &str) -> crate::Result<TokenSt
},
#[cfg(not(feature = "postgres"))]
"postgres" | "postgresql" => Err(format!("database URL has the scheme of a PostgreSQL database but the `postgres` feature is not enabled").into()),
"postgres" | "postgresql" => Err("database URL has the scheme of a PostgreSQL database but the `postgres` feature is not enabled".into()),
#[cfg(feature = "mssql")]
"mssql" | "sqlserver" => {
@ -99,7 +99,7 @@ fn expand_from_db(input: QueryMacroInput, db_url: &str) -> crate::Result<TokenSt
},
#[cfg(not(feature = "mssql"))]
"mssql" | "sqlserver" => Err(format!("database URL has the scheme of a MSSQL database but the `mssql` feature is not enabled").into()),
"mssql" | "sqlserver" => Err("database URL has the scheme of a MSSQL database but the `mssql` feature is not enabled".into()),
#[cfg(feature = "mysql")]
"mysql" | "mariadb" => {
@ -112,7 +112,7 @@ fn expand_from_db(input: QueryMacroInput, db_url: &str) -> crate::Result<TokenSt
},
#[cfg(not(feature = "mysql"))]
"mysql" | "mariadb" => Err(format!("database URL has the scheme of a MySQL/MariaDB database but the `mysql` feature is not enabled").into()),
"mysql" | "mariadb" => Err("database URL has the scheme of a MySQL/MariaDB database but the `mysql` feature is not enabled".into()),
#[cfg(feature = "sqlite")]
"sqlite" => {
@ -125,7 +125,7 @@ fn expand_from_db(input: QueryMacroInput, db_url: &str) -> crate::Result<TokenSt
},
#[cfg(not(feature = "sqlite"))]
"sqlite" => Err(format!("database URL has the scheme of a SQLite database but the `sqlite` feature is not enabled").into()),
"sqlite" => Err("database URL has the scheme of a SQLite database but the `sqlite` feature is not enabled".into()),
scheme => Err(format!("unknown database URL scheme {:?}", scheme).into())
}

View file

@ -25,10 +25,7 @@ pub(super) enum ColumnType {
impl ColumnType {
pub(super) fn is_wildcard(&self) -> bool {
match self {
ColumnType::Exact(_) => false,
_ => true,
}
!matches!(self, ColumnType::Exact(_))
}
}