From b99f3cb447d0eb76afd5d6d3b19336f12e30cc3f Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Mon, 19 Jun 2017 22:06:08 +0900 Subject: [PATCH] Allow extending a chain after raw string literal --- src/utils.rs | 7 ++++--- tests/source/chains.rs | 11 +++++++++++ tests/target/chains.rs | 13 +++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index 1be83d01bab..dc5dee6ba0d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -111,9 +111,10 @@ pub fn trimmed_last_line_width(s: &str) -> usize { #[inline] pub fn last_line_extendable(s: &str) -> bool { s.lines().last().map_or(false, |s| { - s.trim() - .chars() - .all(|c| c == ')' || c == ']' || c == '}' || c == '?') + s.ends_with("\"#") || + s.trim() + .chars() + .all(|c| c == ')' || c == ']' || c == '}' || c == '?') }) } diff --git a/tests/source/chains.rs b/tests/source/chains.rs index 20d320ccde8..99fe6176aa8 100644 --- a/tests/source/chains.rs +++ b/tests/source/chains.rs @@ -152,3 +152,14 @@ fn issue_1004() { }) ?; } + +fn issue1392() { + test_method(r#" + if foo { + a(); + } + else { + b(); + } + "#.trim()); +} diff --git a/tests/target/chains.rs b/tests/target/chains.rs index 52e65b420e7..d930f0a49ba 100644 --- a/tests/target/chains.rs +++ b/tests/target/chains.rs @@ -169,3 +169,16 @@ fn issue_1004() { in_binder(f, tcx, &ty::Binder(""), Some(tap)) })?; } + +fn issue1392() { + test_method( + r#" + if foo { + a(); + } + else { + b(); + } + "#.trim(), + ); +}