From 6ec0ff046cd1307fcd549ccf0c3da0bf04e460de Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Sat, 6 Feb 2021 15:12:38 -0600 Subject: [PATCH 1/3] deps: bump rustc-ap crates to v705 --- Cargo.lock | 80 +++++++++++++++++++++++++++--------------------------- Cargo.toml | 16 +++++------ 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 34d97765a55..2c8cfaae04e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -735,18 +735,18 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_arena" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b4ef3cb8e2471ed0beee8fa7dec927e5a04671605b606b5d650cedaeabcfd5" +checksum = "93575affa286089b92c8208aea4e60fe9fdd251a619a09b566d6e4e2cc123212" dependencies = [ "smallvec", ] [[package]] name = "rustc-ap-rustc_ast" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e60ae0420757f5e8304a36e9ee61848b3cdeab702e2cc91e275fa71194fac9" +checksum = "4c700f2d3b25aa8d6446dd2936048737b08b2d547bd86e2a70afa9fee4e9c522" dependencies = [ "bitflags", "rustc-ap-rustc_data_structures", @@ -761,9 +761,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_ast_passes" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cf00c1a5076bb0daccf5f865d30959fdb3a9fde8207ed0ea5449f4b4057164c" +checksum = "8e01f63e5259ee397bbe2e395d34a2e6b6b24f10c184d30fbbee1dcd7117f4f3" dependencies = [ "itertools 0.9.0", "rustc-ap-rustc_ast", @@ -780,9 +780,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_ast_pretty" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c615111df0b80d1ec7fa1ddbc099cf1b5b885498c3ddeef6a455f456bef6aa60" +checksum = "99d644c69c55deb24257cb0cb5261265fe5134f6f545e9062e1c18b07e422c68" dependencies = [ "rustc-ap-rustc_ast", "rustc-ap-rustc_span", @@ -791,9 +791,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_attr" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f850527d664ae13183e72abda9ad7bfb783ad3cd3511c7b5748ad4940bfcd5ec" +checksum = "797fc68816d5396870f04e03d35164f5275d2502403239d4caec7ce063683f41" dependencies = [ "rustc-ap-rustc_ast", "rustc-ap-rustc_ast_pretty", @@ -809,9 +809,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_data_structures" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4f0f2d7b238d9de2bcdd365e765d61309d71bcfa1a9619e22a61bc3916310a7" +checksum = "5d840c4e6198b57982a54543ae604d634c7ceb7107f0c75970b88ebaff077ac5" dependencies = [ "arrayvec", "bitflags", @@ -840,9 +840,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_errors" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c681cea52a193059f6a2d4d1d9d5a49af6d417a7d87c654c78acf34e8eb1d9d2" +checksum = "2f2f99bdc828ad417636d9016611dc9047b641fadcb7f533b8b0e9616d81f90b" dependencies = [ "annotate-snippets", "atty", @@ -860,9 +860,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_expand" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "499640dd6837b8a5bb7d2f33f69aa74ba4e5fb944e552e38f09864287477ab3b" +checksum = "27008b4c7ded287bf5cb20b84d6d5a6566329140f2e2bc8f6e68b37a34898595" dependencies = [ "rustc-ap-rustc_ast", "rustc-ap-rustc_ast_passes", @@ -884,9 +884,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_feature" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8199d34846af059ff2e387934916277fdffbed92fbbcd693df4179d4f2c51e76" +checksum = "6bb47b53670f1263ed1389dda932d5b5a6daf98579c1f076c2ee7d7f22709b7c" dependencies = [ "rustc-ap-rustc_data_structures", "rustc-ap-rustc_span", @@ -894,21 +894,21 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_fs_util" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce35d2a03e56e6a01f00d8e33b760363f05085859f0340d5caa39823f8cd9a44" +checksum = "cdaddc4bae5ffab17037553e172f5014686db600050429aaa60aec14fe780e84" [[package]] name = "rustc-ap-rustc_graphviz" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9626d1928e8639fe327cdfa3a4b6696de9c84ac04dd8f1d010879dba4524a8d6" +checksum = "3d73c72543311e88786f7380a3bfd946395579c1a0c0441a879a97fcdea79130" [[package]] name = "rustc-ap-rustc_index" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "364c76daf3da8ea105daaea6a92fed6ad89a9366267f4828d1406fc39a65745b" +checksum = "bba8d74ed4bad44a5b4264cf2a51ad0bd458ed56caa5bb090e989b8002ec6327" dependencies = [ "arrayvec", "rustc-ap-rustc_macros", @@ -917,18 +917,18 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_lexer" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47cfdb02425aed8c56f85692975d262cb438ea0388e0c8cd254e73bd22bb6539" +checksum = "3a030d00510966cd31e13dca5e6c1bd40d303a932c54eca40e854188bca8c49e" dependencies = [ "unicode-xid", ] [[package]] name = "rustc-ap-rustc_lint_defs" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "158d326d78e86105c934dd9bdc1fd7afcf21f41a51acb065ac7e1ecbb4663788" +checksum = "bdff95da1b5d979183ef5c285817ba6cc67a1ac11296ef1e87b1b5bbaf57213c" dependencies = [ "rustc-ap-rustc_ast", "rustc-ap-rustc_data_structures", @@ -941,9 +941,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_macros" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a16139dc0677c0417bd969dc816e820f348b1a5f8d6663c7ab0b4c526c3427d" +checksum = "fe3ed7401bf6f5a256d58cd0e1c1e2e77eec25e60a0d7ad75313962edcb4e396" dependencies = [ "proc-macro2", "quote", @@ -953,9 +953,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_parse" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b917704d699b6e5f4e9d35fcb25c8443e3229c4a3e11f4f347fbe7a964dfdbac" +checksum = "609a624baffa3f99847d57d30c96ee6732ce0912f8df4be239b6fd91533910d6" dependencies = [ "bitflags", "rustc-ap-rustc_ast", @@ -973,9 +973,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_serialize" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55b6bfa271ab3778a33d3dc9c1655d6aec7bdd02d327dd80f0fb05199801a2f9" +checksum = "bc232e2a351d8131c8f1386ce372ee22ef7b1b0b897bbf817a8ce4792029a564" dependencies = [ "indexmap", "smallvec", @@ -983,9 +983,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_session" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d8bcdbf64ccca1c93ce4c1b186d680fab897d936755c1c46108335066a4b3df" +checksum = "18acf94c820cd0c64ee1cbd811fd1f4d5ba18987c457c88771359b90cb1a12f5" dependencies = [ "bitflags", "getopts", @@ -1005,9 +1005,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_span" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c255026e999472912f5104881672003623537d5ce675d591fba38632a8b59d" +checksum = "d3479f453a38b6a5572938d035fc2b3cb6ec379c57f598b8682b512eb90c7858" dependencies = [ "cfg-if 0.1.10", "md-5", @@ -1025,9 +1025,9 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_target" -version = "702.0.0" +version = "705.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d3def54a9c21135316cb84aca7c99439b60864e6ac72ba27934473e95d6787c" +checksum = "78cacaf829778cf07bb97a9f4604896789de12392175f3743e74a30ed370f1c1" dependencies = [ "bitflags", "rustc-ap-rustc_data_structures", diff --git a/Cargo.toml b/Cargo.toml index 9e9910ebe8b..8e0efa81b6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,32 +107,32 @@ lazy_static = "1.0.0" [dependencies.rustc_ast] package = "rustc-ap-rustc_ast" -version = "702.0.0" +version = "705.0.0" [dependencies.rustc_ast_pretty] package = "rustc-ap-rustc_ast_pretty" -version = "702.0.0" +version = "705.0.0" [dependencies.rustc_data_structures] package = "rustc-ap-rustc_data_structures" -version = "702.0.0" +version = "705.0.0" [dependencies.rustc_errors] package = "rustc-ap-rustc_errors" -version = "702.0.0" +version = "705.0.0" [dependencies.rustc_expand] package = "rustc-ap-rustc_expand" -version = "702.0.0" +version = "705.0.0" [dependencies.rustc_parse] package = "rustc-ap-rustc_parse" -version = "702.0.0" +version = "705.0.0" [dependencies.rustc_session] package = "rustc-ap-rustc_session" -version = "702.0.0" +version = "705.0.0" [dependencies.rustc_span] package = "rustc-ap-rustc_span" -version = "702.0.0" +version = "705.0.0" From 5f3271f5d690efb3bb5ec4a34ae48bb5819270fe Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Sat, 6 Feb 2021 15:13:14 -0600 Subject: [PATCH 2/3] deps: apply rustc-ap v705 changes to itemkind variants --- src/formatting/items.rs | 140 +++++++++++++-------------- src/formatting/visitor.rs | 198 +++++++++++++++++++++----------------- 2 files changed, 177 insertions(+), 161 deletions(-) diff --git a/src/formatting/items.rs b/src/formatting/items.rs index fbe1ecfe032..b818732d23e 100644 --- a/src/formatting/items.rs +++ b/src/formatting/items.rs @@ -712,8 +712,8 @@ impl<'a> FmtVisitor<'a> { use ast::AssocItemKind::*; fn need_empty_line(a: &ast::AssocItemKind, b: &ast::AssocItemKind) -> bool { match (a, b) { - (TyAlias(_, _, _, ref lty), TyAlias(_, _, _, ref rty)) - if both_type(lty, rty) || both_opaque(lty, rty) => + (TyAlias(lty), TyAlias(rty)) + if both_type(<y.3, &rty.3) || both_opaque(<y.3, &rty.3) => { false } @@ -723,8 +723,8 @@ impl<'a> FmtVisitor<'a> { } buffer.sort_by(|(_, a), (_, b)| match (&a.kind, &b.kind) { - (TyAlias(_, _, _, ref lty), TyAlias(_, _, _, ref rty)) - if both_type(lty, rty) || both_opaque(lty, rty) => + (TyAlias(lty), TyAlias(rty)) + if both_type(<y.3, &rty.3) || both_opaque(<y.3, &rty.3) => { compare_as_versions(&a.ident.as_str(), &b.ident.as_str()) } @@ -732,8 +732,8 @@ impl<'a> FmtVisitor<'a> { compare_as_versions(&a.ident.as_str(), &b.ident.as_str()) } (Fn(..), Fn(..)) => a.span.lo().cmp(&b.span.lo()), - (TyAlias(_, _, _, ref ty), _) if is_type(ty) => Ordering::Less, - (_, TyAlias(_, _, _, ref ty)) if is_type(ty) => Ordering::Greater, + (TyAlias(ty), _) if is_type(&ty.3) => Ordering::Less, + (_, TyAlias(ty)) if is_type(&ty.3) => Ordering::Greater, (TyAlias(..), _) => Ordering::Less, (_, TyAlias(..)) => Ordering::Greater, (Const(..), _) => Ordering::Less, @@ -769,13 +769,13 @@ pub(crate) fn format_impl( item: &ast::Item, offset: Indent, ) -> Option { - if let ast::ItemKind::Impl { - ref generics, - ref self_ty, - ref items, - .. - } = item.kind - { + if let ast::ItemKind::Impl(impl_kind) = &item.kind { + let ast::ImplKind { + ref generics, + ref self_ty, + ref items, + .. + } = **impl_kind; let mut result = String::with_capacity(128); let ref_and_type = format_impl_ref_and_type(context, item, offset)?; let sep = offset.to_string_with_newline(context.config); @@ -931,17 +931,17 @@ fn format_impl_ref_and_type( item: &ast::Item, offset: Indent, ) -> Option { - if let ast::ItemKind::Impl { - unsafety, - polarity, - defaultness, - constness, - ref generics, - of_trait: ref trait_ref, - ref self_ty, - .. - } = item.kind - { + if let ast::ItemKind::Impl(impl_kind) = &item.kind { + let ast::ImplKind { + unsafety, + polarity, + defaultness, + constness, + ref generics, + of_trait: ref trait_ref, + ref self_ty, + .. + } = **impl_kind; let mut result = String::with_capacity(128); result.push_str(&format_visibility(context, &item.vis)); @@ -1119,14 +1119,9 @@ pub(crate) fn format_trait( item: &ast::Item, offset: Indent, ) -> Option { - if let ast::ItemKind::Trait( - is_auto, - unsafety, - ref generics, - ref generic_bounds, - ref trait_items, - ) = item.kind - { + if let ast::ItemKind::Trait(trait_kind) = &item.kind { + let ast::TraitKind(is_auto, unsafety, ref generics, ref generic_bounds, ref trait_items) = + **trait_kind; let mut result = String::with_capacity(128); let header = format!( "{}{}{}trait ", @@ -3256,31 +3251,35 @@ impl Rewrite for ast::ForeignItem { let span = mk_sp(self.span.lo(), self.span.hi() - BytePos(1)); let item_str = match self.kind { - ast::ForeignItemKind::Fn(defaultness, ref fn_sig, ref generics, Some(ref body)) => { - let mut visitor = FmtVisitor::from_context(context); - visitor.block_indent = shape.indent; - visitor.last_pos = self.span.lo(); - let inner_attrs = inner_attributes(&self.attrs); - let fn_ctxt = visit::FnCtxt::Foreign; - visitor.visit_fn( - visit::FnKind::Fn(fn_ctxt, self.ident, &fn_sig, &self.vis, Some(body)), - generics, - &fn_sig.decl, - self.span, - defaultness, - Some(&inner_attrs), - ); - Some(visitor.buffer.to_owned()) + ast::ForeignItemKind::Fn(ref fn_kind) => { + let ast::FnKind(defaultness, ref fn_sig, ref generics, ref block) = **fn_kind; + if let Some(ref body) = block { + let mut visitor = FmtVisitor::from_context(context); + visitor.block_indent = shape.indent; + visitor.last_pos = self.span.lo(); + let inner_attrs = inner_attributes(&self.attrs); + let fn_ctxt = visit::FnCtxt::Foreign; + visitor.visit_fn( + visit::FnKind::Fn(fn_ctxt, self.ident, &fn_sig, &self.vis, Some(body)), + generics, + &fn_sig.decl, + self.span, + defaultness, + Some(&inner_attrs), + ); + Some(visitor.buffer.to_owned()) + } else { + rewrite_fn_base( + context, + shape.indent, + self.ident, + &FnSig::from_method_sig(&fn_sig, generics, self.vis.clone()), + span, + FnBraceStyle::None, + ) + .map(|(s, _, _)| format!("{};", s)) + } } - ast::ForeignItemKind::Fn(_, ref fn_sig, ref generics, None) => rewrite_fn_base( - context, - shape.indent, - self.ident, - &FnSig::from_method_sig(&fn_sig, generics, self.vis.clone()), - span, - FnBraceStyle::None, - ) - .map(|(s, _, _)| format!("{};", s)), ast::ForeignItemKind::Static(ref ty, mutability, _) => { // FIXME(#21): we're dropping potential comments in between the // function kw here. @@ -3295,21 +3294,20 @@ impl Rewrite for ast::ForeignItem { // 1 = ; rewrite_assign_rhs(context, prefix, &**ty, shape.sub_width(1)?).map(|s| s + ";") } - ast::ForeignItemKind::TyAlias( - _, - ref generics, - ref generic_bounds, - ref type_default, - ) => rewrite_type_alias( - self.ident, - type_default.as_ref(), - generics, - Some(generic_bounds), - &context, - shape.indent, - &self.vis, - self.span, - ), + ast::ForeignItemKind::TyAlias(ref ty_alias_kind) => { + let ast::TyAliasKind(_, ref generics, ref generic_bounds, ref type_default) = + **ty_alias_kind; + rewrite_type_alias( + self.ident, + type_default.as_ref(), + generics, + Some(generic_bounds), + &context, + shape.indent, + &self.vis, + self.span, + ) + } ast::ForeignItemKind::MacCall(ref mac) => { rewrite_macro(mac, None, context, shape, MacroPosition::Item) } diff --git a/src/formatting/visitor.rs b/src/formatting/visitor.rs index 40ecfd5b865..2a0af48c84a 100644 --- a/src/formatting/visitor.rs +++ b/src/formatting/visitor.rs @@ -523,6 +523,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { } }; + // TODO(calebcartwright): consider enabling box_patterns feature gate if should_visit_node_again { match item.kind { ast::ItemKind::Use(ref tree) => self.format_import(item, tree), @@ -580,65 +581,72 @@ 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, Some(ref body)) => { - let inner_attrs = inner_attributes(&item.attrs); - let fn_ctxt = match fn_signature.header.ext { - ast::Extern::None => visit::FnCtxt::Free, - _ => visit::FnCtxt::Foreign, - }; - self.visit_fn( - visit::FnKind::Fn( - fn_ctxt, - item.ident, - &fn_signature, - &item.vis, - Some(body), - ), - generics, - &fn_signature.decl, - item.span, - defaultness, - 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( - item.ident, - Some(&*ty), + ast::ItemKind::Fn(ref fn_kind) => { + let ast::FnKind(defaultness, ref fn_signature, ref generics, ref block) = + **fn_kind; + if let Some(ref body) = block { + let inner_attrs = inner_attributes(&item.attrs); + let fn_ctxt = match fn_signature.header.ext { + ast::Extern::None => visit::FnCtxt::Free, + _ => visit::FnCtxt::Foreign, + }; + self.visit_fn( + visit::FnKind::Fn( + fn_ctxt, + item.ident, + &fn_signature, + &item.vis, + Some(body), + ), generics, - Some(generic_bounds), - &self.get_context(), - self.block_indent, - &item.vis, + &fn_signature.decl, item.span, - ); - self.push_rewrite(item.span, rewrite); - } - None => { - let rewrite = rewrite_opaque_type( - &self.get_context(), - self.block_indent, + defaultness, + Some(&inner_attrs), + ) + } else { + let indent = self.block_indent; + let rewrite = self.rewrite_required_fn( + indent, item.ident, - generic_bounds, + &fn_signature, generics, - &item.vis, item.span, ); self.push_rewrite(item.span, rewrite); } - }, + } + ast::ItemKind::TyAlias(ref alias_kind) => { + let ast::TyAliasKind(_, ref generics, ref generic_bounds, ref ty) = + **alias_kind; + match ty { + Some(ty) => { + let rewrite = rewrite_type_alias( + item.ident, + Some(&*ty), + generics, + Some(generic_bounds), + &self.get_context(), + self.block_indent, + &item.vis, + item.span, + ); + self.push_rewrite(item.span, rewrite); + } + None => { + let rewrite = rewrite_opaque_type( + &self.get_context(), + self.block_indent, + item.ident, + generic_bounds, + generics, + &item.vis, + item.span, + ); + self.push_rewrite(item.span, rewrite); + } + } + } ast::ItemKind::GlobalAsm(..) => { let snippet = Some(self.snippet(item.span).to_owned()); self.push_rewrite(item.span, snippet); @@ -670,31 +678,37 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { let skip_context_outer = self.skip_context.clone(); self.skip_context.update_with_attrs(&ti.attrs); + // TODO(calebcartwright): consider enabling box_patterns feature gate match ti.kind { ast::AssocItemKind::Const(..) => self.visit_static(&StaticParts::from_trait_item(ti)), - ast::AssocItemKind::Fn(_, ref sig, ref generics, None) => { - let indent = self.block_indent; - let rewrite = self.rewrite_required_fn(indent, ti.ident, sig, generics, ti.span); - self.push_rewrite(ti.span, rewrite); - } - ast::AssocItemKind::Fn(defaultness, ref sig, ref generics, Some(ref body)) => { - let inner_attrs = inner_attributes(&ti.attrs); - let vis = ast::Visibility { - kind: ast::VisibilityKind::Inherited, - span: DUMMY_SP, - tokens: None, - }; - let fn_ctxt = visit::FnCtxt::Assoc(visit::AssocCtxt::Trait); - self.visit_fn( - visit::FnKind::Fn(fn_ctxt, ti.ident, sig, &vis, Some(body)), - generics, - &sig.decl, - ti.span, - defaultness, - Some(&inner_attrs), - ); + ast::AssocItemKind::Fn(ref fn_kind) => { + let ast::FnKind(defaultness, ref sig, ref generics, ref block) = **fn_kind; + if let Some(ref body) = block { + let inner_attrs = inner_attributes(&ti.attrs); + let vis = ast::Visibility { + kind: ast::VisibilityKind::Inherited, + span: DUMMY_SP, + tokens: None, + }; + let fn_ctxt = visit::FnCtxt::Assoc(visit::AssocCtxt::Trait); + self.visit_fn( + visit::FnKind::Fn(fn_ctxt, ti.ident, sig, &vis, Some(body)), + generics, + &sig.decl, + ti.span, + defaultness, + Some(&inner_attrs), + ); + } else { + let indent = self.block_indent; + let rewrite = + self.rewrite_required_fn(indent, ti.ident, sig, generics, ti.span); + self.push_rewrite(ti.span, rewrite); + } } - ast::AssocItemKind::TyAlias(_, ref generics, ref generic_bounds, ref type_default) => { + ast::AssocItemKind::TyAlias(ref ty_alias_kind) => { + let ast::TyAliasKind(_, ref generics, ref generic_bounds, ref type_default) = + **ty_alias_kind; let rewrite = rewrite_type_alias( ti.ident, type_default.as_ref(), @@ -725,25 +739,29 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { self.skip_context.update_with_attrs(&ii.attrs); match ii.kind { - ast::AssocItemKind::Fn(defaultness, ref sig, ref generics, Some(ref body)) => { - let inner_attrs = inner_attributes(&ii.attrs); - let fn_ctxt = visit::FnCtxt::Assoc(visit::AssocCtxt::Impl); - self.visit_fn( - visit::FnKind::Fn(fn_ctxt, ii.ident, sig, &ii.vis, Some(body)), - generics, - &sig.decl, - ii.span, - defaultness, - Some(&inner_attrs), - ); - } - ast::AssocItemKind::Fn(_, ref sig, ref generics, None) => { - let indent = self.block_indent; - let rewrite = self.rewrite_required_fn(indent, ii.ident, sig, generics, ii.span); - self.push_rewrite(ii.span, rewrite); + ast::AssocItemKind::Fn(ref fn_kind) => { + let ast::FnKind(defaultness, ref sig, ref generics, ref block) = **fn_kind; + if let Some(ref body) = block { + let inner_attrs = inner_attributes(&ii.attrs); + let fn_ctxt = visit::FnCtxt::Assoc(visit::AssocCtxt::Impl); + self.visit_fn( + visit::FnKind::Fn(fn_ctxt, ii.ident, sig, &ii.vis, Some(body)), + generics, + &sig.decl, + ii.span, + defaultness, + Some(&inner_attrs), + ); + } else { + let indent = self.block_indent; + let rewrite = + self.rewrite_required_fn(indent, ii.ident, sig, generics, ii.span); + self.push_rewrite(ii.span, rewrite); + } } ast::AssocItemKind::Const(..) => self.visit_static(&StaticParts::from_impl_item(ii)), - ast::AssocItemKind::TyAlias(defaultness, ref generics, _, ref ty) => { + ast::AssocItemKind::TyAlias(ref ty_alias_kind) => { + let ast::TyAliasKind(defaultness, ref generics, _, ref ty) = **ty_alias_kind; let rewrite_associated = || { rewrite_associated_impl_type( ii.ident, From 69379a7893a12fa7674334c606279d14f95f7199 Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Sat, 6 Feb 2021 15:25:23 -0600 Subject: [PATCH 3/3] chore: bump rust toolchain version --- rust-toolchain | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain b/rust-toolchain index edd49109a62..09ed3829370 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2021-02-03 +nightly-2021-02-06