@@ -912,7 +912,7 @@ impl<'a> State<'a> {
912
912
}
913
913
}
914
914
915
- crate fn print_foreign_mod ( & mut self , nmod : & ast:: ForeignMod , attrs : & [ ast :: Attribute ] ) {
915
+ crate fn print_foreign_mod ( & mut self , nmod : & ast:: ForeignMod , attrs : & [ Attribute ] ) {
916
916
self . print_inner_attributes ( attrs) ;
917
917
for item in & nmod. items {
918
918
self . print_foreign_item ( item) ;
@@ -1016,21 +1016,37 @@ impl<'a> State<'a> {
1016
1016
}
1017
1017
1018
1018
crate fn print_foreign_item ( & mut self , item : & ast:: ForeignItem ) {
1019
+ let ast:: ForeignItem { id, span, ident, attrs, kind, vis, tokens : _ } = item;
1020
+ self . print_nested_item_kind ( * id, * span, * ident, attrs, ast:: Defaultness :: Final , kind, vis) ;
1021
+ }
1022
+
1023
+ fn print_nested_item_kind (
1024
+ & mut self ,
1025
+ id : ast:: NodeId ,
1026
+ span : Span ,
1027
+ ident : ast:: Ident ,
1028
+ attrs : & [ Attribute ] ,
1029
+ defaultness : ast:: Defaultness ,
1030
+ kind : & ast:: AssocItemKind ,
1031
+ vis : & ast:: Visibility ,
1032
+ ) {
1033
+ self . ann . pre ( self , AnnNode :: SubItem ( id) ) ;
1019
1034
self . hardbreak_if_not_bol ( ) ;
1020
- self . maybe_print_comment ( item. span . lo ( ) ) ;
1021
- self . print_outer_attributes ( & item. attrs ) ;
1022
- match & item. kind {
1035
+ self . maybe_print_comment ( span. lo ( ) ) ;
1036
+ self . print_outer_attributes ( attrs) ;
1037
+ self . print_defaultness ( defaultness) ;
1038
+ match kind {
1023
1039
ast:: ForeignItemKind :: Fn ( sig, gen, body) => {
1024
- self . print_fn_full ( sig, item . ident , gen, & item . vis , body. as_deref ( ) , & item . attrs ) ;
1040
+ self . print_fn_full ( sig, ident, gen, vis, body. as_deref ( ) , attrs) ;
1025
1041
}
1026
1042
ast:: ForeignItemKind :: Const ( ty, body) => {
1027
- self . print_item_const ( item . ident , None , ty, body. as_deref ( ) , & item . vis ) ;
1043
+ self . print_item_const ( ident, None , ty, body. as_deref ( ) , vis) ;
1028
1044
}
1029
1045
ast:: ForeignItemKind :: Static ( ty, mutbl, body) => {
1030
- self . print_item_const ( item . ident , Some ( * mutbl) , ty, body. as_deref ( ) , & item . vis ) ;
1046
+ self . print_item_const ( ident, Some ( * mutbl) , ty, body. as_deref ( ) , vis) ;
1031
1047
}
1032
1048
ast:: ForeignItemKind :: TyAlias ( generics, bounds, ty) => {
1033
- self . print_associated_type ( item . ident , generics, bounds, ty. as_deref ( ) ) ;
1049
+ self . print_associated_type ( ident, generics, bounds, ty. as_deref ( ) ) ;
1034
1050
}
1035
1051
ast:: ForeignItemKind :: Macro ( m) => {
1036
1052
self . print_mac ( m) ;
@@ -1039,6 +1055,7 @@ impl<'a> State<'a> {
1039
1055
}
1040
1056
}
1041
1057
}
1058
+ self . ann . post ( self , AnnNode :: SubItem ( id) )
1042
1059
}
1043
1060
1044
1061
fn print_item_const (
@@ -1438,33 +1455,8 @@ impl<'a> State<'a> {
1438
1455
}
1439
1456
1440
1457
crate fn print_assoc_item ( & mut self , item : & ast:: AssocItem ) {
1441
- self . ann . pre ( self , AnnNode :: SubItem ( item. id ) ) ;
1442
- self . hardbreak_if_not_bol ( ) ;
1443
- self . maybe_print_comment ( item. span . lo ( ) ) ;
1444
- self . print_outer_attributes ( & item. attrs ) ;
1445
- self . print_defaultness ( item. defaultness ) ;
1446
- match & item. kind {
1447
- ast:: AssocItemKind :: Static ( ty, mutbl, expr) => {
1448
- self . print_item_const ( item. ident , Some ( * mutbl) , ty, expr. as_deref ( ) , & item. vis ) ;
1449
- }
1450
- ast:: AssocItemKind :: Const ( ty, expr) => {
1451
- self . print_item_const ( item. ident , None , ty, expr. as_deref ( ) , & item. vis ) ;
1452
- }
1453
- ast:: AssocItemKind :: Fn ( sig, generics, body) => {
1454
- let body = body. as_deref ( ) ;
1455
- self . print_fn_full ( sig, item. ident , generics, & item. vis , body, & item. attrs ) ;
1456
- }
1457
- ast:: AssocItemKind :: TyAlias ( generics, bounds, ty) => {
1458
- self . print_associated_type ( item. ident , generics, bounds, ty. as_deref ( ) ) ;
1459
- }
1460
- ast:: AssocItemKind :: Macro ( mac) => {
1461
- self . print_mac ( mac) ;
1462
- if mac. args . need_semicolon ( ) {
1463
- self . s . word ( ";" ) ;
1464
- }
1465
- }
1466
- }
1467
- self . ann . post ( self , AnnNode :: SubItem ( item. id ) )
1458
+ let ast:: AssocItem { id, span, ident, attrs, defaultness, kind, vis, tokens : _ } = item;
1459
+ self . print_nested_item_kind ( * id, * span, * ident, attrs, * defaultness, kind, vis) ;
1468
1460
}
1469
1461
1470
1462
crate fn print_stmt ( & mut self , st : & ast:: Stmt ) {
0 commit comments