Skip to content

Lint against format_implicit_args #5404

Open

Description

@dylni

Would you consider a lint to warn for uses of the "format_implicit_args" feature now that rust-lang/rfcs#2795 has been merged?

As far as I'm aware, it's the only way the standard library provides for a string to be interpreted as a variable. It can be done using procedural macros, but that would require adding a crate as a dependency. So, I would prefer a lint against this, because I believe it to be an anti-pattern.

Activity

  1. flip1995 commented on Apr 2, 2020

    @flip1995
    Member

    You mean a lint, that fires on every use of implicit args?

  2. dylni commented on Apr 2, 2020

    @dylni
    Author

    Yes. If clippy stops after the first usage, that would work too, but I haven't found that to be how lints typically behave.

  3. flip1995 commented on Apr 2, 2020

    @flip1995
    Member

    This would be linting on a whole feature, that got accepted through an RFC, which Clippy normally doesn't do.

    But Clippy has the restriction lint group, where such a lint would be possible, but then has to be enabled explicitly. This lint would first require this feature to be implemented in rustc though.

  4. added
    A-lintArea: New lints
    S-blockedStatus: marked as blocked ❌ on something else such as an RFC or other implementation work
    T-macrosType: Issues with macros and macro expansion
    on Apr 2, 2020
  5. dylni commented on Apr 2, 2020

    @dylni
    Author

    The restriction group definitely makes the most sense.

    I figured it would need to be implemented in rustc first, but I wanted to create the issue now to see if this would even be considered with the RFC being accepted. There was some opposition on the RFC though, which also showed in the voting, so I think this could be generally useful.

  6. added
    L-restrictionLint: Belongs in the restriction lint group
    E-mediumCall for participation: Medium difficulty level problem and requires some initial experience.
    and removed
    S-blockedStatus: marked as blocked ❌ on something else such as an RFC or other implementation work
    on Feb 7, 2021
  7. MightyPork commented on Apr 29, 2022

    @MightyPork

    I would actually be interested in the opposite lint of the proposal here, a lint warning about the old syntax in format macros. It could even have automatic fix available.

  8. dylni commented on May 9, 2022

    @dylni
    Author

    This could be similar to implicit_return and needless_return, which both exist for both styles.

    Also, this issue can now be unblocked.

    @rustbot labels: -S-blocked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.L-restrictionLint: Belongs in the restriction lint groupT-macrosType: Issues with macros and macro expansion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions