Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leave wrapped struct/function as is even not touch the max_width #6122

Open
clouds56 opened this issue Mar 21, 2024 · 0 comments
Open

Leave wrapped struct/function as is even not touch the max_width #6122

clouds56 opened this issue Mar 21, 2024 · 0 comments

Comments

@clouds56
Copy link

With vscode extension rust-analyzer, the (visual) line width in editor might not the same as the width in text file.
e.g.

fn f(very_very_very_very_long_arg_1: i32, very_very_very_very_long_arg_2: i32) {}

fn main() {
  f("1".parse().expect("true"), "2".parse().expect("true")); // what rustfmt see
}

with rust-analyzer it would be rendered as

fn main() {
  f(very_very_very_very_long_arg_1: "1".parse().expect("true"), very_very...: "2".parse().expect("true")); // what we see
}

which is much longer.
The question here is not that rustfmt would not turn this f("1".parse().expect("true"), "2".parse().expect("true")); into vertical format, it is about rustfmt would shrink my vertical formatting version into oneline.

// I write it vertically, after `cargo fmt` it would be forced be into one line
fn main() {
  f(
    "1".parse().expect("true"),
    "2".parse().expect("true"),
  );
}

I think we should add an option like no_force_same_line that rustfmt would only break long line but not combine lines, so that when I explicitly write vertical formatting code, rustfmt would leave it as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants