diff --git a/Cargo.toml b/Cargo.toml index 76c8577f1c6a..b543d56845f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,7 +89,8 @@ wgpu-hal = { version = "0.15.4", default-features = false } [profile.dev] -opt-level = 1 # Make debug builds run faster +opt-level = 1 # Make debug builds run faster +panic = "abort" # This leads to better optimizations and smaller binaries (and is the default in Wasm anyways). # Optimize all dependencies even in debug builds (does not affect workspace packages): [profile.dev.package."*"] @@ -97,6 +98,7 @@ opt-level = 2 [profile.release] # debug = true # good for profilers +panic = "abort" # This leads to better optimizations and smaller binaries (and is the default in Wasm anyways). [profile.bench] debug = true diff --git a/clippy.toml b/clippy.toml index c72661614556..4da41d009fbc 100644 --- a/clippy.toml +++ b/clippy.toml @@ -27,6 +27,8 @@ disallowed-methods = [ "std::thread::spawn", # Use `std::thread::Builder` and name the thread "sha1::Digest::new", # SHA1 is cryptographically broken + + "std::panic::catch_unwind", # We compile with `panic = "abort"` ] # https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_names diff --git a/crates/rerun/src/crash_handler.rs b/crates/rerun/src/crash_handler.rs index e73ffd62b006..b0650b3e72cb 100644 --- a/crates/rerun/src/crash_handler.rs +++ b/crates/rerun/src/crash_handler.rs @@ -30,8 +30,6 @@ fn install_panic_hook(_build_info: BuildInfo) { format!("{file}:{}", location.line()) }); - // `panic_info.message` is unstable, so this is the recommended way of getting - // the panic message out. We need both the `&str` and `String` variants. let msg = panic_info_message(panic_info); if let Some(msg) = &msg { @@ -90,10 +88,17 @@ fn install_panic_hook(_build_info: BuildInfo) { std::thread::sleep(std::time::Duration::from_secs(1)); // Give analytics time to send the event } } + + // We compile with `panic = "abort"`, but we don't want to report the same problem twice, so just exit: + #[allow(clippy::exit)] + std::process::exit(102); })); } fn panic_info_message(panic_info: &std::panic::PanicInfo<'_>) -> Option { + // `panic_info.message` is unstable, so this is the recommended way of getting + // the panic message out. We need both the `&str` and `String` variants. + #[allow(clippy::manual_map)] if let Some(msg) = panic_info.payload().downcast_ref::<&str>() { Some((*msg).to_owned())