-
Notifications
You must be signed in to change notification settings - Fork 734
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attributes: fix #[instrument(err)] with mutable parameters (#1167)
## Motivation The closure generated by `#[instrument(err)]` for non-async functions is not mutable, preventing any captured variables from being mutated. If a function has any mutable parameters that are modified within the function, adding the `#[instrument(err)]` attribute will result in a compiler error. ## Solution This change makes it so the closure is executed directly as a temporary variable instead of storing it in a named variable prior to its use, avoiding the need to explicitly declare it as mutable altogether or to add an `#[allow(unused_mut)]` annotation on the closure declaration to silence lint warnings for closures that do not need to be mutable.
- Loading branch information
Showing
2 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters