From 2d25b344288f78b49b968f46e2bc01d67cebc88c Mon Sep 17 00:00:00 2001 From: gwenn Date: Thu, 19 Dec 2019 20:08:04 +0100 Subject: [PATCH] Fix some Clippy warnings --- libsqlite3-sys/build.rs | 20 +++++++++++--------- libsqlite3-sys/src/lib.rs | 6 +++++- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index 7a04922..3a98c5a 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -138,10 +138,12 @@ impl From for String { match header { HeaderLocation::FromEnvironment => { let prefix = env_prefix(); - let mut header = env::var(format!("{}_INCLUDE_DIR", prefix)).expect(&format!( - "{}_INCLUDE_DIR must be set if {}_LIB_DIR is set", - prefix, prefix - )); + let mut header = env::var(format!("{}_INCLUDE_DIR", prefix)).unwrap_or_else(|_| { + panic!( + "{}_INCLUDE_DIR must be set if {}_LIB_DIR is set", + prefix, prefix + ) + }); header.push_str("/sqlite3.h"); header } @@ -209,7 +211,7 @@ mod build_linked { // Try to use pkg-config to determine link commands let pkgconfig_path = Path::new(&dir).join("pkgconfig"); env::set_var("PKG_CONFIG_PATH", pkgconfig_path); - if let Err(_) = pkg_config::Config::new().probe(link_lib) { + if pkg_config::Config::new().probe(link_lib).is_err() { // Otherwise just emit the bare minimum link commands. println!("cargo:rustc-link-lib={}={}", find_link_mode(), link_lib); println!("cargo:rustc-link-search={}", dir); @@ -338,7 +340,7 @@ mod bindings { bindings .generate() - .expect(&format!("could not run bindgen on header {}", header)) + .unwrap_or_else(|_| panic!("could not run bindgen on header {}", header)) .write(Box::new(&mut output)) .expect("could not write output of bindgen"); let mut output = String::from_utf8(output).expect("bindgen output was not UTF-8?!"); @@ -357,10 +359,10 @@ mod bindings { .write(true) .truncate(true) .create(true) - .open(out_path.clone()) - .expect(&format!("Could not write to {:?}", out_path)); + .open(out_path) + .unwrap_or_else(|_| panic!("Could not write to {:?}", out_path)); file.write_all(output.as_bytes()) - .expect(&format!("Could not write to {:?}", out_path)); + .unwrap_or_else(|_| panic!("Could not write to {:?}", out_path)); } } diff --git a/libsqlite3-sys/src/lib.rs b/libsqlite3-sys/src/lib.rs index 7b169b6..82fcc26 100644 --- a/libsqlite3-sys/src/lib.rs +++ b/libsqlite3-sys/src/lib.rs @@ -49,7 +49,11 @@ pub enum Limit { SQLITE_LIMIT_WORKER_THREADS = 11, } -include!(concat!(env!("OUT_DIR"), "/bindgen.rs")); +#[allow(clippy::all)] +mod bindings { + include!(concat!(env!("OUT_DIR"), "/bindgen.rs")); +} +pub use bindings::*; pub type sqlite3_index_constraint = sqlite3_index_info_sqlite3_index_constraint; pub type sqlite3_index_constraint_usage = sqlite3_index_info_sqlite3_index_constraint_usage;