@@ -556,23 +556,23 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
556556 self . skip_context = skip_context_saved;
557557 }
558558
559- pub ( crate ) fn visit_trait_item ( & mut self , ti : & ast:: TraitItem ) {
559+ pub ( crate ) fn visit_trait_item ( & mut self , ti : & ast:: AssocItem ) {
560560 skip_out_of_file_lines_range_visitor ! ( self , ti. span) ;
561561
562562 if self . visit_attrs ( & ti. attrs , ast:: AttrStyle :: Outer ) {
563- self . push_skipped_with_span ( ti. attrs . as_slice ( ) , ti. span ( ) , ti. span ( ) ) ;
563+ self . push_skipped_with_span ( ti. attrs . as_slice ( ) , ti. span , ti. span ) ;
564564 return ;
565565 }
566566
567567 match ti. kind {
568- ast:: TraitItemKind :: Const ( ..) => self . visit_static ( & StaticParts :: from_trait_item ( ti) ) ,
569- ast:: TraitItemKind :: Method ( ref sig, None ) => {
568+ ast:: AssocItemKind :: Const ( ..) => self . visit_static ( & StaticParts :: from_trait_item ( ti) ) ,
569+ ast:: AssocItemKind :: Fn ( ref sig, None ) => {
570570 let indent = self . block_indent ;
571571 let rewrite =
572572 self . rewrite_required_fn ( indent, ti. ident , sig, & ti. generics , ti. span ) ;
573573 self . push_rewrite ( ti. span , rewrite) ;
574574 }
575- ast:: TraitItemKind :: Method ( ref sig, Some ( ref body) ) => {
575+ ast:: AssocItemKind :: Fn ( ref sig, Some ( ref body) ) => {
576576 let inner_attrs = inner_attributes ( & ti. attrs ) ;
577577 self . visit_fn (
578578 visit:: FnKind :: Method ( ti. ident , sig, None , body) ,
@@ -583,7 +583,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
583583 Some ( & inner_attrs) ,
584584 ) ;
585585 }
586- ast:: TraitItemKind :: Type ( ref generic_bounds, ref type_default) => {
586+ ast:: AssocItemKind :: TyAlias ( ref generic_bounds, ref type_default) => {
587587 let rewrite = rewrite_associated_type (
588588 ti. ident ,
589589 type_default. as_ref ( ) ,
@@ -594,55 +594,62 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
594594 ) ;
595595 self . push_rewrite ( ti. span , rewrite) ;
596596 }
597- ast:: TraitItemKind :: Macro ( ref mac) => {
597+ ast:: AssocItemKind :: Macro ( ref mac) => {
598598 self . visit_mac ( mac, Some ( ti. ident ) , MacroPosition :: Item ) ;
599599 }
600600 }
601601 }
602602
603- pub ( crate ) fn visit_impl_item ( & mut self , ii : & ast:: ImplItem ) {
603+ pub ( crate ) fn visit_impl_item ( & mut self , ii : & ast:: AssocItem ) {
604604 skip_out_of_file_lines_range_visitor ! ( self , ii. span) ;
605605
606606 if self . visit_attrs ( & ii. attrs , ast:: AttrStyle :: Outer ) {
607- self . push_skipped_with_span ( ii. attrs . as_slice ( ) , ii. span ( ) , ii. span ( ) ) ;
607+ self . push_skipped_with_span ( ii. attrs . as_slice ( ) , ii. span , ii. span ) ;
608608 return ;
609609 }
610610
611611 match ii. kind {
612- ast:: ImplItemKind :: Method ( ref sig, ref body) => {
612+ ast:: AssocItemKind :: Fn ( ref sig, Some ( ref body) ) => {
613613 let inner_attrs = inner_attributes ( & ii. attrs ) ;
614614 self . visit_fn (
615- visit:: FnKind :: Method ( ii. ident , sig, Some ( & ii. vis ) , body) ,
615+ visit:: FnKind :: Fn ( ii. ident , sig, Some ( & ii. vis ) , body) ,
616616 & ii. generics ,
617617 & sig. decl ,
618618 ii. span ,
619619 ii. defaultness ,
620620 Some ( & inner_attrs) ,
621621 ) ;
622622 }
623- ast:: ImplItemKind :: Const ( ..) => self . visit_static ( & StaticParts :: from_impl_item ( ii) ) ,
624- ast:: ImplItemKind :: TyAlias ( ref ty) => {
625- let rewrite = rewrite_associated_impl_type (
626- ii. ident ,
627- ii. defaultness ,
628- Some ( ty) ,
629- & ii. generics ,
630- & self . get_context ( ) ,
631- self . block_indent ,
632- ) ;
633- self . push_rewrite ( ii. span , rewrite) ;
634- }
635- ast:: ImplItemKind :: OpaqueTy ( ref generic_bounds) => {
636- let rewrite = rewrite_opaque_impl_type (
637- & self . get_context ( ) ,
638- ii. ident ,
639- & ii. generics ,
640- generic_bounds,
641- self . block_indent ,
642- ) ;
623+ ast:: AssocItemKind :: Const ( ..) => self . visit_static ( & StaticParts :: from_impl_item ( ii) ) ,
624+ ast:: AssocItemKind :: TyAlias ( ref generic_bounds, ref ty) => {
625+ let rewrite_associated = || {
626+ rewrite_associated_impl_type (
627+ ii. ident ,
628+ ii. defaultness ,
629+ ty. as_ref ( ) ,
630+ & ii. generics ,
631+ & self . get_context ( ) ,
632+ self . block_indent ,
633+ )
634+ } ;
635+ let rewrite = match ty {
636+ None => rewrite_associated ( ) ,
637+ Some ( ty) => match ty. kind . opaque_top_hack ( ) {
638+ Some ( _) => {
639+ rewrite_opaque_impl_type (
640+ & self . get_context ( ) ,
641+ ii. ident ,
642+ & ii. generics ,
643+ generic_bounds,
644+ self . block_indent ,
645+ )
646+ } ,
647+ None => rewrite_associated ( )
648+ }
649+ } ;
643650 self . push_rewrite ( ii. span , rewrite) ;
644651 }
645- ast:: ImplItemKind :: Macro ( ref mac) => {
652+ ast:: AssocItemKind :: Macro ( ref mac) => {
646653 self . visit_mac ( mac, Some ( ii. ident ) , MacroPosition :: Item ) ;
647654 }
648655 }
0 commit comments