Add MatchKind member to the Match expr for pretty printing & fmt
This commit is contained in:
parent
124808b582
commit
f3892a06cc
@ -3,7 +3,7 @@ use std::cmp::min;
|
|||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use rustc_ast::token::{Delimiter, Lit, LitKind};
|
use rustc_ast::token::{Delimiter, Lit, LitKind};
|
||||||
use rustc_ast::{ast, ptr, token, ForLoopKind};
|
use rustc_ast::{ast, MatchKind, ptr, token, ForLoopKind};
|
||||||
use rustc_span::{BytePos, Span};
|
use rustc_span::{BytePos, Span};
|
||||||
|
|
||||||
use crate::chains::rewrite_chain;
|
use crate::chains::rewrite_chain;
|
||||||
@ -170,8 +170,8 @@ pub(crate) fn format_expr(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::ExprKind::Match(ref cond, ref arms) => {
|
ast::ExprKind::Match(ref cond, ref arms, kind) => {
|
||||||
rewrite_match(context, cond, arms, shape, expr.span, &expr.attrs)
|
rewrite_match(context, cond, arms, shape, expr.span, &expr.attrs, kind)
|
||||||
}
|
}
|
||||||
ast::ExprKind::Path(ref qself, ref path) => {
|
ast::ExprKind::Path(ref qself, ref path) => {
|
||||||
rewrite_path(context, PathContext::Expr, qself, path, shape)
|
rewrite_path(context, PathContext::Expr, qself, path, shape)
|
||||||
@ -625,7 +625,7 @@ pub(crate) fn rewrite_cond(
|
|||||||
shape: Shape,
|
shape: Shape,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
match expr.kind {
|
match expr.kind {
|
||||||
ast::ExprKind::Match(ref cond, _) => {
|
ast::ExprKind::Match(ref cond, _, MatchKind::Prefix) => {
|
||||||
// `match `cond` {`
|
// `match `cond` {`
|
||||||
let cond_shape = match context.config.indent_style() {
|
let cond_shape = match context.config.indent_style() {
|
||||||
IndentStyle::Visual => shape.shrink_left(6).and_then(|s| s.sub_width(2))?,
|
IndentStyle::Visual => shape.shrink_left(6).and_then(|s| s.sub_width(2))?,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use std::iter::repeat;
|
use std::iter::repeat;
|
||||||
|
|
||||||
use rustc_ast::{ast, ptr};
|
use rustc_ast::{ast, MatchKind, ptr};
|
||||||
use rustc_span::{BytePos, Span};
|
use rustc_span::{BytePos, Span};
|
||||||
|
|
||||||
use crate::comment::{combine_strs_with_missing_comments, rewrite_comment};
|
use crate::comment::{combine_strs_with_missing_comments, rewrite_comment};
|
||||||
@ -72,6 +72,8 @@ pub(crate) fn rewrite_match(
|
|||||||
shape: Shape,
|
shape: Shape,
|
||||||
span: Span,
|
span: Span,
|
||||||
attrs: &[ast::Attribute],
|
attrs: &[ast::Attribute],
|
||||||
|
// TODO: Use this
|
||||||
|
_: MatchKind,
|
||||||
) -> Option<String> {
|
) -> Option<String> {
|
||||||
// Do not take the rhs overhead from the upper expressions into account
|
// Do not take the rhs overhead from the upper expressions into account
|
||||||
// when rewriting match condition.
|
// when rewriting match condition.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user