diff --git a/src/bin/cargo-fmt.rs b/src/bin/cargo-fmt.rs index eeccae5c0776..93348b829966 100644 --- a/src/bin/cargo-fmt.rs +++ b/src/bin/cargo-fmt.rs @@ -94,7 +94,7 @@ fn print_usage(opts: &Options, reason: &str) { let msg = format!("{}\nusage: cargo fmt [options]", reason); println!( "{}\nThis utility formats all bin and lib files of the current crate using rustfmt. \ - Arguments after `--` are passed to rustfmt.", + Arguments after `--` are passed to rustfmt.", opts.usage(&msg) ); } diff --git a/src/bin/rustfmt.rs b/src/bin/rustfmt.rs index 58b7e3ac8fd0..e819579db143 100644 --- a/src/bin/rustfmt.rs +++ b/src/bin/rustfmt.rs @@ -144,7 +144,7 @@ fn make_opts() -> Options { "", "config-path", "Recursively searches the given path for the rustfmt.toml config file. If not \ - found reverts to the input file path", + found reverts to the input file path", "[Path for the configuration file]", ); opts.optopt( diff --git a/src/checkstyle.rs b/src/checkstyle.rs index 90ba45610246..7b7ab2e1b2de 100644 --- a/src/checkstyle.rs +++ b/src/checkstyle.rs @@ -55,7 +55,7 @@ where write!( writer, "", + />", mismatch.line_number, message )?; diff --git a/src/expr.rs b/src/expr.rs index cba0ef381a03..3b78dc961c20 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1857,7 +1857,26 @@ fn rewrite_string_lit(context: &RewriteContext, span: Span, shape: Shape) -> Opt let string_lit = context.snippet(span); if !context.config.format_strings() && !context.config.force_format_strings() { - return Some(string_lit); + if string_lit + .lines() + .rev() + .skip(1) + .all(|line| line.ends_with('\\')) + { + let new_indent = shape.visual_indent(1).indent; + return Some(String::from( + string_lit + .lines() + .map(|line| { + new_indent.to_string(context.config) + line.trim_left() + }) + .collect::>() + .join("\n") + .trim_left(), + )); + } else { + return Some(string_lit); + } } if !context.config.force_format_strings() && diff --git a/src/file_lines.rs b/src/file_lines.rs index 4eae2602908b..6fa243dc1868 100644 --- a/src/file_lines.rs +++ b/src/file_lines.rs @@ -228,7 +228,7 @@ impl<'de> ::serde::de::Deserialize<'de> for FileLines { { panic!( "FileLines cannot be deserialized from a project rustfmt.toml file: please \ - specify it via the `--file-lines` option instead" + specify it via the `--file-lines` option instead" ); } }