-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add #[tracing::instrument] compatibility for #[automock]
The mock method won't be instrumented, but at least it will compile. Fixes #253
- Loading branch information
Showing
4 changed files
with
45 additions
and
11 deletions.
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
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,22 @@ | ||
// vim: tw=80 | ||
//! A trait that uses tracing::instrument should be automockable. The mock | ||
//! method won't be instrumented, though. | ||
#![deny(warnings)] | ||
|
||
use mockall::*; | ||
use tracing::instrument; | ||
|
||
#[derive(Debug)] | ||
pub struct Foo {} | ||
|
||
#[automock] | ||
impl Foo { | ||
#[instrument] | ||
fn foo(&self) {} | ||
#[instrument] | ||
fn bar() {} | ||
#[tracing::instrument] | ||
fn fooz(&self) {} | ||
#[tracing::instrument] | ||
fn barz() {} | ||
} |
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