diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index 2321c91..dee18af 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -74,11 +74,13 @@ mod build_bundled { .flag("-DSQLITE_THREADSAFE=1") .flag("-DSQLITE_USE_URI") .flag("-DHAVE_USLEEP=1"); - // Older versions of visual studio don't support c99 (including isnan), which causes a - // build failure when the linker fails to find the `isnan` function. `sqlite` provides its - // own implmentation, using the fact that x != x when x is NaN. + // Older versions of visual studio don't support c99 (including isnan), which + // causes a build failure when the linker fails to find the `isnan` + // function. `sqlite` provides its own implmentation, using the fact + // that x != x when x is NaN. // - // There may be other platforms that don't support `isnan`, they should be tested for here. + // There may be other platforms that don't support `isnan`, they should be + // tested for here. if cfg!(target_env = "msvc") { use self::cc::windows_registry::{find_vs_version, VsVers}; let vs_has_nan = match find_vs_version() { diff --git a/src/busy.rs b/src/busy.rs index f801e3f..b9bfc65 100644 --- a/src/busy.rs +++ b/src/busy.rs @@ -137,7 +137,7 @@ mod test { #[test] #[ignore] // FIXME: unstable fn test_busy_handler() { - lazy_static! { + lazy_static::lazy_static! { static ref CALLED: AtomicBool = AtomicBool::new(false); } fn busy_handler(_: i32) -> bool { diff --git a/src/error.rs b/src/error.rs index abd4669..b932465 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,5 +1,5 @@ -use crate::types::Type; use crate::types::FromSqlError; +use crate::types::Type; use crate::{errmsg_to_string, ffi}; use std::error; use std::fmt; @@ -162,15 +162,16 @@ const UNKNOWN_COLUMN: usize = std::usize::MAX; /// to allow use of `get_raw(…).as_…()?` in callbacks that take `Error`. impl From for Error { fn from(err: FromSqlError) -> Error { - // The error type requires index and type fields, but they aren't known in this context. + // The error type requires index and type fields, but they aren't known in this + // context. match err { FromSqlError::OutOfRange(val) => Error::IntegralValueOutOfRange(UNKNOWN_COLUMN, val), #[cfg(feature = "i128_blob")] - FromSqlError::InvalidI128Size(s) => { + FromSqlError::InvalidI128Size(_) => { Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Blob, Box::new(err)) } #[cfg(feature = "uuid")] - FromSqlError::InvalidUuidSize(s) => { + FromSqlError::InvalidUuidSize(_) => { Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Blob, Box::new(err)) } FromSqlError::Other(source) => { @@ -190,20 +191,24 @@ impl fmt::Display for Error { f, "SQLite was compiled or configured for single-threaded use only" ), - Error::FromSqlConversionFailure(i, ref t, ref err) => if i != UNKNOWN_COLUMN { - write!( - f, - "Conversion error from type {} at index: {}, {}", - t, i, err - ) - } else { - err.fmt(f) - }, - Error::IntegralValueOutOfRange(col, val) => if col != UNKNOWN_COLUMN { - write!(f, "Integer {} out of range at index {}", val, col) - } else { - write!(f, "Integer {} out of range", val) - }, + Error::FromSqlConversionFailure(i, ref t, ref err) => { + if i != UNKNOWN_COLUMN { + write!( + f, + "Conversion error from type {} at index: {}, {}", + t, i, err + ) + } else { + err.fmt(f) + } + } + Error::IntegralValueOutOfRange(col, val) => { + if col != UNKNOWN_COLUMN { + write!(f, "Integer {} out of range at index {}", val, col) + } else { + write!(f, "Integer {} out of range", val) + } + } Error::Utf8Error(ref err) => err.fmt(f), Error::NulError(ref err) => err.fmt(f), Error::InvalidParameterName(ref name) => write!(f, "Invalid parameter name: {}", name), diff --git a/src/hooks.rs b/src/hooks.rs index 3131462..e8efe76 100644 --- a/src/hooks.rs +++ b/src/hooks.rs @@ -236,6 +236,7 @@ fn free_boxed_hook(p: *mut c_void) { mod test { use super::Action; use crate::Connection; + use lazy_static::lazy_static; use std::sync::atomic::{AtomicBool, Ordering}; #[test] diff --git a/src/lib.rs b/src/lib.rs index d7883529..31c483c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -58,12 +58,6 @@ pub use libsqlite3_sys as ffi; -#[macro_use] -extern crate bitflags; -#[cfg(any(test, feature = "vtab"))] -#[macro_use] -extern crate lazy_static; - use std::cell::RefCell; use std::convert; use std::default::Default; @@ -761,7 +755,7 @@ impl fmt::Debug for Connection { } } -bitflags! { +bitflags::bitflags! { #[doc = "Flags for opening SQLite database connections."] #[doc = "See [sqlite3_open_v2](http://www.sqlite.org/c3ref/open.html) for details."] #[repr(C)] diff --git a/src/session.rs b/src/session.rs index 4ff88b6..bce3e1a 100644 --- a/src/session.rs +++ b/src/session.rs @@ -822,7 +822,7 @@ mod test { db.execute_batch("CREATE TABLE foo(t TEXT PRIMARY KEY NOT NULL);") .unwrap(); - lazy_static! { + lazy_static::lazy_static! { static ref CALLED: AtomicBool = AtomicBool::new(false); } db.apply( diff --git a/src/trace.rs b/src/trace.rs index 8af3f27..572b21f 100644 --- a/src/trace.rs +++ b/src/trace.rs @@ -122,6 +122,7 @@ impl Connection { #[cfg(test)] mod test { + use lazy_static::lazy_static; use std::sync::Mutex; use std::time::Duration; diff --git a/src/vtab/array.rs b/src/vtab/array.rs index 1b4bd46..5a572a1 100644 --- a/src/vtab/array.rs +++ b/src/vtab/array.rs @@ -35,7 +35,7 @@ pub fn load_module(conn: &Connection) -> Result<()> { conn.create_module("rarray", &ARRAY_MODULE, aux) } -lazy_static! { +lazy_static::lazy_static! { static ref ARRAY_MODULE: Module = eponymous_only_module::(1); } diff --git a/src/vtab/csvtab.rs b/src/vtab/csvtab.rs index bf092b0..acae3fc 100644 --- a/src/vtab/csvtab.rs +++ b/src/vtab/csvtab.rs @@ -32,7 +32,7 @@ pub fn load_module(conn: &Connection) -> Result<()> { conn.create_module("csv", &CSV_MODULE, aux) } -lazy_static! { +lazy_static::lazy_static! { static ref CSV_MODULE: Module = read_only_module::(1); } diff --git a/src/vtab/mod.rs b/src/vtab/mod.rs index 2a7191d..5ec10ca 100644 --- a/src/vtab/mod.rs +++ b/src/vtab/mod.rs @@ -234,7 +234,7 @@ pub trait CreateVTab: VTab { } } -bitflags! { +bitflags::bitflags! { #[doc = "Index constraint operator."] #[repr(C)] pub struct IndexConstraintOp: ::std::os::raw::c_uchar { diff --git a/src/vtab/series.rs b/src/vtab/series.rs index 722ed4b..c0d1100 100644 --- a/src/vtab/series.rs +++ b/src/vtab/series.rs @@ -18,7 +18,7 @@ pub fn load_module(conn: &Connection) -> Result<()> { conn.create_module("generate_series", &SERIES_MODULE, aux) } -lazy_static! { +lazy_static::lazy_static! { static ref SERIES_MODULE: Module = eponymous_only_module::(1); } @@ -28,7 +28,7 @@ const SERIES_COLUMN_START: c_int = 1; const SERIES_COLUMN_STOP: c_int = 2; const SERIES_COLUMN_STEP: c_int = 3; -bitflags! { +bitflags::bitflags! { #[repr(C)] struct QueryPlanFlags: ::std::os::raw::c_int { // start = $value -- constraint exists diff --git a/tests/config_log.rs b/tests/config_log.rs index d51acf5..0c28bdf 100644 --- a/tests/config_log.rs +++ b/tests/config_log.rs @@ -2,12 +2,9 @@ //! function affects SQLite process-wide and so is not safe to run as a normal //! #[test] in the library. -#[cfg(feature = "trace")] -#[macro_use] -extern crate lazy_static; - #[cfg(feature = "trace")] fn main() { + use lazy_static::lazy_static; use std::os::raw::c_int; use std::sync::Mutex;