You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider the following example (using clap, as it's one of the easiest builders to demonstrate with):
use clap::{Arg,Command};fnmain(){let matches = Command::new("app").arg(Arg::new("debug").long("debug").short('d').help("Enable additional debugging.").takes_value(false)).about("This string is really super long and rustfmt refuses to wrap it, so long that it isn't even suitable on a line of its own.").arg(Arg::new("debug").long("debug").short('d').help("Enable additional debugging.").takes_value(false)).get_matches();}
rustfmt does nothing (tested on current playground, 1.4.38-nightly (2022-05-05 30f3860)).
Whereas the following example, without the exceedingly long string:
use clap::{Arg,Command};fnmain(){let matches = Command::new("app").arg(Arg::new("debug").long("debug").short('d').help("Enable additional debugging.").takes_value(false)).about("This is a short string.").arg(Arg::new("debug").long("debug").short('d').help("Enable additional debugging.").takes_value(false)).get_matches();}
Formats to the following (what I would expect):
use clap::{Arg,Command};fnmain(){let matches = Command::new("app").arg(Arg::new("debug").long("debug").short('d').help("Enable additional debugging.").takes_value(false),).about("This is a short string.").arg(Arg::new("debug").long("debug").short('d').help("Enable additional debugging.").takes_value(false),).get_matches();}
It seems like rustfmt gives up on the entire statement if any part won't satisfy the width heuristic in the output, rather than still doing its best. The ideal formatting for the long string version would be the final output of the short string version, with the short string substituted. With extremely long builder chains this leads to horrible formatting, as it must all be done manually.
The text was updated successfully, but these errors were encountered:
Consider the following example (using clap, as it's one of the easiest builders to demonstrate with):
rustfmt does nothing (tested on current playground, 1.4.38-nightly (2022-05-05 30f3860)).
Whereas the following example, without the exceedingly long string:
Formats to the following (what I would expect):
It seems like rustfmt gives up on the entire statement if any part won't satisfy the width heuristic in the output, rather than still doing its best. The ideal formatting for the long string version would be the final output of the short string version, with the short string substituted. With extremely long builder chains this leads to horrible formatting, as it must all be done manually.
The text was updated successfully, but these errors were encountered: