rustfmt: Gives up on chains if any line is too long.

If there is a method call chain, and just one call exceeds max_width, it seems like rustfmt gives up and doesn’t format anything.

Example:

fn f() {
    foo("This text is under the max_width limit, and shouldn't cause any problems on its own.").long("But this line is extra long, and doesn't fit within 100 max_width. 1234567890123456789").baz().collect().unwrap();
}

No format changes will be applied to this. I’m also a bit surprised that error_on_line_overflow does not complain.

I would expect it to wrap each call chain element, even if one of them is too long, such as:

fn f() {
    foo("This text is under the max_width limit, and shouldn't cause any problems on its own.")
        .long("But this line is extra long, and doesn't fit within 100 max_width. 1234567890123456789")
        .baz()
        .collect()
        .unwrap();
}

All default settings. rustfmt 1.4.8-nightly (afb1ee1c 2019-09-08)

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 140
  • Comments: 57 (23 by maintainers)

Commits related to this issue

Most upvoted comments

I very much agree with Josh here, but I think even bigger issue is that there are no visible errors/warnings that formatting is not possible and why. It just silently gives up, leaving user guessing why this particular part of the code is not formatted correctly.

How has this bug been open for almost 5 years without a fix? “Just giving up without any error” is unacceptable behavior for a formatter.

i don’t have the required programming experience and the rust skills yet

So be respectful when you speak. Don’t act like a self-entitled git (in the traditional sense of the word).

@calebcartwright In general, I’d expect rustfmt to indent everything to the correct level, and try to wrap appropriately at line-width, but whether it’s successful or not, it should continue on to wrap the rest, yes.

It’s not “except within chains”, it’s “when possible, without violating more important constraints like properly indenting”. If you have an indent-width of 4, and (say) 15 levels of indentation and a 50-character function name, you cannot format that without exceeding 100 characters, and that shouldn’t stop you from continuing on to format more of the line. And if you need to wrap the function parameters, those should still get indented 16 levels, even if one of them is a long string.

I just ran into this as well. My code:

fn main() {
    clap::App::new("foo")
        .subcommand(
            SubCommand::with_name("bar")
                .about("some text here")
                .setting(AppSettings::ArgRequiredElseHelp)
                .arg(
                    Arg::from_usage("-l, --latest 'some very long help text goes here [default: default version]'")
                                               .conflicts_with(  "template_version"  )
                )
        )
        .get_matches();
}

rustfmt seems to completely give up after the line with the long help text, and doesn’t even try to reindent the .conflicts_with, or fix the spacing in its argument, or add a trailing comma in either of the two places that should have trailing commas.

I’d expect rustfmt to do best-effort on the long line, and then continue afterward.

