Open
Description
version
rustfmt 1.7.1-nightly (94885bc6 2024-09-01)
rustfmt.toml
max_width = 80
use_small_heuristics = "Max"
example
fn _hincrbyex(
_a: &mut i64,
_key: &i64,
_field: &i64,
_delta: i64,
_iexpsec: i64,
_b0: bool,
) -> bool {
false
}
fn test() {
let mut conn: i64 = 0;
let key: i64 = 0;
let field: i64 = 0;
let delta: i64 = 0;
let iexpsec: i64 = 0;
let is_xxxxxxxx: bool = false;
let is_xxxxxxxxx: bool = false;
let is_xxxxxxxxxxxxxxx: bool = false;
let is_xxxxxxxxxxxxxxxx: bool = false;
// single line: exactly 80 ------------------------------------------------|
let _fut = _hincrbyex(&mut conn, &key, &field, delta, iexpsec, is_xxxxxxxx);
// style 1: 81 ------------------------------------------------------------|
let _fut =
_hincrbyex(&mut conn, &key, &field, delta, iexpsec, is_xxxxxxxxx);
// style 1: exactly 80 for the second line --------------------------------|
let _fut =
_hincrbyex(&mut conn, &key, &field, delta, iexpsec, is_xxxxxxxxxxxxxxx);
// style 2: 81 for the second line in style 1 -----------------------------|
let _fut = _hincrbyex(
&mut conn,
&key,
&field,
delta,
iexpsec,
is_xxxxxxxxxxxxxxxx,
);
}
According to the above example, rustfmt have two line break styles for long statement. But I really don't like the style 1 because it looks strange in some cases. I have to make some tricky adjustments such as rename the function name / rename some argument names / ... to change the style 1 to single line or style 2. And it bothers me too in some other situations such as match-arms.
I wish to have some new options in rustfmt.toml to disable the style 1, a statement should directly be formatted to the style 2 from single line if it's too long. Thanks~
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
ytmimi commentedon Sep 27, 2024
Seems like this is related to #3626 and is the opposite of #3514
zhongxinghong commentedon Sep 29, 2024
I see. with #3514, I think these can be roughly summarized into the following situations:
for
max_width = 80
line length situations:
line break style:
examples for line break style:
user options:
expected style chooses: