-
Notifications
You must be signed in to change notification settings - Fork 846
Open
Description
Bug Report
Version
tracing-attributes v0.1.27 (proc-macro)
tracing-core v0.1.32
tracing-log v0.2.0
tracing-subscriber v0.3.18
tracing v0.1.40
Platform
Arch Linux, kernel 6.8.5-arch1-1
Crates
tracing-attributes
Description
The documentation claims that:
Note: if the function returns a
Result<T, E>,retwill record returned values if and only if the function returnsResult::Ok.
This is however only the case when the #[instrument] macro is also given the err parameter; otherwise, the return value is printed unconditionally (whether it is Ok or Err). This can also be seen in the implementation, which has a match block when err is specified, but does not have a match block when only ret is specified.
I've been trying to do some code archaeology to find out why it was implemented and documented this way in #1716, but I've come up empty.
Reproducer:
use tracing::instrument;
fn main() {
tracing_subscriber::fmt().init();
let _ = make_error();
}
#[instrument(ret)]
fn make_error() -> Result<(), &'static str> {
Err("error!")
}$ cargo run --quiet
2024-05-05T21:59:22.720067Z INFO make_error: repro: return=Err("error!")
sirewix
Metadata
Metadata
Assignees
Labels
No labels