This was affecting me for a few days, was getting around it by just manually formatting but I was getting desperate. I installed nightly and added the extra fields which ended upbreaking a string and reflowing another expression. I’ve found though that if you have highly nested match/if statements the whitespace counts towards the max width. I imagine most use spaces so that’s 2-4 characters wasted on each indent instead of 1 per tab. Indents also can’t be “reflowed” so it creates a similar problem to strings which are >97 (accounting for the "/’ and the trailing comma if used in a function argument.

I think this is an absolutely insane limitation that it doesn’t warn or error at all outside of nightly. I had been trying to find any reason this wasn’t compiling and it turns out this issue was exactly what I was running into the whole time.

@ilyvion Your snippet clued me into whitespace being an issue as well. For yours I’d expect the formatter to break the closure into multiple lines. You’re right that this silently failing is a huge problem.

    {
        {
            {
                {
                    {
                        {
                            once::run(move |asset_server: Vec<AssetServer>,dynamic_assets: Vec<DynamicAssets>| {
                                load_dynamic_asset(
                                    &dynamic_assets,
                                    &asset_server,
                                    "dialogs",
                                    &dialog,
                                )
                                .expect(&dialog)
                            })
                        }
                    }
                }
            }
        }
    }

I’m unsure why this has been allowed to persist for 4-5 years. Especially given that because it’s silent and it only ever doesn’t run when it can’t compile. So when it compiles and doesn’t format… It’s a game of whack a mole to figure out which fmt rule is breaking, installing nightly and developing within that isn’t feasible since it’s nightly.

Why don’t you fix it yourself? 🤔

You do not need strings to get this bug:

// this does not format
let offenders = current_validators
    .into_iter()
    .enumerate()
    .filter_map(|(_, id)| 
    <<Runtime as pallet_im_online::Config>::ValidatorSet as ValidatorSetWithIdentification<
        sp_runtime::AccountId32>>::IdentificationOf::convert(id.clone()).map(|full_id| (id, full_id)))
    .collect::<Vec<IdentificationTuple<Runtime>>>();
// this type alias prevents the formatting bug
type XXX =
    <<Runtime as pallet_im_online::Config>::ValidatorSet as ValidatorSetWithIdentification<
        sp_runtime::AccountId32,
    >>::IdentificationOf;

// this does format
let offenders = current_validators
    .into_iter()
    .enumerate()
    .filter_map(|(_, id)| XXX::convert(id.clone()).map(|full_id| (id, full_id)))
    .collect::<Vec<IdentificationTuple<Runtime>>>();

And the giving up propagates to the whole block.

Do I understand correctly that if I have too long string literal then rustfmt will just ignore the whole function without any warning / error, and there is nothing that stable toolchain users can do about it because format_strings and https://rust-lang.github.io/rustfmt/?version=master&search=overflow#error_on_line_overflow are all unstable? And this situation is going on for 5 years now? Great…

Here’s my suggestion:

Rustfmt should treat this case the same as Prettier, Biome, Black, Ruff, and I assume many other auto-formatters which I’m not familiar with. Namely, treat the max width as a target but not a strict maximum. They try their best to get lines to fit under that length, but if they can’t, they can’t and that’s fine. They still get the line as short as possible.

Here’s my suggestion:

Rustfmt should treat this case the same as Prettier, Biome, Black, Ruff, and I assume many other auto-formatters which I’m not familiar with. Namely, treat the max width as a target but not a strict maximum. They try their best to get lines to fit under that length, but if they can’t, they can’t and that’s fine.

It could write a warning to stderr, with a config option disable_warning_on_ignored_line.
Both existing options, next to only existing in nightly, have the problem, that you still have the problem with code styling.
If you set a longer max line length it restyles all your code.
If you set the error on overflow, it errors and you have to fiddle around to get the line shorter.
Which is also not so easy viewable, because IDE inserts virtually the types and makes lines virtually longer they are.

And overall I don’t understand why it ignores the other lines of code block following the long line.
This looks like a bug and should have been fixed separately to introducing options as a workaround.

Using format_strings pretty much fixed it for me as strings get broken up and rustfmt can keep the line length below max_width.

Here’s my suggestion:

Rustfmt should treat this case the same as Prettier, Biome, Black, Ruff, and I assume many other auto-formatters which I’m not familiar with. Namely, treat the max width as a target but not a strict maximum. They try their best to get lines to fit under that length, but if they can’t, they can’t and that’s fine. They still get the line as short as possible.

I strongly agree with this.

I have spent a while being very confused about why rustfmt wasn’t formatting some trailing whitespace that broke our CI for our project, as well as not formatting some other lines. Given the robustness and friendly error reporting of Rust tools, I would have expected it to format as much as possible and at least print a warning.

At the moment, it fails silently until something triggers a CI failure or an isolated line change suddenly causes an entire screenful of code to be reformatted.

Now that I know about this issue I can fix it when I see it, but I don’t see a way to identify when it happens (other than when it happens to cause trailing whitespace, which is not every time). Does anyone know any arguments to rustfmt that will reveal when it runs into this bug?

@nazar-pc try running with --config error_on_line_overflow=true which exists for precisely this purpose (make sure you’re on nightly), it’s just disabled by default. If you’d like to make a case for that being enabled by default then #3391 would be the place to do so

example output with that enabled:

error: line formatted, but exceeded maximum width (maximum: 100 (see `max_width` option), found: 115)
 --> <stdin>:8:8:101
  |
8 |                     Arg::from_usage("-l, --latest 'some very long help text goes here [default: default version]'")
  |                                                                                                     ^^^^^^^^^^^^^^^
  |

warning: rustfmt has failed to format. See previous 1 errors.

It seems entire match statements’ stop getting formatted if you have a long string-literal (eg. in a todo!(…)), and if you then happen to have a trailing white-space on the end of a list of variants as shown in my example below, then rust-fmt errors out causing the rest of the code to stop formatting too (atleast in vscode/rust-analyzer):

pub enum SomeType {
    A,
    B,
    C,
}

fn some() {
    let ct = SomeType::A;
    // "SomeType::A " <- trailing whitespace below crashes due to long string in todo!(..)
    match ct {
        SomeType::A 
        | SomeType::B => { /* safe to ignore */ }

        SomeType::C => todo!("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin accumsan orci eget elit posuere varius."),
    }
        let _ill_formatted = 1; /* indent not fixed by rust-analyzer in vscode, but is in rs-playground */
}
error[internal]: left behind trailing whitespace
  --> /playground/src/main.rs:11:11:20
   |
11 |         SomeType::A 
   |                    ^
   |

warning: rustfmt has failed to format. See previous 1 errors.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=e9fed6e242d365cef07f21538724e3c4

i don’t have the required programming experience and the rust skills yet

I would like an option to have max_width be the width of the line not including the indentation, or a switch, like relative_max_width

Yeah, AFAICT that’s because rustfmt is expecting to be able to rewrite each of the individual ChainItems to be able to format the Chain. When it attempts to rewrite that long string literal in the Chain it fails due to the length which results in the entire original chain being left as-is.

https://github.com/rust-lang/rustfmt/blob/a15e97f1e92b3621ab8c2f1585f27e8de583f74b/src/chains.rs#L419-L444

I think I see a way we could support still wrapping chain elements like your expected output, though it would mean rustfmt emitting a line that exceeds the max_width (although the original line does too, and the wrapped version is more human friendly IMO even with the one longer line).

@topecongiro @scampi - any concerns with that? if not, then I’ll take a look at implementing something for consideration.

Another example where a closure is part of the chain:

fn main() {
    let f = foo("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
        .bar(|| {
foo( 233545   );



             if   let Some   ( x)   = foo(3) {
   }
    });
}

So, i have two questions:

  1. Is this the same issue reported here, or something different that looks similar?
  2. If a general fix for this is too complicated, could at least the condition of bailing out on long strings be more local? For example, in the snippet above, could it only affect the formatting of the last block on the match, leaving only that block unformatted, but still formatting the rest of the non-offending blocks normally?
  1. No, it’s separate. There’s various other comments above reporting different-but-with-similar-symptom issues, but they’re likely buried because of the volume of commentary, see https://github.com/rust-lang/rustfmt/issues/3863#issuecomment-986343312 for more
  2. No, no general fix, see same linked comment. Also don’t want to add any additional noise on this thread discussing the reasoning or potential changes for a different issue that would have no impact on this issue.

Update regarding the above: apparently raw strings are allowed to be too long, so I will just convert my long strings to raw strings now.

This means that r#"aaa....aaa"# is formatted correctly even it’s too long, whereas "aaa....aaa" does not.

Before I make this a new issue, can someone check whether or not this issue I’m running into has the same cause as this issue? This isn’t the exact code I’m having trouble with, but it behaves identically, so it’s a good MRE: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f52f18c42f46824eb308281c23ed978e

If you run rustfmt on it, you’ll see the code doesn’t get properly formatted. In particular, ,dynamic_assets remains without a space after the comma, but also any other bad formatting in the same block remains broken if you mess it up further and try to run formatting on that.

To make rustfmt work again, simply shorten the length of the parameters in the closure. You can make it |asset: Vec<AssetServer>, dynamic: Vec<DynamicAssets>|, e.g. and it formats, or |asset_server: Vec<Asset>, dynamic_assets: Vec<Dynamic>| but it feels wrong to me that formatting entirely stops working in a whole block of code just because some names/lines end up too long.

Seems weird that it tries to put as much as possible on 1 line just to break itself. E.g. here formatting doesn’t work, nothing is reported with error_on_line_overflow

{
    t(|ctx, input: VeryLongInputName| async move {
       None
    })
}

If I shorten the struct name a bit then it starts working and it puts even more stuff on that problematic line. Took me several hours to pinpoint this specific place in the long chain of methods that are needed for rspc to create the procedures handler.

{
    t(|ctx, input: VeryLongInputNam| async move { None })
}

This actually reports the very long line error.

{
    t(|ctx, input: VeryLongInputName| async move { None })
}

BTW, it would be very helpful if there was a mode or cli flags that I could use to identify lines that are too long for rustfmt.

Discussed above (e.g. https://github.com/rust-lang/rustfmt/issues/3863#issuecomment-700441739) and in a few other threads, but you can turn on error_on_line_overflow and error_on_unformatted for this.

rustfmt can’t format the entire file, but it doesn’t give any indication about what line(s) need to be manually shortened.

This is a topic that pops up frequently so I’ll reiterate here that it’s important to distinguish between what rustfmt does vs. what editor plugins do, especially since we have no influence/insight into what those various plugin teams do. The decision to not apply any formatting to an entire file in some scenarios is behavior that some editor plugins have opted to apply, and is not related to rustfmt behavior in any capacity.

In these unformattable scenarios rustfmt only leaves the the top level expression as you wrote it, but will absolutely format everything else in the file.

Additionally, the aforementioned config options, though disabled by default, will highlight your lines that are too long. If you have a scenario where that’s not the case (when running rustfmt directly, not editor behavior) then happy to take a look but would ask a separate issue be filed with steps to reproduce.

Option (b)

Attempt to dynamically derive and then use a formatting shape with an increased width (which exceeds max_width) which will be used for that specific chain element.

The reason this would be necessary is to provide some required constraints when formatting those subexpressions to avoid horrific formatting that would try to collapse/single line everything out lines to infinity. I’d envision this operating along the lines of:

  • if impossible to fit the chain element within the max_width of 100
  • then create a scaled up width for this particular chain element (we could allow user control over this, e.g. long_chain_scale_factor = 20%, or rustfmt could attempt to guess one based on what it sees in the AST)
  • repeat as necessary, with some max number of scaled retry attempts (which again could be user controllable)

This would be more complex, both from a user experience/mental model and implementation, but if we get it right would probably be much helpful for that cases with more complex args within chained calls.

With the above being said, I have finally managed to set aside some time to dig into this and believe I see a viable path forward.

As noted previously the current behavior will remain the default, but I’m planning on introducing a new config option that will provide some additional variants users can leverage to control chain formatting behavior. That would include one variant that will perform the standard chain formatting behavior, but unlike the default behavior, it will attempt to make a best effort to continue formatting chains which in part exceed the defined max_width value as requested here.

We’d also most likely want to encourage users opting for this non-default behavior to strongly consider pairing it with other options like error_on_line_overflow (which we’ll be adjusting to include off/warn/error mode variants and then hopefully stabilizing) so that you’ll be aware of cases where your formatting result exceeded your defined value for max_width.

There’s only two feasible approaches I can see for handling an element within a chain that must exceed max_width. I’d like to run a poll of sorts to gauge interest on those, so I’ll details those two in separate comments (options a and b below) and ask folks to use reactions on those comments to provide their feedback.

Note that these aren’t mutually exclusive and I’m open to supporting both if there’s interest. As such I’d ask folks to primarily utilize the “thumbs up” to indicate favor/interest, and only use the “thumbs down” if you adamantally feel the option shouldn’t even exist (don’t downvote it just because you wouldn’t use it yourself).

I’d also ask that folks refrain from requesting other options on this issue. The original use case posed in the issue is pretty straightforward and the solution I have in mind will present a resolution to this. It will also create a framework of sorts through which additional variants/formatting behaviors can be added down the road, each of which should be proposed/discussed independently in a separate issue.

Finally, in cases where a chain in a right hand side (rhs) position (e.g. an assignment) is too long fit within the boundary with either shape (i.e. same line as lhs/assignment operator vs. next line block indented), rustfmt will have to try to pick where to put the chain, and I’m thinking that we should base that on which of the two will minimize the amount of formatted chain that ends up on the right of the defined max_width boundary. There’s not a ton of alternatives to that which come to mind for me, but if anyone has questions/alternatives to that particular piece feel free to ask/suggest.

@lpil I’ve actually had this happen, I believe the reason is that the following line is concatenated to the end of the comment. When I forced it to format it would merge the commented line and potentially drop entire comments with lossy reformats. It highly depends on the syntax around the comment.

@lpil Have to find out the line length that is configured by rustfmt; I don’t remember the default off the top of my head but if you explicitly set it in .rustfmt.toml then that’s it.

Then plug it into either of the following for e.g. 100 characters:

# If you use ripgrep (which I recommend - cargo install ripgrep)
rg '^.{100,}$'

# or using grep
grep -rE '^.{100,}$'

I’ve also found that in many cases temporarily setting the line length to be really long - like 150 or whatever - then doing a cargo fmt, and resetting or unsetting the line length config option sometimes will “unstuck” the long lines.

Unfortunately the solution above did not actually work in my real code. Below is a reduced example with raw strings:

fn f() {
    f1().f2(
            &[],
            f3(
                    r#"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"#,
            ),
        );
    f1().f2(
            &[],
            f3(
                    r#"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"#,
            ),
        );
}

becomes

fn f() {
    f1().f2(
            &[],
            f3(
                    r#"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"#,
            ),
        );
    f1().f2(
        &[],
        f3(r#"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"#),
    );
}

I just had this issue as well. I have an array which spans a lot of lines and it happens to contain some long strings, and as a result almost the entire file has no formatting. The strings contain URLs, which is why they are so long.

Here is an example:

fn f() {
    let too_long = [
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"b"
    ];
    let not_too_long = [
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"b",
    ];
}

becomes

fn f() {
    let too_long = [
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"b"
    ];
    let not_too_long = [
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
        "b",
    ];
}

Is this something that is planned to be fixed, or is there some reason to keep this behaviour?

rustfmt 1.7.1-nightly

I have more simple example to cause “left behind trailing whitespace” error.

fn test() {
    // ↓ this line has trailing space
    hello.push(|()| 
        abort!("aaaaa aaaaaaa aaaaaa aaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaaa aaaaaaaaaa aaaaaaa")
    );
}
error_on_unformatted = false
error_on_line_overflow = false
❯ rustfmt --version
rustfmt 1.8.0-nightly (00f245915b 2025-02-26)

❯ rustfmt --config-path ./rustfmt.toml test_bug2.rs
error[internal]: left behind trailing whitespace
 --> /****.rs:3:3:20
  |
3 |     hello.push(|()|
  |                    ^
  |

No worries! It’s a rather long and fairly old thread at this point so just wanted to note there were some other posts that drilled deeper into the details since I was too lazy to fully recap 😆

Thanks, I confirm that using both error_on_line_overflow and error_on_unformatted does what I want. I’m sorry for not having properly read the previous comments about this, that was wrong of me. I’ve also edited my above comment to clarify my comment about “the entire file”.

Option (a)

Use the original input for that element (whatever the user originally wrote), with some minor adjustments like indentation of the start of that element, and trimming trailing spaces.

This would directly solve the case originally reported in this issue with the desired format being produced for the provided input, as well as most other input snippets reported throughout the thread. It’s also something we could get out on nightly fairly quickly, potentially before the end of the month. However, it likely wouldn’t help all that much in cases where the exceeding chain item is caused by a more complex arg to a chained call, e.g. a closure with various other statements/expressions/etc., as that sub-content wouldn’t be processed

I appreciate those that have commented here, ostensibly in an attempt to avoid opening duplicative issues. However, I feel like in doing so the dialog has started drifting off topic.

As a reminder, rustfmt is strictly a pretty-printer style formatter that deals directly with the AST, so even if you experience similar symptoms from a different type of input AST node/syntax, it’s still a fundamentally different root cause that will almost always need a different investigation and resolution. I’d encourage folks in such a scenario (e.g. long strings but on a struct instead of within a chain) to look for/open a separate issue that’s based on your input, and simply add a link to other issues with similar symptoms if you think they may related.

Finally, while we do have some options available moving forward (which I’ll enumerate in a separate comment), I want to stress that this current behavior is unequivocally not a bug. It is intentional, it has always been the default, and it will continue to be the default.

The decision was made long, long ago to have width boundaries and associated wrapping as a core part of rustfmt when determining what the output should be for a given AST node, and in cases where it is completely impossible for rustfmt to honor the width settings (which the user controls, implicitly or explicitly via max_width) it is up to the user to refactor their code accordingly; rustfmt can’t just categorically run past your width boundary and carry on formatting any type of AST node without any concept of bounding constraints. That’s especially relevant for chains/calls because they frequently have more complex structures beyond string lits (e.g. closures, nested chains, etc.) containing other AST nodes that also have to be formatted according to the same rules.

A work around that can be beneficial in certain cases is to use the include, include_str, and include_bytes macros.

more important constraints like properly indenting

What defines the relative importance of one constraint vs. another though? Is there a consensus on which constraints can be violated? Does the style guide have a prescription? The only thing I’m familiar with (and I know you’re far more familiar with the style guide than I @joshtriplett 😄) is https://github.com/rust-dev-tools/fmt-rfcs/blob/7416e12356a55aae959e9629b58eb7c7c3c86f6f/guide/guide.md#indentation-and-line-width

It’s not that we can’t technically make this change, but in these types of scenarios where rustfmt can’t satisfy all the constraints it bails and defers to the programmer to format, or refactor, as needed. This is usually quite manageable, and often accompanied with advice like refactor your code to avoid long/complex expressions, usually by extracting a local variable or using a shorter name

If you have an indent-width of 4, and (say) 15 levels of indentation and a 50-character function name, you cannot format that without exceeding 100 characters

Precisely and agreed, I was just trying to keep the example in the context of chains given the issue.

There’s also portions of the user base that do want to strictly enforce the width limits in their code and would leverage options like error_on_line_overflow to ensure that any violations of the width constraints were indeed raised, and any changes to the behavior would have to continue to honor that (an implementation detail that I’m just noting for future reference).

I also think that if max width were to be changed to more of a soft constraint then we’d need to explicitly convey that rustfmt will format your code within the limit, unless it really can’t, in which case it will format out indentations indefinitely as needed.

Doing something about this is still on my to-do list, though I do think it’s worth expanding a bit on what folks have in mind when we say “best effort”.

It seems this is most often encountered with a single long string, but will also note there are plenty of other scenarios that can run into this where IMO the expected behavior starts to get a little tricky. Consider for example a chain whose parent starts in a heavily indented position, and the chain element that exceeds the max width value is a closure param that itself has a sizeable body with additional nested indentation.

Would users still want rustfmt to format that closure anyway even though it blows way past the max width value? Are we changing the meaning/honoring of max width with a caveat of “except within chains”? Should rustfmt do this by default or should users have to explicitly opt-in to allowing rustfmt to exceed the max width when there are chains involved?