- let pat_string = rewrite_multiple_patterns(context, &self.pats, pat_shape)?;
- let result = format!("{}{}{}", matcher, pat_string, self.connector);
+ let pat_string = pat.rewrite(context, pat_shape)?;
+ let comments_lo = context
+ .snippet_provider
+ .span_after(self.span, self.connector.trim());
+ let missing_comments = if let Some(comment) =
+ rewrite_missing_comment(mk_sp(comments_lo, expr.span.lo()), cond_shape, context)
+ {
+ if !self.connector.is_empty() && !comment.is_empty() {
+ if comment_style(&comment, false).is_line_comment() || comment.contains("\n") {
+ let newline = &pat_shape
+ .indent
+ .block_indent(context.config)
+ .to_string_with_newline(context.config);
+ // An extra space is added when the lhs and rhs are joined
+ // so we need to remove one space from the end to ensure
+ // the comment and rhs are aligned.
+ let mut suffix = newline.as_ref().to_string();
+ if !suffix.is_empty() {
+ suffix.truncate(suffix.len() - 1);
+ }
+ format!("{}{}{}", newline, comment, suffix)
+ } else {
+ format!(" {}", comment)
+ }
+ } else {
+ comment
+ }
+ } else {
+ "".to_owned()
+ };
+
+ let result = format!(
+ "{}{}{}{}",
+ matcher, pat_string, self.connector, missing_comments
+ );