fix clipyy warnings

This commit is contained in:
Marcin Kaźmierczak 2020-11-23 22:10:28 +01:00 committed by Ryan Leckey
parent 274a69c020
commit 9ad0c71253
No known key found for this signature in database
GPG key ID: F8AA68C235AB08C9
10 changed files with 34 additions and 31 deletions

View file

@ -1,4 +1,5 @@
mod error;
#[allow(clippy::module_inception)]
mod migrate;
mod migration;
mod migration_type;

View file

@ -58,12 +58,12 @@ impl SqliteArguments<'_> {
for param_i in 1..=cnt {
// figure out the index of this bind parameter into our argument tuple
let n: usize = if let Some(name) = handle.bind_parameter_name(param_i) {
if name.starts_with('?') {
if let Some(name) = name.strip_prefix('?') {
// parameter should have the form ?NNN
atoi(name[1..].as_bytes()).expect("parameter of the form ?NNN")
} else if name.starts_with('$') {
atoi(name.as_bytes()).expect("parameter of the form ?NNN")
} else if let Some(name) = name.strip_prefix('$') {
// parameter should have the form $NNN
atoi(name[1..].as_bytes()).ok_or_else(|| {
atoi(name.as_bytes()).ok_or_else(|| {
err_protocol!(
"parameters with non-integer names are not currently supported: {}",
name

View file

@ -110,8 +110,8 @@ impl<'c> Executor<'c> for &'c mut SqliteConnection {
};
let done = SqliteDone {
changes: changes,
last_insert_rowid: last_insert_rowid,
changes,
last_insert_rowid,
};
r#yield!(Either::Left(done));

View file

@ -47,6 +47,7 @@ const OP_REMAINDER: &str = "Remainder";
const OP_CONCAT: &str = "Concat";
const OP_RESULT_ROW: &str = "ResultRow";
#[allow(clippy::wildcard_in_or_patterns)]
fn affinity_to_type(affinity: u8) -> DataType {
match affinity {
SQLITE_AFF_BLOB => DataType::Blob,
@ -59,6 +60,7 @@ fn affinity_to_type(affinity: u8) -> DataType {
}
}
#[allow(clippy::wildcard_in_or_patterns)]
fn opcode_to_type(op: &str) -> DataType {
match op {
OP_REAL => DataType::Float,
@ -115,14 +117,10 @@ pub(super) async fn explain(
OP_FUNCTION => {
// r[p1] = func( _ )
match from_utf8(p4).map_err(Error::protocol)? {
"last_insert_rowid(0)" => {
// last_insert_rowid() -> INTEGER
r.insert(p3, DataType::Int64);
n.insert(p3, false);
}
_ => {}
if from_utf8(p4).map_err(Error::protocol)? == "last_insert_rowid(0)" {
// last_insert_rowid() -> INTEGER
r.insert(p3, DataType::Int64);
n.insert(p3, false);
}
}

View file

@ -108,11 +108,11 @@ CREATE TABLE IF NOT EXISTS _sqlx_migrations (
.await?;
if let Some(checksum) = checksum {
return if checksum == &*migration.checksum {
if checksum == &*migration.checksum {
Ok(())
} else {
Err(MigrateError::VersionMismatch(migration.version))
};
}
} else {
Err(MigrateError::VersionMissing(migration.version))
}

View file

@ -1,3 +1,5 @@
#![allow(clippy::rc_buffer)]
use std::ptr::null_mut;
use std::slice;
use std::sync::atomic::{AtomicPtr, Ordering};
@ -67,6 +69,7 @@ impl SqliteRow {
// inflates this Row into memory as a list of owned, protected SQLite value objects
// this is called by the
#[allow(clippy::needless_range_loop)]
pub(crate) fn inflate(
statement: &StatementHandle,
columns: &[SqliteColumn],

View file

@ -17,6 +17,7 @@ pub(crate) use r#virtual::VirtualStatement;
pub(crate) use worker::StatementWorker;
#[derive(Debug, Clone)]
#[allow(clippy::rc_buffer)]
pub struct SqliteStatement<'q> {
pub(crate) sql: Cow<'q, str>,
pub(crate) parameters: usize,

View file

@ -1,3 +1,5 @@
#![allow(clippy::rc_buffer)]
use crate::error::Error;
use crate::ext::ustr::UStr;
use crate::sqlite::connection::ConnectionHandle;

View file

@ -128,24 +128,21 @@ pub fn parse_child_attributes(input: &[Attribute]) -> syn::Result<SqlxChildAttri
.parse_meta()
.map_err(|e| syn::Error::new_spanned(attr, e))?;
match meta {
Meta::List(list) => {
for value in list.nested.iter() {
match value {
NestedMeta::Meta(meta) => match meta {
Meta::NameValue(MetaNameValue {
path,
lit: Lit::Str(val),
..
}) if path.is_ident("rename") => try_set!(rename, val.value(), value),
Meta::Path(path) if path.is_ident("default") => default = true,
u => fail!(u, "unexpected attribute"),
},
if let Meta::List(list) = meta {
for value in list.nested.iter() {
match value {
NestedMeta::Meta(meta) => match meta {
Meta::NameValue(MetaNameValue {
path,
lit: Lit::Str(val),
..
}) if path.is_ident("rename") => try_set!(rename, val.value(), value),
Meta::Path(path) if path.is_ident("default") => default = true,
u => fail!(u, "unexpected attribute"),
}
},
u => fail!(u, "unexpected attribute"),
}
}
_ => {}
}
}

View file

@ -15,6 +15,7 @@ use std::marker::PhantomData;
// specialization (but this works only if all types are statically known, i.e. we're not in a
// generic context; this should suit 99% of use cases for the macros).
#[allow(clippy::just_underscores_and_digits)]
pub fn same_type<T>(_1: &T, _2: &T) {}
pub struct WrapSame<T, U>(PhantomData<T>, PhantomData<U>);