diff --git a/src/matches.rs b/src/matches.rs index 9fd07cc1bf4..06e7078b11f 100644 --- a/src/matches.rs +++ b/src/matches.rs @@ -402,7 +402,11 @@ fn rewrite_match_body( let arrow_snippet = context.snippet(arrow_span).trim(); // search for the arrow starting from the end of the snippet since there may be a match // expression within the guard - let arrow_index = arrow_snippet.find_last_uncommented("=>").unwrap(); + let arrow_index = if context.config.version() == Version::One { + arrow_snippet.rfind("=>").unwrap() + } else { + arrow_snippet.find_last_uncommented("=>").unwrap() + }; // 2 = `=>` let comment_str = arrow_snippet[arrow_index + 2..].trim(); if comment_str.is_empty() { diff --git a/tests/source/arrow_in_comments/arrow_in_single_comment.rs b/tests/source/arrow_in_comments/arrow_in_single_comment.rs index c4ae0634832..fb0576a4822 100644 --- a/tests/source/arrow_in_comments/arrow_in_single_comment.rs +++ b/tests/source/arrow_in_comments/arrow_in_single_comment.rs @@ -1,4 +1,4 @@ -// rustfmt-wrap_comments: true +// rustfmt-version: Two fn main() { match a { _ => diff --git a/tests/source/arrow_in_comments/multiple_arrows.rs b/tests/source/arrow_in_comments/multiple_arrows.rs index b827a20803c..fc696b309f2 100644 --- a/tests/source/arrow_in_comments/multiple_arrows.rs +++ b/tests/source/arrow_in_comments/multiple_arrows.rs @@ -1,4 +1,4 @@ -// rustfmt-wrap_comments: true +// rustfmt-version: Two fn main() { match a { _ => // comment with => diff --git a/tests/target/arrow_in_comments/arrow_in_single_comment.rs b/tests/target/arrow_in_comments/arrow_in_single_comment.rs index a46370c08e8..deffdbeeaaf 100644 --- a/tests/target/arrow_in_comments/arrow_in_single_comment.rs +++ b/tests/target/arrow_in_comments/arrow_in_single_comment.rs @@ -1,4 +1,4 @@ -// rustfmt-wrap_comments: true +// rustfmt-version: Two fn main() { match a { _ => diff --git a/tests/target/arrow_in_comments/multiple_arrows.rs b/tests/target/arrow_in_comments/multiple_arrows.rs index 8a2b5061f72..b0443411816 100644 --- a/tests/target/arrow_in_comments/multiple_arrows.rs +++ b/tests/target/arrow_in_comments/multiple_arrows.rs @@ -1,4 +1,4 @@ -// rustfmt-wrap_comments: true +// rustfmt-version: Two fn main() { match a { _ =>