diff options
| author | Michael Goulet <michael@errs.io> | 2023-10-13 08:58:33 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-10-13 08:59:36 +0000 |
| commit | b2d2184edea578109a48ec3d8decbee5948e8f35 (patch) | |
| tree | 84a351b1b08b838e0adcb1062ec04c344524e6c2 /compiler/rustc_builtin_macros/src/global_allocator.rs | |
| parent | 2763ca50da1192aa28295ef4dbe5d06443e1b90a (diff) | |
| download | rust-b2d2184edea578109a48ec3d8decbee5948e8f35.tar.gz rust-b2d2184edea578109a48ec3d8decbee5948e8f35.zip | |
Format all the let chains in compiler
Diffstat (limited to 'compiler/rustc_builtin_macros/src/global_allocator.rs')
| -rw-r--r-- | compiler/rustc_builtin_macros/src/global_allocator.rs | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/compiler/rustc_builtin_macros/src/global_allocator.rs b/compiler/rustc_builtin_macros/src/global_allocator.rs index 1bec00add55..33392edf060 100644 --- a/compiler/rustc_builtin_macros/src/global_allocator.rs +++ b/compiler/rustc_builtin_macros/src/global_allocator.rs @@ -24,20 +24,22 @@ pub fn expand( // Allow using `#[global_allocator]` on an item statement // FIXME - if we get deref patterns, use them to reduce duplication here - let (item, is_stmt, ty_span) = - if let Annotatable::Item(item) = &item - && let ItemKind::Static(box ast::StaticItem { ty, ..}) = &item.kind - { - (item, false, ecx.with_def_site_ctxt(ty.span)) - } else if let Annotatable::Stmt(stmt) = &item - && let StmtKind::Item(item) = &stmt.kind - && let ItemKind::Static(box ast::StaticItem { ty, ..}) = &item.kind - { - (item, true, ecx.with_def_site_ctxt(ty.span)) - } else { - ecx.sess.parse_sess.span_diagnostic.emit_err(errors::AllocMustStatics{span: item.span()}); - return vec![orig_item]; - }; + let (item, is_stmt, ty_span) = if let Annotatable::Item(item) = &item + && let ItemKind::Static(box ast::StaticItem { ty, .. }) = &item.kind + { + (item, false, ecx.with_def_site_ctxt(ty.span)) + } else if let Annotatable::Stmt(stmt) = &item + && let StmtKind::Item(item) = &stmt.kind + && let ItemKind::Static(box ast::StaticItem { ty, .. }) = &item.kind + { + (item, true, ecx.with_def_site_ctxt(ty.span)) + } else { + ecx.sess + .parse_sess + .span_diagnostic + .emit_err(errors::AllocMustStatics { span: item.span() }); + return vec![orig_item]; + }; // Generate a bunch of new items using the AllocFnFactory let span = ecx.with_def_site_ctxt(item.span); |
