Skip to content

Commit f19e826

Browse files
committed
Refactor FnKind variant to hold &Fn
1 parent 0c91d0c commit f19e826

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/items.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -333,19 +333,19 @@ impl<'a> FnSig<'a> {
333333
defaultness: ast::Defaultness,
334334
) -> FnSig<'a> {
335335
match *fn_kind {
336-
visit::FnKind::Fn(visit::FnCtxt::Assoc(..), _, fn_sig, vis, generics, _) => {
337-
let mut fn_sig = FnSig::from_method_sig(fn_sig, generics, vis);
336+
visit::FnKind::Fn(visit::FnCtxt::Assoc(..), _, vis, ast::Fn { sig, generics, .. }) => {
337+
let mut fn_sig = FnSig::from_method_sig(sig, generics, vis);
338338
fn_sig.defaultness = defaultness;
339339
fn_sig
340340
}
341-
visit::FnKind::Fn(_, _, fn_sig, vis, generics, _) => FnSig {
341+
visit::FnKind::Fn(_, _, vis, ast::Fn { sig, generics, .. }) => FnSig {
342342
decl,
343343
generics,
344-
ext: fn_sig.header.ext,
345-
constness: fn_sig.header.constness,
346-
coroutine_kind: Cow::Borrowed(&fn_sig.header.coroutine_kind),
344+
ext: sig.header.ext,
345+
constness: sig.header.constness,
346+
coroutine_kind: Cow::Borrowed(&sig.header.coroutine_kind),
347347
defaultness,
348-
safety: fn_sig.header.safety,
348+
safety: sig.header.safety,
349349
visibility: vis,
350350
},
351351
_ => unreachable!(),
@@ -3453,6 +3453,7 @@ impl Rewrite for ast::ForeignItem {
34533453
ref sig,
34543454
ref generics,
34553455
ref body,
3456+
..
34563457
} = **fn_kind;
34573458
if body.is_some() {
34583459
let mut visitor = FmtVisitor::from_context(context);
@@ -3461,7 +3462,7 @@ impl Rewrite for ast::ForeignItem {
34613462
let inner_attrs = inner_attributes(&self.attrs);
34623463
let fn_ctxt = visit::FnCtxt::Foreign;
34633464
visitor.visit_fn(
3464-
visit::FnKind::Fn(fn_ctxt, &self.ident, sig, &self.vis, generics, body),
3465+
visit::FnKind::Fn(fn_ctxt, &self.ident, &self.vis, fn_kind),
34653466
&sig.decl,
34663467
self.span,
34673468
defaultness,

src/visitor.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,14 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
386386
let indent = self.block_indent;
387387
let block;
388388
let rewrite = match fk {
389-
visit::FnKind::Fn(_, ident, _, _, _, Some(ref b)) => {
389+
visit::FnKind::Fn(
390+
_,
391+
ident,
392+
_,
393+
ast::Fn {
394+
body: Some(ref b), ..
395+
},
396+
) => {
390397
block = b;
391398
self.rewrite_fn_before_block(
392399
indent,
@@ -539,6 +546,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
539546
ref sig,
540547
ref generics,
541548
ref body,
549+
..
542550
} = **fn_kind;
543551
if body.is_some() {
544552
let inner_attrs = inner_attributes(&item.attrs);
@@ -547,7 +555,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
547555
_ => visit::FnCtxt::Foreign,
548556
};
549557
self.visit_fn(
550-
visit::FnKind::Fn(fn_ctxt, &item.ident, sig, &item.vis, generics, body),
558+
visit::FnKind::Fn(fn_ctxt, &item.ident, &item.vis, fn_kind),
551559
&sig.decl,
552560
item.span,
553561
defaultness,
@@ -640,12 +648,13 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
640648
ref sig,
641649
ref generics,
642650
ref body,
651+
..
643652
} = **fn_kind;
644653
if body.is_some() {
645654
let inner_attrs = inner_attributes(&ai.attrs);
646655
let fn_ctxt = visit::FnCtxt::Assoc(assoc_ctxt);
647656
self.visit_fn(
648-
visit::FnKind::Fn(fn_ctxt, &ai.ident, sig, &ai.vis, generics, body),
657+
visit::FnKind::Fn(fn_ctxt, &ai.ident, &ai.vis, fn_kind),
649658
&sig.decl,
650659
ai.span,
651660
defaultness,

0 commit comments

Comments
 (0)