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: fix #[instrument(err)] with mutable parameters #1167

Merged
merged 6 commits into from
Feb 4, 2021

Commits on Dec 31, 2020

  1. attributes: fix #[instrument(err)] with mutable parameters

    ## 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.
    okready committed Dec 31, 2020
    Configuration menu
    Copy the full SHA
    0e52374 View commit details
    Browse the repository at this point in the history

Commits on Feb 2, 2021

  1. Configuration menu
    Copy the full SHA
    87fecc2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8cb2eb2 View commit details
    Browse the repository at this point in the history

Commits on Feb 3, 2021

  1. make clippy happy

    hawkw authored Feb 3, 2021
    Configuration menu
    Copy the full SHA
    d4e90b3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a0b1c79 View commit details
    Browse the repository at this point in the history

Commits on Feb 4, 2021

  1. Fix clippy::unit_arg in #[instrument(err)] result matching

    The clippy::unit_arg warning is triggered for the Ok branch in the match
    statements generated for the #[instrument(err)] attribute against the
    function result if that function returns a unit Ok value. This commit
    disables the unit_arg lint check for the Ok match arms and cleans up
    other attempts to isolate the lint error.
    okready committed Feb 4, 2021
    Configuration menu
    Copy the full SHA
    72b8d0a View commit details
    Browse the repository at this point in the history