Skip to content

Wrong calc fn_call_width vs. max_width for default use_small_heuristics #6601

Closed as duplicate

Description

@boozook

Version: rustfmt 1.8.0-nightly (ab68b0fb26 2025-07-08)

Seems to fn_call_width and other which depends on use_small_heuristics = "Default" calculated incorrectly (or I just don't understand how it works 🤷🏻‍♂️).

How to reproduce:

  • Run rustfmt -v --check with config below.

Message:

`fn_call_width` cannot have a value that exceeds `max_width`. `fn_call_width` will be set to the same value as `max_width`
`attr_fn_like_width` cannot have a value that exceeds `max_width`. `attr_fn_like_width` will be set to the same value as `max_width`
`struct_lit_width` cannot have a value that exceeds `max_width`. `struct_lit_width` will be set to the same value as `max_width`
`struct_variant_width` cannot have a value that exceeds `max_width`. `struct_variant_width` will be set to the same value as `max_width`
`array_width` cannot have a value that exceeds `max_width`. `array_width` will be set to the same value as `max_width`
`chain_width` cannot have a value that exceeds `max_width`. `chain_width` will be set to the same value as `max_width`
`single_line_if_else_max_width` cannot have a value that exceeds `max_width`. `single_line_if_else_max_width` will be set to the same value as `max_width`
`single_line_let_else_max_width` cannot have a value that exceeds `max_width`. `single_line_let_else_max_width` will be set to the same value as `max_width`

Config fustfmt.toml:

unstable_features = true
edition = "2024"
style_edition = "2024"


max_width = 1000
comment_width = 1000

use_small_heuristics = "Default"

fn_call_width = 999
attr_fn_like_width = 999
struct_lit_width = 999
struct_variant_width = 999
array_width = 999
chain_width = 999
single_line_if_else_max_width = 999
single_line_let_else_max_width = 999

Activity

  1. added
    E-needs-mcve
    on Jul 9, 2025
  2. ytmimi commented on Jul 9, 2025

    @ytmimi
    Contributor

    @boozook please provide a code snippet we can use to verify the issue, thanks!

  3. ytmimi commented on Jul 9, 2025

    @ytmimi
    Contributor

    Though this feels like a duplicate of #5404

  4. boozook commented on Jul 9, 2025

    @boozook
    Author

    @ytmimi Uh, sorry, really looks similar. But I not 100%-sure.

    please provide a code snippet we can use to verify the issue, thanks!

    Just tested with minimal reproducible code snippet from #5404 that you've mentioned - yes, it is!

    macro_rules! foo {
        () => {};
    }

    Close this issue freely if necessary, sorry for duplicate if it is so. Thanks!

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

    E-needs-mcve

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions