tokio-rs / tracing

Application level tracing for Rust.
https://tracing.rs
MIT License
5.19k stars 677 forks source link

attributes: force instrumented function to be `FnOnce` #2892

Closed mladedav closed 4 months ago

mladedav commented 5 months ago

Closes #2857

Motivation

Functions which are Fn or FnMut fail to compile when they are instrumented with #[instrument(ret)]

Solution

I've added a non-copy zst ([&mut (), 0]) to the generated code that is moved inside the function so that it is forced to be no more than FnOnce.

mladedav commented 4 months ago

I've created #2897 to be merged into master and then backported to v0.1.x since that's the workflow here.