From a504a6096830bef88836b2dbb334a11373c69b7f Mon Sep 17 00:00:00 2001 From: Tei Roberts Date: Tue, 7 Nov 2023 23:43:05 +0100 Subject: [PATCH 1/5] fix: warnings for newer rust versions --- examples/multiple_errors.rs | 8 +++++--- src/config.rs | 16 ++++++++-------- src/lib.rs | 3 --- tests/theme.rs | 5 +++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/examples/multiple_errors.rs b/examples/multiple_errors.rs index e06c0fc..f1e65a9 100644 --- a/examples/multiple_errors.rs +++ b/examples/multiple_errors.rs @@ -12,13 +12,15 @@ fn join_errors(results: Vec>) -> Result<(), Report> { return Ok(()); } - results + let err = results .into_iter() .filter(Result::is_err) .map(Result::unwrap_err) - .fold(Err(eyre!("encountered multiple errors")), |report, e| { + .fold(eyre!("encountered multiple errors"), |report, e| { report.error(e) - }) + }); + + Err(err) } /// Helper function to generate errors diff --git a/src/config.rs b/src/config.rs index f2c38f9..ea26597 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1038,6 +1038,13 @@ pub struct EyreHook { issue_filter: Arc, } +type HookFunc = Box< + dyn Fn(&(dyn std::error::Error + 'static)) -> Box + + Send + + Sync + + 'static, +>; + impl EyreHook { #[allow(unused_variables)] pub(crate) fn default(&self, error: &(dyn std::error::Error + 'static)) -> crate::Handler { @@ -1091,14 +1098,7 @@ impl EyreHook { } /// Convert the self into the boxed type expected by `eyre::set_hook`. - pub fn into_eyre_hook( - self, - ) -> Box< - dyn Fn(&(dyn std::error::Error + 'static)) -> Box - + Send - + Sync - + 'static, - > { + pub fn into_eyre_hook(self) -> HookFunc { Box::new(move |e| Box::new(self.default(e))) } } diff --git a/src/lib.rs b/src/lib.rs index 51cb504..2664cad 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -342,7 +342,6 @@ rust_2018_idioms, unreachable_pub, bad_style, - const_err, dead_code, improper_ctypes, non_shorthand_field_patterns, @@ -350,8 +349,6 @@ overflowing_literals, path_statements, patterns_in_fns_without_body, - private_in_public, - unconditional_recursion, unused, unused_allocation, unused_comparisons, diff --git a/tests/theme.rs b/tests/theme.rs index 5894385..3b9ad98 100644 --- a/tests/theme.rs +++ b/tests/theme.rs @@ -118,7 +118,7 @@ fn test_panic_backwards_compatibility() { }; let output = std::process::Command::new("cargo") - .args(&["run", "--example", "theme_test_helper"]) + .args(["run", "--example", "theme_test_helper"]) .arg("--no-default-features") .args(&features) .output() @@ -151,7 +151,6 @@ fn test_backwards_compatibility(target: String, file_name: &str) { let all: Vec<_> = s.ansi_parse().collect(); let ansi: Vec<_> = s .ansi_parse() - .into_iter() .filter_map(|x| { if let Output::Escape(ansi) = x { Some(ansi) @@ -166,6 +165,7 @@ fn test_backwards_compatibility(target: String, file_name: &str) { let (_control_tokens, control_ansi) = f(&control); let (_target_tokens, target_ansi) = f(&target); + // pretty_assertions::assert_eq!(target, control); let msg = [ // comment out / un-comment what you need or don't need for debugging (see below for more instructions): @@ -188,6 +188,7 @@ fn test_backwards_compatibility(target: String, file_name: &str) { ].join("\n\n"); + pretty_assertions::assert_eq!(target_ansi, control_ansi, "{msg}"); assert_eq!(target_ansi, control_ansi, "{}", &msg); /* From eedde5137f6b1b4e64904bbe7d254c8b02d71058 Mon Sep 17 00:00:00 2001 From: Tei Roberts Date: Tue, 7 Nov 2023 23:43:52 +0100 Subject: [PATCH 2/5] fix: test_error_backwards_compatability --- tests/data/theme_error_control.txt | 8 ++++++-- tests/theme.rs | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/data/theme_error_control.txt b/tests/data/theme_error_control.txt index ec3c1f0..573fb79 100644 --- a/tests/data/theme_error_control.txt +++ b/tests/data/theme_error_control.txt @@ -44,11 +44,15 @@ Error: at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panic.rs:133 20: test::run_test_in_process::h15b6b7d5919893aa at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/test/src/lib.rs:608 -  ⋮ 15 frames hidden ⋮  + 21: test::run_test::{{closure}}::h8ef02d13d4506b7f + at /rustc/7b4d9e155fec06583c763f176fc432dc779f1fc6/library/test/src/lib.rs:572 + 22: test::run_test::{{closure}}::hcd7b423365d0ff7e + at /rustc/7b4d9e155fec06583c763f176fc432dc779f1fc6/library/test/src/lib.rs:600 +  ⋮ 13 frames hidden ⋮  Note: note Warning: warning Suggestion: suggestion Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering. -Run with RUST_BACKTRACE=full to include source snippets. \ No newline at end of file +Run with RUST_BACKTRACE=full to include source snippets. diff --git a/tests/theme.rs b/tests/theme.rs index 3b9ad98..278f364 100644 --- a/tests/theme.rs +++ b/tests/theme.rs @@ -188,7 +188,6 @@ fn test_backwards_compatibility(target: String, file_name: &str) { ].join("\n\n"); - pretty_assertions::assert_eq!(target_ansi, control_ansi, "{msg}"); assert_eq!(target_ansi, control_ansi, "{}", &msg); /* From 2629d614a8d3a79be79cd49e80564fa3300f1daf Mon Sep 17 00:00:00 2001 From: Tei Roberts Date: Wed, 8 Nov 2023 00:29:49 +0100 Subject: [PATCH 3/5] fix: no-default-features test --- src/config.rs | 3 +-- tests/data/theme_error_control_minimal.txt | 8 ++++++-- .../data/theme_panic_control_no_spantrace.txt | 20 ++++++++++--------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/config.rs b/src/config.rs index ea26597..01a5c74 100644 --- a/src/config.rs +++ b/src/config.rs @@ -4,7 +4,6 @@ use crate::{ section::PanicMessage, writers::{EnvSection, WriterExt}, }; -use eyre::WrapErr; use fmt::Display; use indenter::{indented, Format}; use owo_colors::{style, OwoColorize, Style}; @@ -760,7 +759,7 @@ impl HookBuilder { }; #[cfg(feature = "capture-spantrace")] - color_spantrace::set_theme(self.theme.into()).wrap_err("could not set the provided `Theme` via `color_spantrace::set_theme` globally as another was already set")?; + eyre::WrapErr::wrap_err(color_spantrace::set_theme(self.theme.into()), "could not set the provided `Theme` via `color_spantrace::set_theme` globally as another was already set")?; Ok((panic_hook, eyre_hook)) } diff --git a/tests/data/theme_error_control_minimal.txt b/tests/data/theme_error_control_minimal.txt index 0df50fb..684d048 100644 --- a/tests/data/theme_error_control_minimal.txt +++ b/tests/data/theme_error_control_minimal.txt @@ -36,11 +36,15 @@ Error: at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panic.rs:133 20: test::run_test_in_process::h15b6b7d5919893aa at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/test/src/lib.rs:608 -  ⋮ 15 frames hidden ⋮  + 21: test::run_test::{{closure}}::h8ef02d13d4506b7f + at /rustc/7b4d9e155fec06583c763f176fc432dc779f1fc6/library/test/src/lib.rs:572 + 22: test::run_test::{{closure}}::hcd7b423365d0ff7e + at /rustc/7b4d9e155fec06583c763f176fc432dc779f1fc6/library/test/src/lib.rs:600 +  ⋮ 13 frames hidden ⋮  Note: note Warning: warning Suggestion: suggestion Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering. -Run with RUST_BACKTRACE=full to include source snippets. \ No newline at end of file +Run with RUST_BACKTRACE=full to include source snippets. diff --git a/tests/data/theme_panic_control_no_spantrace.txt b/tests/data/theme_panic_control_no_spantrace.txt index bac190d..95aa739 100644 --- a/tests/data/theme_panic_control_no_spantrace.txt +++ b/tests/data/theme_panic_control_no_spantrace.txt @@ -1,18 +1,20 @@ - Finished dev [unoptimized + debuginfo] target(s) in 0.02s + Finished dev [unoptimized + debuginfo] target(s) in 0.03s +warning: the following packages contain code that will be rejected by a future version of Rust: nom v4.2.3 +note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1` Running `target/debug/examples/theme_test_helper` The application panicked (crashed). Message:  Location: examples/theme_test_helper.rs:37 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -  ⋮ 6 frames hidden ⋮  - 7: std::panic::panic_any::hb5351c0843c6c4aa - at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panic.rs:57 - 8: theme_test_helper::main::h22b568e997946766 - at /home/jlusby/git/yaahc/color-eyre/examples/theme_test_helper.rs:37 - 9: core::ops::function::FnOnce::call_once::hab7662216a7cf3dc - at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ops/function.rs:227 -  ⋮ 15 frames hidden ⋮  +  ⋮ 7 frames hidden ⋮  + 8: std::panic::panic_any::h696507828cece708 + at /rustc/7b4d9e155fec06583c763f176fc432dc779f1fc6/library/std/src/panic.rs:63 + 9: theme_test_helper::main::h8b0946db6f62a6fa + at /home/tei/dev/rust/color-eyre/examples/theme_test_helper.rs:37 + 10: core::ops::function::FnOnce::call_once::h6e047342a35216be + at /rustc/7b4d9e155fec06583c763f176fc432dc779f1fc6/library/core/src/ops/function.rs:250 +  ⋮ 16 frames hidden ⋮  Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering. Run with RUST_BACKTRACE=full to include source snippets. From 7fadb08f08ba7599daa6ac5e4b8dc0d209aaca1d Mon Sep 17 00:00:00 2001 From: Tei Roberts Date: Wed, 8 Nov 2023 00:32:34 +0100 Subject: [PATCH 4/5] fix: track caller test --- tests/data/theme_error_control_location.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/data/theme_error_control_location.txt b/tests/data/theme_error_control_location.txt index 099cd2e..19fecfa 100644 --- a/tests/data/theme_error_control_location.txt +++ b/tests/data/theme_error_control_location.txt @@ -39,11 +39,15 @@ Error: at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panic.rs:133 20: test::run_test_in_process::h15b6b7d5919893aa at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/test/src/lib.rs:608 -  ⋮ 15 frames hidden ⋮  + 21: test::run_test::{{closure}}::h8ef02d13d4506b7f + at /rustc/7b4d9e155fec06583c763f176fc432dc779f1fc6/library/test/src/lib.rs:572 + 22: test::run_test::{{closure}}::hcd7b423365d0ff7e + at /rustc/7b4d9e155fec06583c763f176fc432dc779f1fc6/library/test/src/lib.rs:600 +  ⋮ 13 frames hidden ⋮  Note: note Warning: warning Suggestion: suggestion Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering. -Run with RUST_BACKTRACE=full to include source snippets. \ No newline at end of file +Run with RUST_BACKTRACE=full to include source snippets. From b4a26d7670bfcc1444371b265b4465e80d1c9ef5 Mon Sep 17 00:00:00 2001 From: Tei Roberts Date: Wed, 8 Nov 2023 00:35:32 +0100 Subject: [PATCH 5/5] fix: spantrace test --- tests/data/theme_error_control_spantrace.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/data/theme_error_control_spantrace.txt b/tests/data/theme_error_control_spantrace.txt index 723e994..70635cc 100644 --- a/tests/data/theme_error_control_spantrace.txt +++ b/tests/data/theme_error_control_spantrace.txt @@ -41,11 +41,15 @@ Error: at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panic.rs:133 20: test::run_test_in_process::h15b6b7d5919893aa at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/test/src/lib.rs:608 -  ⋮ 15 frames hidden ⋮  + 21: test::run_test::{{closure}}::h8ef02d13d4506b7f + at /rustc/7b4d9e155fec06583c763f176fc432dc779f1fc6/library/test/src/lib.rs:572 + 22: test::run_test::{{closure}}::hcd7b423365d0ff7e + at /rustc/7b4d9e155fec06583c763f176fc432dc779f1fc6/library/test/src/lib.rs:600 +  ⋮ 13 frames hidden ⋮  Note: note Warning: warning Suggestion: suggestion Run with COLORBT_SHOW_HIDDEN=1 environment variable to disable frame filtering. -Run with RUST_BACKTRACE=full to include source snippets. \ No newline at end of file +Run with RUST_BACKTRACE=full to include source snippets.