From e9b33789133033b66df5e9e94b2fbc8ab93d340f Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 23 Nov 2020 12:40:55 -0600 Subject: [PATCH] fix: Be friendlier with panics --- Cargo.lock | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 7 +++++ src/main.rs | 1 + 3 files changed, 99 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index f9b4930..63b6890 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,20 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "addr2line" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c0929d69e78dd9bf5408269919fcbcaeb2e35e5d43e5815517cdc6a8e11a423" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" + [[package]] name = "ahash" version = "0.5.7" @@ -71,6 +86,20 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +[[package]] +name = "backtrace" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef5140344c85b01f9bbb4d4b7288a8aa4b3287ccef913a14bcc78a1063623598" +dependencies = [ + "addr2line", + "cfg-if 1.0.0", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "bitflags" version = "1.2.1" @@ -417,6 +446,12 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" + [[package]] name = "globset" version = "0.4.6" @@ -458,6 +493,21 @@ dependencies = [ "libc", ] +[[package]] +name = "human-panic" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39f357a500abcbd7c5f967c1d45c8838585b36743823b9d43488f24850534e36" +dependencies = [ + "backtrace", + "os_type", + "serde", + "serde_derive", + "termcolor", + "toml", + "uuid", +] + [[package]] name = "humantime" version = "1.3.0" @@ -552,6 +602,16 @@ version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +[[package]] +name = "miniz_oxide" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" +dependencies = [ + "adler", + "autocfg", +] + [[package]] name = "misspell-codegen" version = "0.1.2" @@ -601,12 +661,27 @@ dependencies = [ "autocfg", ] +[[package]] +name = "object" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397" + [[package]] name = "once_cell" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" +[[package]] +name = "os_type" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edc011af0ae98b7f88cf7e4a83b70a54a75d2b8cb013d6efd02e5956207e9eb" +dependencies = [ + "regex", +] + [[package]] name = "phf" version = "0.8.0" @@ -852,6 +927,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "rustc-demangle" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" + [[package]] name = "rustc_version" version = "0.2.3" @@ -1105,6 +1186,7 @@ dependencies = [ "clap-verbosity-flag", "difflib", "env_logger 0.8.2", + "human-panic", "ignore", "log", "phf", @@ -1215,6 +1297,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +[[package]] +name = "uuid" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" +dependencies = [ + "rand", +] + [[package]] name = "varcon" version = "0.2.1" diff --git a/Cargo.toml b/Cargo.toml index be3067e..2f240df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,7 +49,14 @@ bstr = "0.2" ahash = "0.5.7" difflib = "0.4" proc-exit = "0.3" +human-panic = "1.0.3" [dev-dependencies] assert_fs = "1.0" predicates = "1.0" + +[profile.dev] +panic = "abort" + +[profile.release] +panic = "abort" diff --git a/src/main.rs b/src/main.rs index 11a616d..80d0b99 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,7 @@ mod replace; use proc_exit::WithCodeResultExt; fn main() { + human_panic::setup_panic!(); let result = run(); proc_exit::exit(result); }