mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-10-02 15:25:32 +00:00
Fix some clippy lints
This commit is contained in:
parent
672f724aac
commit
3c7c266eac
@ -3,7 +3,7 @@ use console::style;
|
|||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
const MIGRATION_FOLDER: &'static str = "migrations";
|
const MIGRATION_FOLDER: &str = "migrations";
|
||||||
|
|
||||||
pub struct Migration {
|
pub struct Migration {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
@ -54,7 +54,7 @@ impl<'a, T> Stream for TryAsyncStream<'a, T> {
|
|||||||
pin_mut!(receiver);
|
pin_mut!(receiver);
|
||||||
|
|
||||||
// then we check to see if we have anything to return
|
// then we check to see if we have anything to return
|
||||||
return receiver.poll_next(cx);
|
receiver.poll_next(cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +122,6 @@ impl Decode<'_, MySql> for i32 {
|
|||||||
|
|
||||||
impl Decode<'_, MySql> for i64 {
|
impl Decode<'_, MySql> for i64 {
|
||||||
fn decode(value: MySqlValueRef<'_>) -> Result<Self, BoxDynError> {
|
fn decode(value: MySqlValueRef<'_>) -> Result<Self, BoxDynError> {
|
||||||
int_decode(value)?.try_into().map_err(Into::into)
|
int_decode(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,6 @@ impl Decode<'_, MySql> for u32 {
|
|||||||
|
|
||||||
impl Decode<'_, MySql> for u64 {
|
impl Decode<'_, MySql> for u64 {
|
||||||
fn decode(value: MySqlValueRef<'_>) -> Result<Self, BoxDynError> {
|
fn decode(value: MySqlValueRef<'_>) -> Result<Self, BoxDynError> {
|
||||||
uint_decode(value)?.try_into().map_err(Into::into)
|
uint_decode(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ pub struct PgArgumentBuffer {
|
|||||||
patches: Vec<(
|
patches: Vec<(
|
||||||
usize, // offset
|
usize, // offset
|
||||||
usize, // argument index
|
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
|
// Whenever an `Encode` impl encounters a `PgTypeInfo` object that does not have an OID
|
||||||
|
@ -317,10 +317,10 @@ impl PgConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
Err(err_protocol!(
|
return Err(err_protocol!(
|
||||||
"execute: unexpected message: {:?}",
|
"execute: unexpected message: {:?}",
|
||||||
message.format
|
message.format
|
||||||
))?;
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -995,20 +995,18 @@ impl PartialEq<PgType> for PgType {
|
|||||||
if let (Some(a), Some(b)) = (self.try_oid(), other.try_oid()) {
|
if let (Some(a), Some(b)) = (self.try_oid(), other.try_oid()) {
|
||||||
// If there are OIDs available, use OIDs to perform a direct match
|
// If there are OIDs available, use OIDs to perform a direct match
|
||||||
a == b
|
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 {
|
} else {
|
||||||
if (matches!(self, PgType::DeclareWithName(_))
|
// Otherwise, perform a match on the name
|
||||||
&& matches!(other, PgType::DeclareWithOid(_)))
|
self.name().eq_ignore_ascii_case(other.name())
|
||||||
|| (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())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ pub fn check_transparent_attributes(
|
|||||||
Ok(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)?;
|
let attributes = parse_container_attributes(&input.attrs)?;
|
||||||
|
|
||||||
assert_attribute!(
|
assert_attribute!(
|
||||||
|
@ -38,11 +38,9 @@ impl ToTokens for QuotedMigration {
|
|||||||
// mostly copied from sqlx-core/src/migrate/source.rs
|
// mostly copied from sqlx-core/src/migrate/source.rs
|
||||||
pub(crate) fn expand_migrator_from_dir(dir: LitStr) -> crate::Result<proc_macro2::TokenStream> {
|
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 path = crate::common::resolve_path(&dir.value(), dir.span())?;
|
||||||
let mut s = fs::read_dir(path)?;
|
|
||||||
|
|
||||||
let mut migrations = Vec::new();
|
let mut migrations = Vec::new();
|
||||||
|
|
||||||
while let Some(entry) = s.next() {
|
for entry in fs::read_dir(path)? {
|
||||||
let entry = entry?;
|
let entry = entry?;
|
||||||
if !entry.metadata()?.is_file() {
|
if !entry.metadata()?.is_file() {
|
||||||
// not a file; ignore
|
// not a file; ignore
|
||||||
|
@ -86,7 +86,7 @@ fn expand_from_db(input: QueryMacroInput, db_url: &str) -> crate::Result<TokenSt
|
|||||||
},
|
},
|
||||||
|
|
||||||
#[cfg(not(feature = "postgres"))]
|
#[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")]
|
#[cfg(feature = "mssql")]
|
||||||
"mssql" | "sqlserver" => {
|
"mssql" | "sqlserver" => {
|
||||||
@ -99,7 +99,7 @@ fn expand_from_db(input: QueryMacroInput, db_url: &str) -> crate::Result<TokenSt
|
|||||||
},
|
},
|
||||||
|
|
||||||
#[cfg(not(feature = "mssql"))]
|
#[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")]
|
#[cfg(feature = "mysql")]
|
||||||
"mysql" | "mariadb" => {
|
"mysql" | "mariadb" => {
|
||||||
@ -112,7 +112,7 @@ fn expand_from_db(input: QueryMacroInput, db_url: &str) -> crate::Result<TokenSt
|
|||||||
},
|
},
|
||||||
|
|
||||||
#[cfg(not(feature = "mysql"))]
|
#[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")]
|
#[cfg(feature = "sqlite")]
|
||||||
"sqlite" => {
|
"sqlite" => {
|
||||||
@ -125,7 +125,7 @@ fn expand_from_db(input: QueryMacroInput, db_url: &str) -> crate::Result<TokenSt
|
|||||||
},
|
},
|
||||||
|
|
||||||
#[cfg(not(feature = "sqlite"))]
|
#[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())
|
scheme => Err(format!("unknown database URL scheme {:?}", scheme).into())
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,7 @@ pub(super) enum ColumnType {
|
|||||||
|
|
||||||
impl ColumnType {
|
impl ColumnType {
|
||||||
pub(super) fn is_wildcard(&self) -> bool {
|
pub(super) fn is_wildcard(&self) -> bool {
|
||||||
match self {
|
!matches!(self, ColumnType::Exact(_))
|
||||||
ColumnType::Exact(_) => false,
|
|
||||||
_ => true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user