about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorCaleb Cartwright <caleb.cartwright@outlook.com>2020-03-27 22:13:46 -0500
committerCaleb Cartwright <caleb.cartwright@outlook.com>2020-03-27 22:13:46 -0500
commitc1a66e1e223db7687c28359d95f7a218283b796f (patch)
tree215c9a32a657fa0d20b5546f3787cf3de1b655b9 /src
parent537d746e08dc7feda17e07a3cf4442837aec0030 (diff)
fix: unreachable err on Fn with `None` block
Diffstat (limited to 'src')
-rw-r--r--src/visitor.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/visitor.rs b/src/visitor.rs
index 7dd594a304f..593e3ac6a21 100644
--- a/src/visitor.rs
+++ b/src/visitor.rs
@@ -514,7 +514,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
                 ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => {
                     self.visit_static(&StaticParts::from_item(item));
                 }
-                ast::ItemKind::Fn(defaultness, ref fn_signature, ref generics, ref body) => {
+                ast::ItemKind::Fn(defaultness, ref fn_signature, ref generics, Some(ref body)) => {
                     let inner_attrs = inner_attributes(&item.attrs);
                     let fn_ctxt = match fn_signature.header.ext {
                         ast::Extern::None => visit::FnCtxt::Free,
@@ -526,7 +526,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
                             item.ident,
                             &fn_signature,
                             &item.vis,
-                            body.as_deref(),
+                            Some(body),
                         ),
                         generics,
                         &fn_signature.decl,
@@ -535,6 +535,18 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
                         Some(&inner_attrs),
                     )
                 }
+                ast::ItemKind::Fn(_, ref fn_signature, ref generics, None) => {
+                    let indent = self.block_indent;
+                    let rewrite = self.rewrite_required_fn(
+                        indent,
+                        item.ident,
+                        &fn_signature,
+                        generics,
+                        item.span,
+                    );
+
+                    self.push_rewrite(item.span, rewrite);
+                }
                 ast::ItemKind::TyAlias(_, ref generics, ref generic_bounds, ref ty) => match ty {
                     Some(ty) => {
                         let rewrite = rewrite_type_alias(