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: suppress clippy::suspicious_else without nop let #1614

Merged
merged 1 commit into from
Oct 4, 2021

Commits on Oct 4, 2021

  1. attributes: suppress clippy::suspicious_else without nop let

    Currently, `tracing-attributes` generates a `let _ = ();` in between the
    `if tracing::level_enabled!(...) {}` and the function body. This is
    intended to suppress the `clippy::suspicious_else_formatting` lint,
    which is generated when an `if` is followed immediately by a block with
    no whitespace in between. Since we can't add whitespace in the generated
    code (as `quote` produces a stream of _rust tokens_, not text), we
    can't suppress the lint without adding a no-op statement.
    
    However, unfortunately, the no-op let triggers a _different_ lint
    (`clippy::let_unit_value`), when `clippy::pedantic` is enabled. This is
    kind of annoying for some users.
    
    This branch changes the code to suppress the
    `suspicious_else_formatting` lint using `#[allow(...)]` attributes,
    instead. The warning is turned back on inside of user code, since users
    probably want the warning.
    hawkw committed Oct 4, 2021
    Configuration menu
    Copy the full SHA
    aecf7f4 View commit details
    Browse the repository at this point in the history