Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attributes: force instrumented function to be FnOnce #2897

Closed

Conversation

mladedav
Copy link
Contributor

@mladedav mladedav commented Mar 1, 2024

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 mladedav force-pushed the dm/instrument-fn-mut-master branch from 92b7168 to 442f558 Compare March 1, 2024 23:26
@Hakuyume
Copy link

Hakuyume commented Mar 6, 2024

Seems similar to #2847 ?

@mladedav
Copy link
Contributor Author

mladedav commented Mar 6, 2024

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

@mladedav mladedav closed this Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tracing::instrument(ret) errors on function with &mut args returning &/&mut
2 participants