diff --git a/Cargo.toml b/Cargo.toml index 363e8bbb4c..02c227b242 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -103,3 +103,4 @@ warnings = "deny" [workspace.lints.clippy] all = "deny" +unwrap_used = { level = "deny", allow-unwrap-in-tests = true } diff --git a/build-vortex/src/lib.rs b/build-vortex/src/lib.rs index 5e70edc4c0..ac6e9c5724 100644 --- a/build-vortex/src/lib.rs +++ b/build-vortex/src/lib.rs @@ -8,13 +8,13 @@ use flatc::flatc; use walkdir::WalkDir; fn manifest_dir() -> PathBuf { - PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()) + PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set")) .canonicalize() .expect("Failed to canonicalize CARGO_MANIFEST_DIR") } fn out_dir() -> PathBuf { - PathBuf::from(env::var("OUT_DIR").unwrap()) + PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR not set")) .canonicalize() .expect("Failed to canonicalize OUT_DIR") } @@ -79,18 +79,29 @@ fn rerun_if_changed(path: &Path) { println!( "cargo:rerun-if-changed={}", path.canonicalize() - .unwrap_or_else(|_| panic!("failed to canonicalize {}", path.to_str().unwrap())) + .unwrap_or_else(|_| panic!( + "failed to canonicalize {}", + path.to_str().expect("not unicode") + )) .to_str() - .unwrap() + .expect("not unicode") ); } fn check_call(command: &mut Command) { - let name = command.get_program().to_str().unwrap().to_string(); + let name = command + .get_program() + .to_str() + .expect("not unicode") + .to_string(); let Ok(status) = command.status() else { panic!("Failed to launch {}", &name) }; if !status.success() { - panic!("{} failed with status {}", &name, status.code().unwrap()); + panic!( + "{} failed with status {}", + &name, + status.code().expect("process terminated by signal") + ); } } diff --git a/fastlanez-sys/build.rs b/fastlanez-sys/build.rs index 7292af079b..496c250785 100644 --- a/fastlanez-sys/build.rs +++ b/fastlanez-sys/build.rs @@ -5,9 +5,10 @@ use std::process::{Command, Stdio}; use walkdir::WalkDir; fn main() { - let buildrs_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()) - .canonicalize() - .expect("Failed to canonicalize CARGO_MANIFEST_DIR"); + let buildrs_dir = + PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("missing CARGO_MANIFEST_DIR")) + .canonicalize() + .expect("Failed to canonicalize CARGO_MANIFEST_DIR"); let root_dir = buildrs_dir .join("../") .canonicalize() @@ -17,7 +18,10 @@ fn main() { // Tell cargo to tell rustc to link fastlanez println!( "cargo:rustc-link-search={}", - fastlanez_dir.join("zig-out/lib").to_str().unwrap() + fastlanez_dir + .join("zig-out/lib") + .to_str() + .expect("not unicode") ); println!("cargo:rustc-link-lib=fastlanez"); @@ -37,13 +41,13 @@ fn main() { .spawn() .expect("Could not invoke `zig build`") .wait() - .unwrap() + .expect("Failed to wait on `zig build`") .success() { // Panic if the command was not successful. panic!( "failed to successfully invoke `zig build` in {}", - root_dir.to_str().unwrap() + root_dir.to_str().expect("not unicode") ); } @@ -52,7 +56,7 @@ fn main() { fastlanez_dir .join("zig-out/include/fastlanez.h") .to_str() - .unwrap(), + .expect("not unicode"), ) .clang_args(&[ get_zig_include().as_ref(), @@ -64,7 +68,7 @@ fn main() { .expect("Unable to generate bindings"); // Write the bindings to the $OUT_DIR/bindings.rs file. - let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + let out_path = PathBuf::from(env::var("OUT_DIR").expect("missing OUT_DIR")); bindings .write_to_file(out_path.join("bindings.rs")) .expect("Couldn't write bindings!"); @@ -74,15 +78,18 @@ fn rerun_if_changed(path: &Path) { println!( "cargo:rerun-if-changed={}", path.canonicalize() - .unwrap_or_else(|_| panic!("failed to canonicalize {}", path.to_str().unwrap())) + .unwrap_or_else(|_| panic!( + "failed to canonicalize {}", + path.to_str().expect("not unicode") + )) .to_str() - .unwrap() + .expect("not unicode") ); } fn get_zig_opt() -> &'static str { - let profile_env = env::var("PROFILE").unwrap(); - let opt_level_zero = env::var("OPT_LEVEL").unwrap() == "0"; + let profile_env = env::var("PROFILE").expect("PROFILE not set"); + let opt_level_zero = env::var("OPT_LEVEL").expect("OPT_LEVEL not set") == "0"; // based on https://doc.rust-lang.org/cargo/reference/environment-variables.html // diff --git a/vortex-array/src/lib.rs b/vortex-array/src/lib.rs index 6513db3df6..0f0be09af9 100644 --- a/vortex-array/src/lib.rs +++ b/vortex-array/src/lib.rs @@ -44,7 +44,7 @@ pub mod flatbuffers { #[allow(unused_imports)] #[allow(dead_code)] #[allow(non_camel_case_types)] - #[allow(clippy::all)] + #[allow(clippy::all, clippy::restriction)] mod generated { include!(concat!(env!("OUT_DIR"), "/flatbuffers/array.rs")); } diff --git a/vortex-dtype/src/lib.rs b/vortex-dtype/src/lib.rs index 179d9d3a61..7e6f33e538 100644 --- a/vortex-dtype/src/lib.rs +++ b/vortex-dtype/src/lib.rs @@ -22,9 +22,8 @@ pub mod proto { pub mod flatbuffers { #[allow(unused_imports)] #[allow(dead_code)] - #[allow(dead_code)] - #[allow(clippy::all)] #[allow(non_camel_case_types)] + #[allow(clippy::all, clippy::restriction)] mod generated { include!(concat!(env!("OUT_DIR"), "/flatbuffers/dtype.rs")); } diff --git a/vortex-ipc/src/lib.rs b/vortex-ipc/src/lib.rs index e54e86eaf4..0344889026 100644 --- a/vortex-ipc/src/lib.rs +++ b/vortex-ipc/src/lib.rs @@ -8,7 +8,7 @@ pub mod flatbuffers { #[allow(unused_imports)] #[allow(dead_code)] #[allow(non_camel_case_types)] - #[allow(clippy::all)] + #[allow(clippy::all, clippy::restriction)] mod generated { include!(concat!(env!("OUT_DIR"), "/flatbuffers/message.rs")); } diff --git a/vortex-scalar/src/lib.rs b/vortex-scalar/src/lib.rs index faeee748cd..46cb7e83e5 100644 --- a/vortex-scalar/src/lib.rs +++ b/vortex-scalar/src/lib.rs @@ -42,7 +42,7 @@ pub mod flatbuffers { #[allow(unused_imports)] #[allow(dead_code)] #[allow(non_camel_case_types)] - #[allow(clippy::all)] + #[allow(clippy::all, clippy::restriction)] pub mod generated { include!(concat!(env!("OUT_DIR"), "/flatbuffers/scalar.rs")); }