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` #2897

Closed mladedav closed 4 months ago

mladedav commented 4 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.

Hakuyume commented 4 months ago

Seems similar to #2847 ?

mladedav commented 4 months ago

You're right, I'll close it in favor of your PR.