Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Fix tests and warnings from new compiler versions #140

Merged
merged 5 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/multiple_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ fn join_errors(results: Vec<Result<(), SourceError>>) -> 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
Expand Down
19 changes: 9 additions & 10 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -1038,6 +1037,13 @@ pub struct EyreHook {
issue_filter: Arc<IssueFilterCallback>,
}

type HookFunc = Box<
dyn Fn(&(dyn std::error::Error + 'static)) -> Box<dyn eyre::EyreHandler>
+ Send
+ Sync
+ 'static,
>;

impl EyreHook {
#[allow(unused_variables)]
pub(crate) fn default(&self, error: &(dyn std::error::Error + 'static)) -> crate::Handler {
Expand Down Expand Up @@ -1091,14 +1097,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<dyn eyre::EyreHandler>
+ Send
+ Sync
+ 'static,
> {
pub fn into_eyre_hook(self) -> HookFunc {
Box::new(move |e| Box::new(self.default(e)))
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,22 +336,19 @@
//! [`examples/multiple_errors.rs`]: https://github.com/yaahc/color-eyre/blob/master/examples/multiple_errors.rs
#![doc(html_root_url = "https://docs.rs/color-eyre/0.6.2")]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(

Check warning on line 339 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Features (--no-default-features --features track-caller)

unknown lint: `rustdoc::missing_doc_code_examples`

Check warning on line 339 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Features (--no-default-features --features capture-spantrace)

unknown lint: `rustdoc::missing_doc_code_examples`

Check warning on line 339 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Features (--all-features)

unknown lint: `rustdoc::missing_doc_code_examples`

Check warning on line 339 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Versions (x86_64-unknown-linux-gnu, nightly)

unknown lint: `rustdoc::missing_doc_code_examples`

Check warning on line 339 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Features (--no-default-features)

unknown lint: `rustdoc::missing_doc_code_examples`

Check warning on line 339 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Features

unknown lint: `rustdoc::missing_doc_code_examples`

Check warning on line 339 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Operating Systems (macOS-latest)

unknown lint: `rustdoc::missing_doc_code_examples`

Check warning on line 339 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Features (--no-default-features --features issue-url)

unknown lint: `rustdoc::missing_doc_code_examples`

Check warning on line 339 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Operating Systems (ubuntu-latest)

unknown lint: `rustdoc::missing_doc_code_examples`

Check warning on line 339 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Versions (x86_64-unknown-linux-gnu, stable)

unknown lint: `rustdoc::missing_doc_code_examples`

Check warning on line 339 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Versions (x86_64-unknown-linux-gnu, beta)

unknown lint: `rustdoc::missing_doc_code_examples`

Check warning on line 339 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Test Operating Systems (windows-latest)

unknown lint: `rustdoc::missing_doc_code_examples`
missing_docs,
rustdoc::missing_doc_code_examples,
rust_2018_idioms,
unreachable_pub,
bad_style,
const_err,
dead_code,
improper_ctypes,
non_shorthand_field_patterns,
no_mangle_generic_items,
overflowing_literals,
path_statements,
patterns_in_fns_without_body,
private_in_public,
unconditional_recursion,
unused,
unused_allocation,
unused_comparisons,
Expand Down
8 changes: 6 additions & 2 deletions tests/data/theme_error_control.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Run with RUST_BACKTRACE=full to include source snippets.
8 changes: 6 additions & 2 deletions tests/data/theme_error_control_location.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Run with RUST_BACKTRACE=full to include source snippets.
8 changes: 6 additions & 2 deletions tests/data/theme_error_control_minimal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Run with RUST_BACKTRACE=full to include source snippets.
8 changes: 6 additions & 2 deletions tests/data/theme_error_control_spantrace.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Run with RUST_BACKTRACE=full to include source snippets.
20 changes: 11 additions & 9 deletions tests/data/theme_panic_control_no_spantrace.txt
Original file line number Diff line number Diff line change
@@ -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: <non string panic payload>
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.
4 changes: 2 additions & 2 deletions tests/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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):

Expand Down
Loading