Skip to content

Commit

Permalink
suppress internal error (#4069)
Browse files Browse the repository at this point in the history
  • Loading branch information
topecongiro authored Mar 31, 2020
2 parents ce159c1 + 8c400e9 commit dee282d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 13 additions & 2 deletions rustfmt-core/rustfmt-lib/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => {
self.visit_static(&StaticParts::from_item(item));
}
ast::ItemKind::Fn(ref fn_signature, ref generics, ref body) => {
ast::ItemKind::Fn(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,
Expand All @@ -514,7 +514,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
item.ident,
&fn_signature,
&item.vis,
body.as_deref(),
Some(body),
),
generics,
&fn_signature.decl,
Expand All @@ -523,6 +523,17 @@ 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 ty, ref generics) => match ty.kind.opaque_top_hack() {
None => {
let rewrite = rewrite_type_alias(
Expand Down
4 changes: 4 additions & 0 deletions rustfmt-core/rustfmt-lib/tests/target/issue-4068.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// following code is invalid but should not cause an internal error
fn main() {
extern "C" fn packet_records_options_impl_layout_length_encoding_option_len_multiplier();
}

0 comments on commit dee282d

Please sign in to comment.