diff --git a/src/expr.rs b/src/expr.rs index 4076298cec8..f2c98129cd6 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -693,11 +693,6 @@ fn rewrite_match_arm_comment(context: &RewriteContext, Some(n) => &missed_str[n+1..], None => &missed_str[..], }; - // Nor the trailing "}" which closes the match - let missed_str = match missed_str.find_uncommented("}") { - Some(n) => &missed_str[..n-1], - None => &missed_str[..], - }; let mut result = String::new(); // any text not preceeded by a newline is pushed unmodified to the block @@ -777,7 +772,10 @@ fn rewrite_match(context: &RewriteContext, result.push_str(&snippet); } } - let last_comment = context.snippet(mk_sp(arm_end_pos(&arms[arms.len() - 1]), span.hi)); + // BytePos(1) = closing match brace. + let last_span = mk_sp(arm_end_pos(&arms[arms.len() - 1]), + span.hi - BytePos(1)); + let last_comment = context.snippet(last_span); let comment = try_opt!(rewrite_match_arm_comment(context, &last_comment, width, diff --git a/tests/source/match.rs b/tests/source/match.rs index 49e66e4c0df..b1c6449226f 100644 --- a/tests/source/match.rs +++ b/tests/source/match.rs @@ -221,3 +221,7 @@ fn issue280() { } } } + +fn issue383() { + match resolution.last_private {LastImport{..} => false, _ => true}; +} diff --git a/tests/target/match.rs b/tests/target/match.rs index 6e330505a9b..e6b0b4099d3 100644 --- a/tests/target/match.rs +++ b/tests/target/match.rs @@ -210,3 +210,10 @@ fn issue280() { } } } + +fn issue383() { + match resolution.last_private { + LastImport{..} => false, + _ => true, + }; +}