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) {
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.
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")]
{
@ -159,12 +158,11 @@ mod build_bundled {
let lib_dir = lib_dir.unwrap_or_else(|| openssl_dir.join("lib"));
let inc_dir = inc_dir.unwrap_or_else(|| openssl_dir.join("include"));
if !Path::new(&lib_dir).exists() {
panic!(
assert!(
Path::new(&lib_dir).exists(),
"OpenSSL library directory does not exist: {}",
lib_dir.to_string_lossy()
);
}
if !Path::new(&inc_dir).exists() {
panic!(
@ -221,7 +219,8 @@ mod build_bundled {
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") {
cfg.static_crt(true);
}

View File

@ -430,8 +430,7 @@ fn ensure_safe_sqlite_threading_mode() -> Result<()> {
}
unsafe {
if ffi::sqlite3_config(ffi::SQLITE_CONFIG_MULTITHREAD) != ffi::SQLITE_OK || ffi::sqlite3_initialize() != ffi::SQLITE_OK {
panic!(
assert!(ffi::sqlite3_config(ffi::SQLITE_CONFIG_MULTITHREAD) == ffi::SQLITE_OK && ffi::sqlite3_initialize() == ffi::SQLITE_OK,
"Could not ensure safe initialization of SQLite.\n\
To fix this, either:\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."
);
}
}
});
Ok(())
}

View File

@ -679,7 +679,7 @@ impl Connection {
stmt.check_no_tail()?;
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.
@ -1346,9 +1346,11 @@ mod test {
fn test_execute_select() {
let db = checked_memory_handle();
let err = db.execute("SELECT 1 WHERE 1 < ?", [1i32]).unwrap_err();
if err != Error::ExecuteReturnedResults {
panic!("Unexpected error: {}", err);
}
assert!(
err == Error::ExecuteReturnedResults,
"Unexpected error: {}",
err
);
}
#[test]

View File

@ -156,7 +156,7 @@ where
self.rows
.next()
.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
.next()
.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)?;
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

View File

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