Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakuyume committed Jan 10, 2024
1 parent 07b4900 commit 123c818
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tracing-attributes/tests/instrument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,40 @@ fn repro_2294() {
let i = 42;
}

// Reproduces a compile error when an instrumented function signature contains lifetimes
// (https://github.com/tokio-rs/tracing/issues/2796).
#[derive(Debug)]
struct Repro2796(u8);
impl Repro2796 {
#[instrument(err)]
fn err(x: &mut u8) -> Result<&u8, &u8> {
Ok(&*x)
}
#[instrument(ret)]
fn ret(x: &mut u8) -> Result<&u8, &u8> {
Ok(&*x)
}
#[instrument(err, ret)]
fn err_ret(x: &mut u8) -> Result<&u8, &u8> {
Ok(&*x)
}

#[instrument(err, ret)]
fn receiver(&mut self) -> Result<&u8, &u8> {
Ok(&self.0)
}

#[instrument(err, ret)]
fn multiple<'a, 'b, 'c, 'd>(
x: &'a mut u8,
(y, _): (&'b mut u8, u8),
Repro2796(z, ..): &'c mut Repro2796,
_: &'d mut u8,
) -> Result<&'a u8, &'b u8> {
Ok(&*x)
}
}

#[test]
fn override_everything() {
#[instrument(target = "my_target", level = "debug")]
Expand Down

0 comments on commit 123c818

Please sign in to comment.