Skip to content

replace panicking unwrap with explicit panic in build.rs#724

Open
anaslimem wants to merge 1 commit intounum-cloud:mainfrom
anaslimem:fix-rust-build-panic
Open

replace panicking unwrap with explicit panic in build.rs#724
anaslimem wants to merge 1 commit intounum-cloud:mainfrom
anaslimem:fix-rust-build-panic

Conversation

@anaslimem
Copy link

What does this PR do?

Resolves a clippy::panicking_unwrap lint error in the Rust build.rs script.

Previously, if compiling the usearch C++ backend failed ( due to missing system headers like <omp.h> on macOS), the build script would unconditionally call .unwrap() on the resulting Err. This caused a generic panic that obscured the actual underlying compiler error and triggered a clippy warning.

Why is this necessary?

Unwrapping an Err value is discouraged by cargo clippy because it leads to unhelpful error messages:

error: this call to `unwrap()` will always panic
   --> build.rs:113:17
    |
...
113 |                 result.unwrap();
    |                 ^^^^^^^^^^^^^^^

This PR replaces the .unwrap() with an explicit panic! that surfaces the exact cxx ToolExecError message. This makes debugging C++ dependency issues during cargo build significantly easier for developers and users.

Testing

Verified locally that:

  • cargo clippy --all-targets --all-features passes with zero errors/warnings.
  • cargo test -p usearch succeeds with all 14 tests passing.
  • Building the crate on a system missing libomp now cleanly displays the fatal error: 'omp.h' file not found message instead of a generic unwrap tracing panic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant