Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::borrow::Cow;
use std::cmp::min;

use itertools::Itertools;
use syntax::parse::token::DelimToken;
use syntax::parse::token::{DelimToken, LitKind};
use syntax::source_map::{BytePos, SourceMap, Span};
use syntax::{ast, ptr};

Expand Down Expand Up @@ -75,7 +75,17 @@ pub(crate) fn format_expr(
choose_separator_tactic(context, expr.span),
None,
),
ast::ExprKind::Lit(ref l) => rewrite_literal(context, l, shape),
ast::ExprKind::Lit(ref l) => {
if let Some(expr_rw) = rewrite_literal(context, l, shape) {
Some(expr_rw)
} else {
if let LitKind::StrRaw(_) = l.token.kind {
Some(context.snippet(l.span).trim().into())
} else {
None
}
}
}
ast::ExprKind::Call(ref callee, ref args) => {
let inner_span = mk_sp(callee.span.hi(), expr.span.hi());
let callee_str = callee.rewrite(context, shape)?;
Expand Down
12 changes: 12 additions & 0 deletions tests/source/issue-3786.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
fn main() {
let _ =
r#"
this is a very long string exceeded maximum width in this case maximum 100. (current this line width is about 115)
"#;

let _with_newline =

r#"
this is a very long string exceeded maximum width in this case maximum 100. (current this line width is about 115)
"#;
}
9 changes: 9 additions & 0 deletions tests/target/issue-3786.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fn main() {
let _ = r#"
this is a very long string exceeded maximum width in this case maximum 100. (current this line width is about 115)
"#;

let _with_newline = r#"
this is a very long string exceeded maximum width in this case maximum 100. (current this line width is about 115)
"#;
}