rust-lang / rustfmt

Format Rust code
https://rust-lang.github.io/rustfmt/
Apache License 2.0
6.06k stars 892 forks source link

Clamp width settings to max_width before warning about exceeding it #6359

Closed rs-sac closed 1 month ago

rs-sac commented 1 month ago

Within a macro scope, max_width is reduced, which can trigger warnings if it is reduced below some other width setting (e.g. struct_lit_width.) Width settings were already being clamped to max_width, but only after the warning fired. The order is now reversed.


This change allows setting, e.g., struct_lit_width to the same value as max_width without getting incorrect warnings within macro scopes. The bug related to macros has been previously acknowledged, and a previous fix was attempted. I attempt to fix the same problem, but my patch takes an approach different from deleting the warning.

Related: