@@ -618,8 +618,8 @@ impl<'a> FmtVisitor<'a> {
618
618
use crate :: ast:: AssocItemKind :: * ;
619
619
fn need_empty_line ( a : & ast:: AssocItemKind , b : & ast:: AssocItemKind ) -> bool {
620
620
match ( a, b) {
621
- ( TyAlias ( _ , _ , _ , ref lty) , TyAlias ( _ , _ , _ , ref rty) )
622
- if both_type ( lty, rty) || both_opaque ( lty, rty) =>
621
+ ( TyAlias ( lty) , TyAlias ( rty) )
622
+ if both_type ( & lty. 3 , & rty. 3 ) || both_opaque ( & lty. 3 , & rty. 3 ) =>
623
623
{
624
624
false
625
625
}
@@ -629,17 +629,17 @@ impl<'a> FmtVisitor<'a> {
629
629
}
630
630
631
631
buffer. sort_by ( |( _, a) , ( _, b) | match ( & a. kind , & b. kind ) {
632
- ( TyAlias ( _ , _ , _ , ref lty) , TyAlias ( _ , _ , _ , ref rty) )
633
- if both_type ( lty, rty) || both_opaque ( lty, rty) =>
632
+ ( TyAlias ( lty) , TyAlias ( rty) )
633
+ if both_type ( & lty. 3 , & rty. 3 ) || both_opaque ( & lty. 3 , & rty. 3 ) =>
634
634
{
635
635
a. ident . as_str ( ) . cmp ( & b. ident . as_str ( ) )
636
636
}
637
637
( Const ( ..) , Const ( ..) ) | ( MacCall ( ..) , MacCall ( ..) ) => {
638
638
a. ident . as_str ( ) . cmp ( & b. ident . as_str ( ) )
639
639
}
640
640
( Fn ( ..) , Fn ( ..) ) => a. span . lo ( ) . cmp ( & b. span . lo ( ) ) ,
641
- ( TyAlias ( _ , _ , _ , ref ty) , _) if is_type ( ty ) => Ordering :: Less ,
642
- ( _, TyAlias ( _ , _ , _ , ref ty) ) if is_type ( ty ) => Ordering :: Greater ,
641
+ ( TyAlias ( ty) , _) if is_type ( & ty . 3 ) => Ordering :: Less ,
642
+ ( _, TyAlias ( ty) ) if is_type ( & ty . 3 ) => Ordering :: Greater ,
643
643
( TyAlias ( ..) , _) => Ordering :: Less ,
644
644
( _, TyAlias ( ..) ) => Ordering :: Greater ,
645
645
( Const ( ..) , _) => Ordering :: Less ,
@@ -675,13 +675,13 @@ pub(crate) fn format_impl(
675
675
item : & ast:: Item ,
676
676
offset : Indent ,
677
677
) -> Option < String > {
678
- if let ast:: ItemKind :: Impl {
679
- ref generics ,
680
- ref self_ty ,
681
- ref items ,
682
- ..
683
- } = item . kind
684
- {
678
+ if let ast:: ItemKind :: Impl ( impl_kind ) = & item . kind {
679
+ let ast :: ImplKind {
680
+ ref generics ,
681
+ ref self_ty ,
682
+ ref items ,
683
+ ..
684
+ } = * * impl_kind ;
685
685
let mut result = String :: with_capacity ( 128 ) ;
686
686
let ref_and_type = format_impl_ref_and_type ( context, item, offset) ?;
687
687
let sep = offset. to_string_with_newline ( context. config ) ;
@@ -829,17 +829,17 @@ fn format_impl_ref_and_type(
829
829
item : & ast:: Item ,
830
830
offset : Indent ,
831
831
) -> Option < String > {
832
- if let ast:: ItemKind :: Impl {
833
- unsafety ,
834
- polarity ,
835
- defaultness ,
836
- constness ,
837
- ref generics ,
838
- of_trait : ref trait_ref ,
839
- ref self_ty ,
840
- ..
841
- } = item . kind
842
- {
832
+ if let ast:: ItemKind :: Impl ( impl_kind ) = & item . kind {
833
+ let ast :: ImplKind {
834
+ unsafety ,
835
+ polarity ,
836
+ defaultness ,
837
+ constness ,
838
+ ref generics ,
839
+ of_trait : ref trait_ref ,
840
+ ref self_ty ,
841
+ ..
842
+ } = * * impl_kind ;
843
843
let mut result = String :: with_capacity ( 128 ) ;
844
844
845
845
result. push_str ( & format_visibility ( context, & item. vis ) ) ;
@@ -1025,14 +1025,9 @@ pub(crate) fn format_trait(
1025
1025
item : & ast:: Item ,
1026
1026
offset : Indent ,
1027
1027
) -> Option < String > {
1028
- if let ast:: ItemKind :: Trait (
1029
- is_auto,
1030
- unsafety,
1031
- ref generics,
1032
- ref generic_bounds,
1033
- ref trait_items,
1034
- ) = item. kind
1035
- {
1028
+ if let ast:: ItemKind :: Trait ( trait_kind) = & item. kind {
1029
+ let ast:: TraitKind ( is_auto, unsafety, ref generics, ref generic_bounds, ref trait_items) =
1030
+ * * trait_kind;
1036
1031
let mut result = String :: with_capacity ( 128 ) ;
1037
1032
let header = format ! (
1038
1033
"{}{}{}trait " ,
@@ -3119,31 +3114,35 @@ impl Rewrite for ast::ForeignItem {
3119
3114
let span = mk_sp ( self . span . lo ( ) , self . span . hi ( ) - BytePos ( 1 ) ) ;
3120
3115
3121
3116
let item_str = match self . kind {
3122
- ast:: ForeignItemKind :: Fn ( defaultness, ref fn_sig, ref generics, Some ( ref body) ) => {
3123
- let mut visitor = FmtVisitor :: from_context ( context) ;
3124
- visitor. block_indent = shape. indent ;
3125
- visitor. last_pos = self . span . lo ( ) ;
3126
- let inner_attrs = inner_attributes ( & self . attrs ) ;
3127
- let fn_ctxt = visit:: FnCtxt :: Foreign ;
3128
- visitor. visit_fn (
3129
- visit:: FnKind :: Fn ( fn_ctxt, self . ident , & fn_sig, & self . vis , Some ( body) ) ,
3130
- generics,
3131
- & fn_sig. decl ,
3132
- self . span ,
3133
- defaultness,
3134
- Some ( & inner_attrs) ,
3135
- ) ;
3136
- Some ( visitor. buffer . to_owned ( ) )
3117
+ ast:: ForeignItemKind :: Fn ( ref fn_kind) => {
3118
+ let ast:: FnKind ( defaultness, ref fn_sig, ref generics, ref block) = * * fn_kind;
3119
+ if let Some ( ref body) = block {
3120
+ let mut visitor = FmtVisitor :: from_context ( context) ;
3121
+ visitor. block_indent = shape. indent ;
3122
+ visitor. last_pos = self . span . lo ( ) ;
3123
+ let inner_attrs = inner_attributes ( & self . attrs ) ;
3124
+ let fn_ctxt = visit:: FnCtxt :: Foreign ;
3125
+ visitor. visit_fn (
3126
+ visit:: FnKind :: Fn ( fn_ctxt, self . ident , & fn_sig, & self . vis , Some ( body) ) ,
3127
+ generics,
3128
+ & fn_sig. decl ,
3129
+ self . span ,
3130
+ defaultness,
3131
+ Some ( & inner_attrs) ,
3132
+ ) ;
3133
+ Some ( visitor. buffer . to_owned ( ) )
3134
+ } else {
3135
+ rewrite_fn_base (
3136
+ context,
3137
+ shape. indent ,
3138
+ self . ident ,
3139
+ & FnSig :: from_method_sig ( & fn_sig, generics, self . vis . clone ( ) ) ,
3140
+ span,
3141
+ FnBraceStyle :: None ,
3142
+ )
3143
+ . map ( |( s, _, _) | format ! ( "{};" , s) )
3144
+ }
3137
3145
}
3138
- ast:: ForeignItemKind :: Fn ( _, ref fn_sig, ref generics, None ) => rewrite_fn_base (
3139
- context,
3140
- shape. indent ,
3141
- self . ident ,
3142
- & FnSig :: from_method_sig ( & fn_sig, generics, self . vis . clone ( ) ) ,
3143
- span,
3144
- FnBraceStyle :: None ,
3145
- )
3146
- . map ( |( s, _, _) | format ! ( "{};" , s) ) ,
3147
3146
ast:: ForeignItemKind :: Static ( ref ty, mutability, _) => {
3148
3147
// FIXME(#21): we're dropping potential comments in between the
3149
3148
// function kw here.
@@ -3158,21 +3157,20 @@ impl Rewrite for ast::ForeignItem {
3158
3157
// 1 = ;
3159
3158
rewrite_assign_rhs ( context, prefix, & * * ty, shape. sub_width ( 1 ) ?) . map ( |s| s + ";" )
3160
3159
}
3161
- ast:: ForeignItemKind :: TyAlias (
3162
- _,
3163
- ref generics,
3164
- ref generic_bounds,
3165
- ref type_default,
3166
- ) => rewrite_type_alias (
3167
- self . ident ,
3168
- type_default. as_ref ( ) ,
3169
- generics,
3170
- Some ( generic_bounds) ,
3171
- & context,
3172
- shape. indent ,
3173
- & self . vis ,
3174
- self . span ,
3175
- ) ,
3160
+ ast:: ForeignItemKind :: TyAlias ( ref ty_alias_kind) => {
3161
+ let ast:: TyAliasKind ( _, ref generics, ref generic_bounds, ref type_default) =
3162
+ * * ty_alias_kind;
3163
+ rewrite_type_alias (
3164
+ self . ident ,
3165
+ type_default. as_ref ( ) ,
3166
+ generics,
3167
+ Some ( generic_bounds) ,
3168
+ & context,
3169
+ shape. indent ,
3170
+ & self . vis ,
3171
+ self . span ,
3172
+ )
3173
+ }
3176
3174
ast:: ForeignItemKind :: MacCall ( ref mac) => {
3177
3175
rewrite_macro ( mac, None , context, shape, MacroPosition :: Item )
3178
3176
}
0 commit comments