Fix clippy warnings

This commit is contained in:
gwenn 2021-10-01 20:09:48 +02:00
parent e2af87f747
commit ce90b519bb
6 changed files with 22 additions and 23 deletions

View File

@ -85,10 +85,9 @@ mod build_bundled {
pub fn main(out_dir: &str, out_path: &Path) { pub fn main(out_dir: &str, out_path: &Path) {
let lib_name = super::lib_name(); let lib_name = super::lib_name();
if cfg!(feature = "bundled-windows") && !cfg!(feature = "bundled") && !win_target() {
// This is just a sanity check, the top level `main` should ensure this. // This is just a sanity check, the top level `main` should ensure this.
panic!("This module should not be used: we're not on Windows and the bundled feature has not been enabled"); assert!(!(cfg!(feature = "bundled-windows") && !cfg!(feature = "bundled") && !win_target()),
} "This module should not be used: we're not on Windows and the bundled feature has not been enabled");
#[cfg(feature = "buildtime_bindgen")] #[cfg(feature = "buildtime_bindgen")]
{ {
@ -159,12 +158,11 @@ mod build_bundled {
let lib_dir = lib_dir.unwrap_or_else(|| openssl_dir.join("lib")); let lib_dir = lib_dir.unwrap_or_else(|| openssl_dir.join("lib"));
let inc_dir = inc_dir.unwrap_or_else(|| openssl_dir.join("include")); let inc_dir = inc_dir.unwrap_or_else(|| openssl_dir.join("include"));
if !Path::new(&lib_dir).exists() { assert!(
panic!( Path::new(&lib_dir).exists(),
"OpenSSL library directory does not exist: {}", "OpenSSL library directory does not exist: {}",
lib_dir.to_string_lossy() lib_dir.to_string_lossy()
); );
}
if !Path::new(&inc_dir).exists() { if !Path::new(&inc_dir).exists() {
panic!( panic!(
@ -221,7 +219,8 @@ mod build_bundled {
cfg.flag("-fsanitize=address"); cfg.flag("-fsanitize=address");
} }
// If explicitly requested: enable static linking against the Microsoft Visual C++ Runtime to avoid dependencies on vcruntime140.dll and similar libraries. // If explicitly requested: enable static linking against the Microsoft Visual
// C++ Runtime to avoid dependencies on vcruntime140.dll and similar libraries.
if cfg!(target_feature = "crt-static") && is_compiler("msvc") { if cfg!(target_feature = "crt-static") && is_compiler("msvc") {
cfg.static_crt(true); cfg.static_crt(true);
} }

View File

@ -430,8 +430,7 @@ fn ensure_safe_sqlite_threading_mode() -> Result<()> {
} }
unsafe { unsafe {
if ffi::sqlite3_config(ffi::SQLITE_CONFIG_MULTITHREAD) != ffi::SQLITE_OK || ffi::sqlite3_initialize() != ffi::SQLITE_OK { assert!(ffi::sqlite3_config(ffi::SQLITE_CONFIG_MULTITHREAD) == ffi::SQLITE_OK && ffi::sqlite3_initialize() == ffi::SQLITE_OK,
panic!(
"Could not ensure safe initialization of SQLite.\n\ "Could not ensure safe initialization of SQLite.\n\
To fix this, either:\n\ To fix this, either:\n\
* Upgrade SQLite to at least version 3.7.0\n\ * Upgrade SQLite to at least version 3.7.0\n\
@ -439,7 +438,6 @@ fn ensure_safe_sqlite_threading_mode() -> Result<()> {
rusqlite::bypass_sqlite_initialization() prior to your first connection attempt." rusqlite::bypass_sqlite_initialization() prior to your first connection attempt."
); );
} }
}
}); });
Ok(()) Ok(())
} }

View File

@ -679,7 +679,7 @@ impl Connection {
stmt.check_no_tail()?; stmt.check_no_tail()?;
let mut rows = stmt.query(params)?; let mut rows = stmt.query(params)?;
rows.get_expected_row().map_err(E::from).and_then(|r| f(r)) rows.get_expected_row().map_err(E::from).and_then(f)
} }
/// Prepare a SQL statement for execution. /// Prepare a SQL statement for execution.
@ -1346,9 +1346,11 @@ mod test {
fn test_execute_select() { fn test_execute_select() {
let db = checked_memory_handle(); let db = checked_memory_handle();
let err = db.execute("SELECT 1 WHERE 1 < ?", [1i32]).unwrap_err(); let err = db.execute("SELECT 1 WHERE 1 < ?", [1i32]).unwrap_err();
if err != Error::ExecuteReturnedResults { assert!(
panic!("Unexpected error: {}", err); err == Error::ExecuteReturnedResults,
} "Unexpected error: {}",
err
);
} }
#[test] #[test]

View File

@ -156,7 +156,7 @@ where
self.rows self.rows
.next() .next()
.transpose() .transpose()
.map(|row_result| row_result.and_then(|row| (map)(row))) .map(|row_result| row_result.and_then(map))
} }
} }
@ -181,7 +181,7 @@ where
self.rows self.rows
.next() .next()
.transpose() .transpose()
.map(|row_result| row_result.map_err(E::from).and_then(|row| (map)(row))) .map(|row_result| row_result.map_err(E::from).and_then(map))
} }
} }

View File

@ -453,7 +453,7 @@ impl Statement<'_> {
{ {
let mut rows = self.query(params)?; let mut rows = self.query(params)?;
rows.get_expected_row().and_then(|r| f(r)) rows.get_expected_row().and_then(f)
} }
/// Convenience method to execute a query with named parameter(s) that is /// Convenience method to execute a query with named parameter(s) that is

View File

@ -431,7 +431,7 @@ impl<'a> Iterator for IndexConstraintIter<'a> {
#[inline] #[inline]
fn next(&mut self) -> Option<IndexConstraint<'a>> { fn next(&mut self) -> Option<IndexConstraint<'a>> {
self.iter.next().map(|raw| IndexConstraint(raw)) self.iter.next().map(IndexConstraint)
} }
#[inline] #[inline]
@ -492,7 +492,7 @@ impl<'a> Iterator for OrderByIter<'a> {
#[inline] #[inline]
fn next(&mut self) -> Option<OrderBy<'a>> { fn next(&mut self) -> Option<OrderBy<'a>> {
self.iter.next().map(|raw| OrderBy(raw)) self.iter.next().map(OrderBy)
} }
#[inline] #[inline]