From 8522f02518330d4a0178a0e940c4a910bb9299e0 Mon Sep 17 00:00:00 2001 From: LeoniePhiline <22329650+LeoniePhiline@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:35:20 +0100 Subject: [PATCH] chore: clarify trait usage in location test Both `WrapErr` and `ContextCompat` expose `anyhow` compatibility methods. `ContextCompat` is completely feature gated behind the `anyhow` flag. `WrapErr`, on the other hand, feature-gates individual functions behind the `anyhow` flag. This has led to [confusion][confusion] in the past. [confusion]: https://github.com/eyre-rs/eyre/pull/138#discussion_r1432909562 --- eyre/tests/test_location.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eyre/tests/test_location.rs b/eyre/tests/test_location.rs index 53c181f..063c644 100644 --- a/eyre/tests/test_location.rs +++ b/eyre/tests/test_location.rs @@ -1,7 +1,5 @@ use std::panic::Location; -use eyre::WrapErr; - struct LocationHandler { actual: Option<&'static str>, expected: &'static str, @@ -46,6 +44,7 @@ fn test_wrap_err() { Box::new(LocationHandler::new(expected_location)) })); + use eyre::WrapErr; let err = read_path("totally_fake_path") .wrap_err("oopsie") .unwrap_err(); @@ -75,6 +74,7 @@ fn test_wrap_err_with() { Box::new(LocationHandler::new(expected_location)) })); + use eyre::WrapErr; let err = read_path("totally_fake_path") .wrap_err_with(|| "oopsie") .unwrap_err(); @@ -106,6 +106,7 @@ fn test_context() { Box::new(LocationHandler::new(expected_location)) })); + use eyre::WrapErr; let err = read_path("totally_fake_path") .context("oopsie") .unwrap_err(); @@ -122,6 +123,7 @@ fn test_with_context() { Box::new(LocationHandler::new(expected_location)) })); + use eyre::WrapErr; let err = read_path("totally_fake_path") .with_context(|| "oopsie") .unwrap_err();