-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add better error message when using
async-trait
- Loading branch information
1 parent
951a41f
commit c757155
Showing
4 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
autometrics/tests/result_labels/fail/async_trait_support.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use async_trait::async_trait; | ||
use autometrics::autometrics; | ||
|
||
// https://github.com/autometrics-dev/autometrics-rs/issues/141 | ||
|
||
#[async_trait] | ||
trait TestTrait { | ||
async fn method() -> bool; | ||
async fn self_method(&self) -> bool; | ||
} | ||
|
||
#[derive(Default)] | ||
struct TestStruct; | ||
|
||
#[autometrics] | ||
#[async_trait] | ||
impl TestTrait for TestStruct { | ||
async fn method() -> bool { | ||
true | ||
} | ||
|
||
async fn self_method(&self) -> bool { | ||
true | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_async_trait() { | ||
let ts = TestStruct::default(); | ||
|
||
async move { | ||
<TestStruct as TestTrait>::method().await; | ||
ts.self_method().await; | ||
}; | ||
} |
7 changes: 7 additions & 0 deletions
7
autometrics/tests/result_labels/fail/async_trait_support.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
error: #[async_trait] must be defined BEFORE #[autometrics] | ||
--> tests/result_labels/fail/async_trait_support.rs:15:1 | ||
| | ||
15 | #[autometrics] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in the attribute macro `autometrics` (in Nightly builds, run with -Z macro-backtrace for more info) |