Skip to content

Commit 8522f02

Browse files
committed
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]: #138 (comment)
1 parent 34bd1d9 commit 8522f02

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

eyre/tests/test_location.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use std::panic::Location;
22

3-
use eyre::WrapErr;
4-
53
struct LocationHandler {
64
actual: Option<&'static str>,
75
expected: &'static str,
@@ -46,6 +44,7 @@ fn test_wrap_err() {
4644
Box::new(LocationHandler::new(expected_location))
4745
}));
4846

47+
use eyre::WrapErr;
4948
let err = read_path("totally_fake_path")
5049
.wrap_err("oopsie")
5150
.unwrap_err();
@@ -75,6 +74,7 @@ fn test_wrap_err_with() {
7574
Box::new(LocationHandler::new(expected_location))
7675
}));
7776

77+
use eyre::WrapErr;
7878
let err = read_path("totally_fake_path")
7979
.wrap_err_with(|| "oopsie")
8080
.unwrap_err();
@@ -106,6 +106,7 @@ fn test_context() {
106106
Box::new(LocationHandler::new(expected_location))
107107
}));
108108

109+
use eyre::WrapErr;
109110
let err = read_path("totally_fake_path")
110111
.context("oopsie")
111112
.unwrap_err();
@@ -122,6 +123,7 @@ fn test_with_context() {
122123
Box::new(LocationHandler::new(expected_location))
123124
}));
124125

126+
use eyre::WrapErr;
125127
let err = read_path("totally_fake_path")
126128
.with_context(|| "oopsie")
127129
.unwrap_err();

0 commit comments

Comments
 (0)