mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 10:45:18 +00:00
Support ..=
syntax
This commit is contained in:
parent
2f81933272
commit
28860000fe
@ -232,7 +232,7 @@ pub fn format_expr(
|
||||
ast::ExprKind::Range(ref lhs, ref rhs, limits) => {
|
||||
let delim = match limits {
|
||||
ast::RangeLimits::HalfOpen => "..",
|
||||
ast::RangeLimits::Closed => "...",
|
||||
ast::RangeLimits::Closed => "..=",
|
||||
};
|
||||
|
||||
fn needs_space_before_range(context: &RewriteContext, lhs: &ast::Expr) -> bool {
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use syntax::ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd};
|
||||
use syntax::ast::{self, BindingMode, FieldPat, Pat, PatKind, RangeEnd, RangeSyntax};
|
||||
use syntax::codemap::{self, BytePos, Span};
|
||||
use syntax::ptr;
|
||||
|
||||
@ -58,31 +58,23 @@ impl Rewrite for Pat {
|
||||
} else {
|
||||
None
|
||||
},
|
||||
PatKind::Range(ref lhs, ref rhs, ref end_kind) => match *end_kind {
|
||||
RangeEnd::Excluded => rewrite_pair(
|
||||
PatKind::Range(ref lhs, ref rhs, ref end_kind) => {
|
||||
let infix = match *end_kind {
|
||||
RangeEnd::Included(RangeSyntax::DotDotDot) => "...",
|
||||
RangeEnd::Included(RangeSyntax::DotDotEq) => "..=",
|
||||
RangeEnd::Excluded => "..",
|
||||
};
|
||||
rewrite_pair(
|
||||
&**lhs,
|
||||
&**rhs,
|
||||
"",
|
||||
"..",
|
||||
infix,
|
||||
"",
|
||||
context,
|
||||
shape,
|
||||
SeparatorPlace::Front,
|
||||
),
|
||||
// FIXME: Change _ to RangeEnd::Included(RangeSyntax::DotDotDot)
|
||||
// and add RangeEnd::Included(RangeSyntax::DotDotEq)
|
||||
// once rust PR #44709 gets merged
|
||||
_ => rewrite_pair(
|
||||
&**lhs,
|
||||
&**rhs,
|
||||
"",
|
||||
"...",
|
||||
"",
|
||||
context,
|
||||
shape,
|
||||
SeparatorPlace::Front,
|
||||
),
|
||||
},
|
||||
)
|
||||
}
|
||||
PatKind::Ref(ref pat, mutability) => {
|
||||
let prefix = format!("&{}", format_mutability(mutability));
|
||||
rewrite_unary_prefix(context, &prefix, &**pat, shape)
|
||||
|
Loading…
Reference in New Issue
Block a user