Skip to content

Commit a4533eb

Browse files
refactor: reduce Option<P<Expr>> rewrite scope to PatKind::Range
1 parent 27f2120 commit a4533eb

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

rustfmt-core/rustfmt-lib/src/expr.rs

-11
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,6 @@ impl Rewrite for ast::Expr {
4242
}
4343
}
4444

45-
impl Rewrite for Option<ptr::P<ast::Expr>> {
46-
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
47-
match &self {
48-
None => Some("".to_owned()),
49-
Some(ref exp) => {
50-
exp.rewrite(context, shape)
51-
}
52-
}
53-
}
54-
}
55-
5645
#[derive(Copy, Clone, PartialEq)]
5746
pub(crate) enum ExprType {
5847
Statement,

rustfmt-core/rustfmt-lib/src/patterns.rs

+10
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,16 @@ impl Rewrite for Pat {
180180
}
181181
}
182182
PatKind::Range(ref lhs, ref rhs, ref end_kind) => {
183+
impl Rewrite for Option<ptr::P<ast::Expr>> {
184+
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
185+
match &self {
186+
None => Some("".to_owned()),
187+
Some(ref exp) => {
188+
exp.rewrite(context, shape)
189+
}
190+
}
191+
}
192+
}
183193
let infix = match end_kind.node {
184194
RangeEnd::Included(RangeSyntax::DotDotDot) => "...",
185195
RangeEnd::Included(RangeSyntax::DotDotEq) => "..=",

0 commit comments

Comments
 (0)