Merge pull request #560 from gwenn/clean

Clean
This commit is contained in:
gwenn 2019-08-09 20:25:25 +02:00 committed by GitHub
commit cb6f890e48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 40 additions and 40 deletions

View File

@ -74,11 +74,13 @@ mod build_bundled {
.flag("-DSQLITE_THREADSAFE=1") .flag("-DSQLITE_THREADSAFE=1")
.flag("-DSQLITE_USE_URI") .flag("-DSQLITE_USE_URI")
.flag("-DHAVE_USLEEP=1"); .flag("-DHAVE_USLEEP=1");
// Older versions of visual studio don't support c99 (including isnan), which causes a // Older versions of visual studio don't support c99 (including isnan), which
// build failure when the linker fails to find the `isnan` function. `sqlite` provides its // causes a build failure when the linker fails to find the `isnan`
// own implmentation, using the fact that x != x when x is NaN. // 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") { if cfg!(target_env = "msvc") {
use self::cc::windows_registry::{find_vs_version, VsVers}; use self::cc::windows_registry::{find_vs_version, VsVers};
let vs_has_nan = match find_vs_version() { let vs_has_nan = match find_vs_version() {

View File

@ -137,7 +137,7 @@ mod test {
#[test] #[test]
#[ignore] // FIXME: unstable #[ignore] // FIXME: unstable
fn test_busy_handler() { fn test_busy_handler() {
lazy_static! { lazy_static::lazy_static! {
static ref CALLED: AtomicBool = AtomicBool::new(false); static ref CALLED: AtomicBool = AtomicBool::new(false);
} }
fn busy_handler(_: i32) -> bool { fn busy_handler(_: i32) -> bool {

View File

@ -1,5 +1,5 @@
use crate::types::Type;
use crate::types::FromSqlError; use crate::types::FromSqlError;
use crate::types::Type;
use crate::{errmsg_to_string, ffi}; use crate::{errmsg_to_string, ffi};
use std::error; use std::error;
use std::fmt; 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`. /// to allow use of `get_raw(…).as_…()?` in callbacks that take `Error`.
impl From<FromSqlError> for Error { impl From<FromSqlError> for Error {
fn from(err: FromSqlError) -> 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 { match err {
FromSqlError::OutOfRange(val) => Error::IntegralValueOutOfRange(UNKNOWN_COLUMN, val), FromSqlError::OutOfRange(val) => Error::IntegralValueOutOfRange(UNKNOWN_COLUMN, val),
#[cfg(feature = "i128_blob")] #[cfg(feature = "i128_blob")]
FromSqlError::InvalidI128Size(s) => { FromSqlError::InvalidI128Size(_) => {
Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Blob, Box::new(err)) Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Blob, Box::new(err))
} }
#[cfg(feature = "uuid")] #[cfg(feature = "uuid")]
FromSqlError::InvalidUuidSize(s) => { FromSqlError::InvalidUuidSize(_) => {
Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Blob, Box::new(err)) Error::FromSqlConversionFailure(UNKNOWN_COLUMN, Type::Blob, Box::new(err))
} }
FromSqlError::Other(source) => { FromSqlError::Other(source) => {
@ -190,20 +191,24 @@ impl fmt::Display for Error {
f, f,
"SQLite was compiled or configured for single-threaded use only" "SQLite was compiled or configured for single-threaded use only"
), ),
Error::FromSqlConversionFailure(i, ref t, ref err) => if i != UNKNOWN_COLUMN { Error::FromSqlConversionFailure(i, ref t, ref err) => {
write!( if i != UNKNOWN_COLUMN {
f, write!(
"Conversion error from type {} at index: {}, {}", f,
t, i, err "Conversion error from type {} at index: {}, {}",
) t, i, err
} else { )
err.fmt(f) } else {
}, err.fmt(f)
Error::IntegralValueOutOfRange(col, val) => if col != UNKNOWN_COLUMN { }
write!(f, "Integer {} out of range at index {}", val, col) }
} else { Error::IntegralValueOutOfRange(col, val) => {
write!(f, "Integer {} out of range", 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::Utf8Error(ref err) => err.fmt(f),
Error::NulError(ref err) => err.fmt(f), Error::NulError(ref err) => err.fmt(f),
Error::InvalidParameterName(ref name) => write!(f, "Invalid parameter name: {}", name), Error::InvalidParameterName(ref name) => write!(f, "Invalid parameter name: {}", name),

View File

@ -236,6 +236,7 @@ fn free_boxed_hook<F>(p: *mut c_void) {
mod test { mod test {
use super::Action; use super::Action;
use crate::Connection; use crate::Connection;
use lazy_static::lazy_static;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
#[test] #[test]

View File

@ -58,12 +58,6 @@
pub use libsqlite3_sys as ffi; 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::cell::RefCell;
use std::convert; use std::convert;
use std::default::Default; use std::default::Default;
@ -761,7 +755,7 @@ impl fmt::Debug for Connection {
} }
} }
bitflags! { bitflags::bitflags! {
#[doc = "Flags for opening SQLite database connections."] #[doc = "Flags for opening SQLite database connections."]
#[doc = "See [sqlite3_open_v2](http://www.sqlite.org/c3ref/open.html) for details."] #[doc = "See [sqlite3_open_v2](http://www.sqlite.org/c3ref/open.html) for details."]
#[repr(C)] #[repr(C)]

View File

@ -822,7 +822,7 @@ mod test {
db.execute_batch("CREATE TABLE foo(t TEXT PRIMARY KEY NOT NULL);") db.execute_batch("CREATE TABLE foo(t TEXT PRIMARY KEY NOT NULL);")
.unwrap(); .unwrap();
lazy_static! { lazy_static::lazy_static! {
static ref CALLED: AtomicBool = AtomicBool::new(false); static ref CALLED: AtomicBool = AtomicBool::new(false);
} }
db.apply( db.apply(

View File

@ -122,6 +122,7 @@ impl Connection {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use lazy_static::lazy_static;
use std::sync::Mutex; use std::sync::Mutex;
use std::time::Duration; use std::time::Duration;

View File

@ -35,7 +35,7 @@ pub fn load_module(conn: &Connection) -> Result<()> {
conn.create_module("rarray", &ARRAY_MODULE, aux) conn.create_module("rarray", &ARRAY_MODULE, aux)
} }
lazy_static! { lazy_static::lazy_static! {
static ref ARRAY_MODULE: Module<ArrayTab> = eponymous_only_module::<ArrayTab>(1); static ref ARRAY_MODULE: Module<ArrayTab> = eponymous_only_module::<ArrayTab>(1);
} }

View File

@ -32,7 +32,7 @@ pub fn load_module(conn: &Connection) -> Result<()> {
conn.create_module("csv", &CSV_MODULE, aux) conn.create_module("csv", &CSV_MODULE, aux)
} }
lazy_static! { lazy_static::lazy_static! {
static ref CSV_MODULE: Module<CSVTab> = read_only_module::<CSVTab>(1); static ref CSV_MODULE: Module<CSVTab> = read_only_module::<CSVTab>(1);
} }

View File

@ -234,7 +234,7 @@ pub trait CreateVTab: VTab {
} }
} }
bitflags! { bitflags::bitflags! {
#[doc = "Index constraint operator."] #[doc = "Index constraint operator."]
#[repr(C)] #[repr(C)]
pub struct IndexConstraintOp: ::std::os::raw::c_uchar { pub struct IndexConstraintOp: ::std::os::raw::c_uchar {

View File

@ -18,7 +18,7 @@ pub fn load_module(conn: &Connection) -> Result<()> {
conn.create_module("generate_series", &SERIES_MODULE, aux) conn.create_module("generate_series", &SERIES_MODULE, aux)
} }
lazy_static! { lazy_static::lazy_static! {
static ref SERIES_MODULE: Module<SeriesTab> = eponymous_only_module::<SeriesTab>(1); static ref SERIES_MODULE: Module<SeriesTab> = eponymous_only_module::<SeriesTab>(1);
} }
@ -28,7 +28,7 @@ const SERIES_COLUMN_START: c_int = 1;
const SERIES_COLUMN_STOP: c_int = 2; const SERIES_COLUMN_STOP: c_int = 2;
const SERIES_COLUMN_STEP: c_int = 3; const SERIES_COLUMN_STEP: c_int = 3;
bitflags! { bitflags::bitflags! {
#[repr(C)] #[repr(C)]
struct QueryPlanFlags: ::std::os::raw::c_int { struct QueryPlanFlags: ::std::os::raw::c_int {
// start = $value -- constraint exists // start = $value -- constraint exists

View File

@ -2,12 +2,9 @@
//! function affects SQLite process-wide and so is not safe to run as a normal //! function affects SQLite process-wide and so is not safe to run as a normal
//! #[test] in the library. //! #[test] in the library.
#[cfg(feature = "trace")]
#[macro_use]
extern crate lazy_static;
#[cfg(feature = "trace")] #[cfg(feature = "trace")]
fn main() { fn main() {
use lazy_static::lazy_static;
use std::os::raw::c_int; use std::os::raw::c_int;
use std::sync::Mutex; use std::sync::Mutex;