Skip to content

Commit 535bbfb

Browse files
committed
Make Visitor::FnKind and MutVisitor::FnKind compatible
1 parent d03d338 commit 535bbfb

File tree

2 files changed

+7
-21
lines changed

2 files changed

+7
-21
lines changed

src/items.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3449,21 +3449,14 @@ impl Rewrite for ast::ForeignItem {
34493449
ref generics,
34503450
ref body,
34513451
} = **fn_kind;
3452-
if let Some(ref body) = body {
3452+
if body.is_some() {
34533453
let mut visitor = FmtVisitor::from_context(context);
34543454
visitor.block_indent = shape.indent;
34553455
visitor.last_pos = self.span.lo();
34563456
let inner_attrs = inner_attributes(&self.attrs);
34573457
let fn_ctxt = visit::FnCtxt::Foreign;
34583458
visitor.visit_fn(
3459-
visit::FnKind::Fn(
3460-
fn_ctxt,
3461-
self.ident,
3462-
sig,
3463-
&self.vis,
3464-
generics,
3465-
Some(body),
3466-
),
3459+
visit::FnKind::Fn(fn_ctxt, &self.ident, sig, &self.vis, generics, body),
34673460
&sig.decl,
34683461
self.span,
34693462
defaultness,

src/visitor.rs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
390390
block = b;
391391
self.rewrite_fn_before_block(
392392
indent,
393-
ident,
393+
*ident,
394394
&FnSig::from_fn_kind(&fk, fd, defaultness),
395395
mk_sp(s.lo(), b.span.lo()),
396396
)
@@ -540,21 +540,14 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
540540
ref generics,
541541
ref body,
542542
} = **fn_kind;
543-
if let Some(ref body) = body {
543+
if body.is_some() {
544544
let inner_attrs = inner_attributes(&item.attrs);
545545
let fn_ctxt = match sig.header.ext {
546546
ast::Extern::None => visit::FnCtxt::Free,
547547
_ => visit::FnCtxt::Foreign,
548548
};
549549
self.visit_fn(
550-
visit::FnKind::Fn(
551-
fn_ctxt,
552-
item.ident,
553-
sig,
554-
&item.vis,
555-
generics,
556-
Some(body),
557-
),
550+
visit::FnKind::Fn(fn_ctxt, &item.ident, sig, &item.vis, generics, body),
558551
&sig.decl,
559552
item.span,
560553
defaultness,
@@ -648,11 +641,11 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
648641
ref generics,
649642
ref body,
650643
} = **fn_kind;
651-
if let Some(ref body) = body {
644+
if body.is_some() {
652645
let inner_attrs = inner_attributes(&ai.attrs);
653646
let fn_ctxt = visit::FnCtxt::Assoc(assoc_ctxt);
654647
self.visit_fn(
655-
visit::FnKind::Fn(fn_ctxt, ai.ident, sig, &ai.vis, generics, Some(body)),
648+
visit::FnKind::Fn(fn_ctxt, &ai.ident, sig, &ai.vis, generics, body),
656649
&sig.decl,
657650
ai.span,
658651
defaultness,

0 commit comments

Comments
 (0)