diff --git a/src/error.rs b/src/error.rs index 3662d37..ebc79b7 100644 --- a/src/error.rs +++ b/src/error.rs @@ -140,6 +140,7 @@ impl error::Error for Error { } } + #[allow(match_same_arms)] fn cause(&self) -> Option<&error::Error> { match *self { Error::SqliteFailure(ref err, _) => Some(err), @@ -159,6 +160,7 @@ impl error::Error for Error { #[cfg(feature = "functions")] Error::InvalidFunctionParameterType => None, + #[cfg(feature = "functions")] Error::UserFunctionError(ref err) => Some(&**err), } diff --git a/src/functions.rs b/src/functions.rs index e00221a..8fd78f0 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -307,7 +307,7 @@ impl<'a> Context<'a> { ffi::sqlite3_set_auxdata(self.ctx, arg, mem::transmute(boxed), - Some(mem::transmute(free_boxed_value::))) + Some(free_boxed_value::)) }; } @@ -480,7 +480,7 @@ impl InnerConnection { Some(call_boxed_closure::), None, None, - Some(mem::transmute(free_boxed_value::))) + Some(free_boxed_value::)) }; self.decode_result(r) } @@ -597,7 +597,7 @@ impl InnerConnection { None, Some(call_boxed_step::), Some(call_boxed_final::), - Some(mem::transmute(free_boxed_value::))) + Some(free_boxed_value::)) }; self.decode_result(r) } @@ -626,6 +626,7 @@ mod test { use std::collections::HashMap; use libc::c_double; use self::regex::Regex; + use std::f64::EPSILON; use {Connection, Error, Result}; use functions::{Aggregate, Context}; @@ -642,7 +643,7 @@ mod test { db.create_scalar_function("half", 1, true, half).unwrap(); let result: Result = db.query_row("SELECT half(6)", &[], |r| r.get(0)); - assert_eq!(3f64, result.unwrap()); + assert!((3f64 - result.unwrap()).abs() < EPSILON); } #[test] @@ -650,7 +651,7 @@ mod test { let db = Connection::open_in_memory().unwrap(); db.create_scalar_function("half", 1, true, half).unwrap(); let result: Result = db.query_row("SELECT half(6)", &[], |r| r.get(0)); - assert_eq!(3f64, result.unwrap()); + assert!((3f64 - result.unwrap()).abs() < EPSILON); db.remove_function("half", 1).unwrap(); let result: Result = db.query_row("SELECT half(6)", &[], |r| r.get(0)); diff --git a/src/lib.rs b/src/lib.rs index 952ebe0..930e1c6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,9 +53,6 @@ #![cfg_attr(feature="clippy", feature(plugin))] #![cfg_attr(feature="clippy", plugin(clippy))] -// Clippy complains about SQLite in our doc comments, but they're fine. -#![cfg_attr(feature="clippy", allow(doc_markdown))] - extern crate libc; extern crate libsqlite3_sys as ffi; #[macro_use] @@ -1224,10 +1221,9 @@ mod test { #[test] fn test_open_with_flags() { - for bad_flags in [OpenFlags::empty(), - SQLITE_OPEN_READ_ONLY | SQLITE_OPEN_READ_WRITE, - SQLITE_OPEN_READ_ONLY | SQLITE_OPEN_CREATE] - .iter() { + for bad_flags in &[OpenFlags::empty(), + SQLITE_OPEN_READ_ONLY | SQLITE_OPEN_READ_WRITE, + SQLITE_OPEN_READ_ONLY | SQLITE_OPEN_CREATE] { assert!(Connection::open_in_memory_with_flags(*bad_flags).is_err()); } } diff --git a/src/transaction.rs b/src/transaction.rs index 5ef4909..e72add4 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -174,6 +174,7 @@ impl<'conn> Drop for Transaction<'conn> { } #[cfg(test)] +#[cfg_attr(feature="clippy", allow(similar_names))] mod test { use Connection; diff --git a/src/types.rs b/src/types.rs index aca7fad..4a92d72 100644 --- a/src/types.rs +++ b/src/types.rs @@ -328,11 +328,13 @@ impl FromSql for Value { } #[cfg(test)] +#[cfg_attr(feature="clippy", allow(similar_names))] mod test { use Connection; use super::time; use Error; use libc::{c_int, c_double}; + use std::f64::EPSILON; fn checked_memory_handle() -> Connection { let db = Connection::open_in_memory().unwrap(); @@ -403,6 +405,7 @@ mod test { } #[test] + #[cfg_attr(feature="clippy", allow(cyclomatic_complexity))] fn test_mismatched_types() { fn is_invalid_column_type(err: Error) -> bool { match err { @@ -426,7 +429,7 @@ mod test { assert_eq!(vec![1, 2], row.get_checked::>(0).unwrap()); assert_eq!("text", row.get_checked::(1).unwrap()); assert_eq!(1, row.get_checked::(2).unwrap()); - assert_eq!(1.5, row.get_checked::(3).unwrap()); + assert!((1.5 - row.get_checked::(3).unwrap()).abs() < EPSILON); assert!(row.get_checked::>(4).unwrap().is_none()); assert!(row.get_checked::>(4).unwrap().is_none()); assert!(row.get_checked::>(4).unwrap().is_none()); @@ -491,7 +494,10 @@ mod test { assert_eq!(Value::Text(String::from("text")), row.get_checked::(1).unwrap()); assert_eq!(Value::Integer(1), row.get_checked::(2).unwrap()); - assert_eq!(Value::Real(1.5), row.get_checked::(3).unwrap()); + match row.get_checked::(3).unwrap() { + Value::Real(val) => assert!((1.5 - val).abs() < EPSILON), + x => panic!("Invalid Value {:?}", x), + } assert_eq!(Value::Null, row.get_checked::(4).unwrap()); } }