Skip to content

Rename allow-mixed-uninlined-format-args #17747

Description

@smoelius

Description

I humbly suggest that allow-mixed-uninlined-format-args (i.e, the configuration affecting uninlined_format_args) be renamed.

Recall, changing this configuration from true (its default) to false causes Clippy to flag the following code:

format!("{} {}", var, 1+2); // Clippy suggests: format!("{var} {}", 1+2);

I personally find the configuration name confusing and difficult to read. Also, it recently confused Codex. 😬

Transcript

So you think the configuration name is confusing?

Yes. I initially read:

allow-mixed-uninlined-format-args = false

as “mixed positional and captured arguments are forbidden.”

Its actual meaning is closer to: “do not exempt an uninlined variable merely because the same format call also contains an expression that cannot be inlined.”

Thus Clippy accepts—and may produce—the mixed result:

panic!("Could not parse config as `{}`: {error}", type_name::<T>())

Here, error is inlined, while the non-capturable expression remains positional. The configuration name describes when the lint tolerates uninlined arguments, not whether mixed formatting syntax itself is allowed, which makes it easy to misread.

Adding to the above, the fact that the default is true feels odd to me. A default of false feels more natural. Currently, there are 26 configurations that default to false, but only 14 that default to true, which I think supports this view.

Personally, I suggest the configuration be renamed to lint-inlinable-args-in-mixed-format-calls and have the default be false. Modulo the change in name and polarity, everything else about the configuration would stay the same.

I could submit a PR if the maintainers and @nyurik are agreeable to the change.

P.S. @nyurik I love the unlined_format_args lint! 🙏

Activity

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-uiArea: Clippy interface, usage and configuration

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions