mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-29 21:52:12 +08:00
Fix clippy warnings
This commit is contained in:
parent
9484f5c15e
commit
8302a50fb8
@ -8,7 +8,7 @@ use std::mem;
|
|||||||
mod error;
|
mod error;
|
||||||
|
|
||||||
pub fn SQLITE_STATIC() -> sqlite3_destructor_type {
|
pub fn SQLITE_STATIC() -> sqlite3_destructor_type {
|
||||||
Some(unsafe { mem::transmute(0isize) })
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SQLITE_TRANSIENT() -> sqlite3_destructor_type {
|
pub fn SQLITE_TRANSIENT() -> sqlite3_destructor_type {
|
||||||
|
18
src/error.rs
18
src/error.rs
@ -142,7 +142,7 @@ impl PartialEq for Error {
|
|||||||
(Error::UnwindingPanic, Error::UnwindingPanic) => true,
|
(Error::UnwindingPanic, Error::UnwindingPanic) => true,
|
||||||
#[cfg(feature = "functions")]
|
#[cfg(feature = "functions")]
|
||||||
(Error::GetAuxWrongType, Error::GetAuxWrongType) => true,
|
(Error::GetAuxWrongType, Error::GetAuxWrongType) => true,
|
||||||
(_, _) => false,
|
(..) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,7 +261,7 @@ impl error::Error for Error {
|
|||||||
"SQLite was compiled or configured for single-threaded use only"
|
"SQLite was compiled or configured for single-threaded use only"
|
||||||
}
|
}
|
||||||
Error::FromSqlConversionFailure(_, _, ref err) => err.description(),
|
Error::FromSqlConversionFailure(_, _, ref err) => err.description(),
|
||||||
Error::IntegralValueOutOfRange(_, _) => "integral value out of range of requested type",
|
Error::IntegralValueOutOfRange(..) => "integral value out of range of requested type",
|
||||||
Error::Utf8Error(ref err) => err.description(),
|
Error::Utf8Error(ref err) => err.description(),
|
||||||
Error::InvalidParameterName(_) => "invalid parameter name",
|
Error::InvalidParameterName(_) => "invalid parameter name",
|
||||||
Error::NulError(ref err) => err.description(),
|
Error::NulError(ref err) => err.description(),
|
||||||
@ -272,13 +272,13 @@ impl error::Error for Error {
|
|||||||
Error::QueryReturnedNoRows => "query returned no rows",
|
Error::QueryReturnedNoRows => "query returned no rows",
|
||||||
Error::InvalidColumnIndex(_) => "invalid column index",
|
Error::InvalidColumnIndex(_) => "invalid column index",
|
||||||
Error::InvalidColumnName(_) => "invalid column name",
|
Error::InvalidColumnName(_) => "invalid column name",
|
||||||
Error::InvalidColumnType(_, _, _) => "invalid column type",
|
Error::InvalidColumnType(..) => "invalid column type",
|
||||||
Error::StatementChangedRows(_) => "query inserted zero or more than one row",
|
Error::StatementChangedRows(_) => "query inserted zero or more than one row",
|
||||||
|
|
||||||
#[cfg(feature = "functions")]
|
#[cfg(feature = "functions")]
|
||||||
Error::InvalidFunctionParameterType(_, _) => "invalid function parameter type",
|
Error::InvalidFunctionParameterType(..) => "invalid function parameter type",
|
||||||
#[cfg(feature = "vtab")]
|
#[cfg(feature = "vtab")]
|
||||||
Error::InvalidFilterParameterType(_, _) => "invalid filter parameter type",
|
Error::InvalidFilterParameterType(..) => "invalid filter parameter type",
|
||||||
#[cfg(feature = "functions")]
|
#[cfg(feature = "functions")]
|
||||||
Error::UserFunctionError(ref err) => err.description(),
|
Error::UserFunctionError(ref err) => err.description(),
|
||||||
Error::ToSqlConversionFailure(ref err) => err.description(),
|
Error::ToSqlConversionFailure(ref err) => err.description(),
|
||||||
@ -299,23 +299,23 @@ impl error::Error for Error {
|
|||||||
Error::Utf8Error(ref err) => Some(err),
|
Error::Utf8Error(ref err) => Some(err),
|
||||||
Error::NulError(ref err) => Some(err),
|
Error::NulError(ref err) => Some(err),
|
||||||
|
|
||||||
Error::IntegralValueOutOfRange(_, _)
|
Error::IntegralValueOutOfRange(..)
|
||||||
| Error::SqliteSingleThreadedMode
|
| Error::SqliteSingleThreadedMode
|
||||||
| Error::InvalidParameterName(_)
|
| Error::InvalidParameterName(_)
|
||||||
| Error::ExecuteReturnedResults
|
| Error::ExecuteReturnedResults
|
||||||
| Error::QueryReturnedNoRows
|
| Error::QueryReturnedNoRows
|
||||||
| Error::InvalidColumnIndex(_)
|
| Error::InvalidColumnIndex(_)
|
||||||
| Error::InvalidColumnName(_)
|
| Error::InvalidColumnName(_)
|
||||||
| Error::InvalidColumnType(_, _, _)
|
| Error::InvalidColumnType(..)
|
||||||
| Error::InvalidPath(_)
|
| Error::InvalidPath(_)
|
||||||
| Error::StatementChangedRows(_)
|
| Error::StatementChangedRows(_)
|
||||||
| Error::InvalidQuery
|
| Error::InvalidQuery
|
||||||
| Error::MultipleStatement => None,
|
| Error::MultipleStatement => None,
|
||||||
|
|
||||||
#[cfg(feature = "functions")]
|
#[cfg(feature = "functions")]
|
||||||
Error::InvalidFunctionParameterType(_, _) => None,
|
Error::InvalidFunctionParameterType(..) => None,
|
||||||
#[cfg(feature = "vtab")]
|
#[cfg(feature = "vtab")]
|
||||||
Error::InvalidFilterParameterType(_, _) => None,
|
Error::InvalidFilterParameterType(..) => None,
|
||||||
|
|
||||||
#[cfg(feature = "functions")]
|
#[cfg(feature = "functions")]
|
||||||
Error::UserFunctionError(ref err) => Some(&**err),
|
Error::UserFunctionError(ref err) => Some(&**err),
|
||||||
|
@ -92,7 +92,7 @@ impl InnerConnection {
|
|||||||
if let Error::SqliteFailure(
|
if let Error::SqliteFailure(
|
||||||
ffi::Error {
|
ffi::Error {
|
||||||
code: ffi::ErrorCode::CannotOpen,
|
code: ffi::ErrorCode::CannotOpen,
|
||||||
extended_code: _,
|
..
|
||||||
},
|
},
|
||||||
Some(msg),
|
Some(msg),
|
||||||
) = e
|
) = e
|
||||||
|
32
src/lib.rs
32
src/lib.rs
@ -701,7 +701,11 @@ impl Connection {
|
|||||||
///
|
///
|
||||||
/// You should not need to use this function. If you do need to, please
|
/// You should not need to use this function. If you do need to, please
|
||||||
/// [open an issue on the rusqlite repository](https://github.com/jgallagher/rusqlite/issues) and describe
|
/// [open an issue on the rusqlite repository](https://github.com/jgallagher/rusqlite/issues) and describe
|
||||||
/// your use case. This function is unsafe because it gives you raw access
|
/// your use case.
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// This function is unsafe because it gives you raw access
|
||||||
/// to the SQLite connection, and what you do with it could impact the
|
/// to the SQLite connection, and what you do with it could impact the
|
||||||
/// safety of this `Connection`.
|
/// safety of this `Connection`.
|
||||||
pub unsafe fn handle(&self) -> *mut ffi::sqlite3 {
|
pub unsafe fn handle(&self) -> *mut ffi::sqlite3 {
|
||||||
@ -797,8 +801,11 @@ impl Default for OpenFlags {
|
|||||||
/// If you are encountering that panic _and_ can ensure that SQLite has been
|
/// If you are encountering that panic _and_ can ensure that SQLite has been
|
||||||
/// initialized in either multi-thread or serialized mode, call this function
|
/// initialized in either multi-thread or serialized mode, call this function
|
||||||
/// prior to attempting to open a connection and rusqlite's initialization
|
/// prior to attempting to open a connection and rusqlite's initialization
|
||||||
/// process will by skipped. This
|
/// process will by skipped.
|
||||||
/// function is unsafe because if you call it and SQLite has actually been
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// This function is unsafe because if you call it and SQLite has actually been
|
||||||
/// configured to run in single-thread mode,
|
/// configured to run in single-thread mode,
|
||||||
/// you may enounter memory errors or data corruption or any number of terrible
|
/// you may enounter memory errors or data corruption or any number of terrible
|
||||||
/// things that should not be possible when you're using Rust.
|
/// things that should not be possible when you're using Rust.
|
||||||
@ -809,11 +816,13 @@ pub unsafe fn bypass_sqlite_initialization() {
|
|||||||
/// rusqlite performs a one-time check that the runtime SQLite version is at
|
/// rusqlite performs a one-time check that the runtime SQLite version is at
|
||||||
/// least as new as the version of SQLite found when rusqlite was built.
|
/// least as new as the version of SQLite found when rusqlite was built.
|
||||||
/// Bypassing this check may be dangerous; e.g., if you use features of SQLite
|
/// Bypassing this check may be dangerous; e.g., if you use features of SQLite
|
||||||
/// that are not present in the runtime
|
/// that are not present in the runtime version.
|
||||||
/// version. If you are sure the runtime version is compatible with the
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// If you are sure the runtime version is compatible with the
|
||||||
/// build-time version for your usage, you can bypass the version check by
|
/// build-time version for your usage, you can bypass the version check by
|
||||||
/// calling this function before
|
/// calling this function before your first connection attempt.
|
||||||
/// your first connection attempt.
|
|
||||||
pub unsafe fn bypass_sqlite_version_check() {
|
pub unsafe fn bypass_sqlite_version_check() {
|
||||||
#[cfg(not(feature = "bundled"))]
|
#[cfg(not(feature = "bundled"))]
|
||||||
inner_connection::BYPASS_VERSION_CHECK.store(true, Ordering::Relaxed);
|
inner_connection::BYPASS_VERSION_CHECK.store(true, Ordering::Relaxed);
|
||||||
@ -992,10 +1001,11 @@ mod test {
|
|||||||
let raw_db = db.db.borrow_mut().db;
|
let raw_db = db.db.borrow_mut().db;
|
||||||
let sql = "SELECT 1";
|
let sql = "SELECT 1";
|
||||||
let mut raw_stmt = MaybeUninit::uninit();
|
let mut raw_stmt = MaybeUninit::uninit();
|
||||||
|
let cstring = str_to_cstring(sql).unwrap();
|
||||||
let rc = unsafe {
|
let rc = unsafe {
|
||||||
ffi::sqlite3_prepare_v2(
|
ffi::sqlite3_prepare_v2(
|
||||||
raw_db,
|
raw_db,
|
||||||
str_to_cstring(sql).unwrap().as_ptr(),
|
cstring.as_ptr(),
|
||||||
(sql.len() + 1) as c_int,
|
(sql.len() + 1) as c_int,
|
||||||
raw_stmt.as_mut_ptr(),
|
raw_stmt.as_mut_ptr(),
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
@ -1511,7 +1521,7 @@ mod test {
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
match bad_type.unwrap_err() {
|
match bad_type.unwrap_err() {
|
||||||
Error::InvalidColumnType(_, _, _) => (),
|
Error::InvalidColumnType(..) => (),
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {}", err),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1566,7 +1576,7 @@ mod test {
|
|||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
match bad_type.unwrap_err() {
|
match bad_type.unwrap_err() {
|
||||||
CustomError::Sqlite(Error::InvalidColumnType(_, _, _)) => (),
|
CustomError::Sqlite(Error::InvalidColumnType(..)) => (),
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {}", err),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1623,7 +1633,7 @@ mod test {
|
|||||||
});
|
});
|
||||||
|
|
||||||
match bad_type.unwrap_err() {
|
match bad_type.unwrap_err() {
|
||||||
CustomError::Sqlite(Error::InvalidColumnType(_, _, _)) => (),
|
CustomError::Sqlite(Error::InvalidColumnType(..)) => (),
|
||||||
err => panic!("Unexpected error {}", err),
|
err => panic!("Unexpected error {}", err),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1051,7 +1051,7 @@ mod test {
|
|||||||
use std::collections::BTreeSet;
|
use std::collections::BTreeSet;
|
||||||
let data: BTreeSet<String> = ["one", "two", "three"]
|
let data: BTreeSet<String> = ["one", "two", "three"]
|
||||||
.iter()
|
.iter()
|
||||||
.map(|s| s.to_string())
|
.map(|s| (*s).to_string())
|
||||||
.collect();
|
.collect();
|
||||||
db.query_row("SELECT ?1, ?2, ?3", &data, |row| row.get::<_, String>(0))
|
db.query_row("SELECT ?1, ?2, ?3", &data, |row| row.get::<_, String>(0))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -12,6 +12,9 @@ use crate::error::error_from_sqlite_code;
|
|||||||
use crate::{Connection, Result};
|
use crate::{Connection, Result};
|
||||||
|
|
||||||
/// Set up the process-wide SQLite error logging callback.
|
/// Set up the process-wide SQLite error logging callback.
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
/// This function is marked unsafe for two reasons:
|
/// This function is marked unsafe for two reasons:
|
||||||
///
|
///
|
||||||
/// * The function is not threadsafe. No other SQLite calls may be made while
|
/// * The function is not threadsafe. No other SQLite calls may be made while
|
||||||
|
@ -36,7 +36,7 @@ impl PartialEq for FromSqlError {
|
|||||||
(FromSqlError::InvalidI128Size(s1), FromSqlError::InvalidI128Size(s2)) => s1 == s2,
|
(FromSqlError::InvalidI128Size(s1), FromSqlError::InvalidI128Size(s2)) => s1 == s2,
|
||||||
#[cfg(feature = "uuid")]
|
#[cfg(feature = "uuid")]
|
||||||
(FromSqlError::InvalidUuidSize(s1), FromSqlError::InvalidUuidSize(s2)) => s1 == s2,
|
(FromSqlError::InvalidUuidSize(s1), FromSqlError::InvalidUuidSize(s2)) => s1 == s2,
|
||||||
(_, _) => false,
|
(..) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ mod test {
|
|||||||
fn test_mismatched_types() {
|
fn test_mismatched_types() {
|
||||||
fn is_invalid_column_type(err: Error) -> bool {
|
fn is_invalid_column_type(err: Error) -> bool {
|
||||||
match err {
|
match err {
|
||||||
Error::InvalidColumnType(_, _, _) => true,
|
Error::InvalidColumnType(..) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,11 @@ impl VTabConnection {
|
|||||||
///
|
///
|
||||||
/// You should not need to use this function. If you do need to, please
|
/// You should not need to use this function. If you do need to, please
|
||||||
/// [open an issue on the rusqlite repository](https://github.com/jgallagher/rusqlite/issues) and describe
|
/// [open an issue on the rusqlite repository](https://github.com/jgallagher/rusqlite/issues) and describe
|
||||||
/// your use case. This function is unsafe because it gives you raw access
|
/// your use case.
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// This function is unsafe because it gives you raw access
|
||||||
/// to the SQLite connection, and what you do with it could impact the
|
/// to the SQLite connection, and what you do with it could impact the
|
||||||
/// safety of this `Connection`.
|
/// safety of this `Connection`.
|
||||||
pub unsafe fn handle(&mut self) -> *mut ffi::sqlite3 {
|
pub unsafe fn handle(&mut self) -> *mut ffi::sqlite3 {
|
||||||
|
Loading…
Reference in New Issue
Block a user