@@ -2,7 +2,7 @@ use crate::pp::Breaks::{Consistent, Inconsistent};
2
2
use crate :: pp:: { self , Breaks } ;
3
3
4
4
use rustc_span:: edition:: Edition ;
5
- use rustc_span:: source_map:: { dummy_spanned , SourceMap , Spanned } ;
5
+ use rustc_span:: source_map:: { SourceMap , Spanned } ;
6
6
use rustc_span:: symbol:: { kw, sym} ;
7
7
use rustc_span:: { BytePos , FileName , Span } ;
8
8
use syntax:: ast:: { self , BlockCheckMode , PatKind , RangeEnd , RangeSyntax } ;
@@ -1026,27 +1026,26 @@ impl<'a> State<'a> {
1026
1026
span : Span ,
1027
1027
ident : ast:: Ident ,
1028
1028
attrs : & [ Attribute ] ,
1029
- defaultness : ast:: Defaultness ,
1029
+ def : ast:: Defaultness ,
1030
1030
kind : & ast:: AssocItemKind ,
1031
1031
vis : & ast:: Visibility ,
1032
1032
) {
1033
1033
self . ann . pre ( self , AnnNode :: SubItem ( id) ) ;
1034
1034
self . hardbreak_if_not_bol ( ) ;
1035
1035
self . maybe_print_comment ( span. lo ( ) ) ;
1036
1036
self . print_outer_attributes ( attrs) ;
1037
- self . print_defaultness ( defaultness) ;
1038
1037
match kind {
1039
1038
ast:: ForeignItemKind :: Fn ( sig, gen, body) => {
1040
- self . print_fn_full ( sig, ident, gen, vis, body. as_deref ( ) , attrs) ;
1039
+ self . print_fn_full ( sig, ident, gen, vis, def , body. as_deref ( ) , attrs) ;
1041
1040
}
1042
1041
ast:: ForeignItemKind :: Const ( ty, body) => {
1043
- self . print_item_const ( ident, None , ty, body. as_deref ( ) , vis) ;
1042
+ self . print_item_const ( ident, None , ty, body. as_deref ( ) , vis, def ) ;
1044
1043
}
1045
1044
ast:: ForeignItemKind :: Static ( ty, mutbl, body) => {
1046
- self . print_item_const ( ident, Some ( * mutbl) , ty, body. as_deref ( ) , vis) ;
1045
+ self . print_item_const ( ident, Some ( * mutbl) , ty, body. as_deref ( ) , vis, def ) ;
1047
1046
}
1048
1047
ast:: ForeignItemKind :: TyAlias ( generics, bounds, ty) => {
1049
- self . print_associated_type ( ident, generics, bounds, ty. as_deref ( ) ) ;
1048
+ self . print_associated_type ( ident, generics, bounds, ty. as_deref ( ) , vis , def ) ;
1050
1049
}
1051
1050
ast:: ForeignItemKind :: Macro ( m) => {
1052
1051
self . print_mac ( m) ;
@@ -1065,13 +1064,17 @@ impl<'a> State<'a> {
1065
1064
ty : & ast:: Ty ,
1066
1065
body : Option < & ast:: Expr > ,
1067
1066
vis : & ast:: Visibility ,
1067
+ defaultness : ast:: Defaultness ,
1068
1068
) {
1069
+ self . head ( "" ) ;
1070
+ self . print_visibility ( vis) ;
1071
+ self . print_defaultness ( defaultness) ;
1069
1072
let leading = match mutbl {
1070
1073
None => "const" ,
1071
1074
Some ( ast:: Mutability :: Not ) => "static" ,
1072
1075
Some ( ast:: Mutability :: Mut ) => "static mut" ,
1073
1076
} ;
1074
- self . head ( visibility_qualified ( vis , leading) ) ;
1077
+ self . word_space ( leading) ;
1075
1078
self . print_ident ( ident) ;
1076
1079
self . word_space ( ":" ) ;
1077
1080
self . print_type ( ty) ;
@@ -1091,7 +1094,12 @@ impl<'a> State<'a> {
1091
1094
generics : & ast:: Generics ,
1092
1095
bounds : & ast:: GenericBounds ,
1093
1096
ty : Option < & ast:: Ty > ,
1097
+ vis : & ast:: Visibility ,
1098
+ defaultness : ast:: Defaultness ,
1094
1099
) {
1100
+ self . head ( "" ) ;
1101
+ self . print_visibility ( vis) ;
1102
+ self . print_defaultness ( defaultness) ;
1095
1103
self . word_space ( "type" ) ;
1096
1104
self . print_ident ( ident) ;
1097
1105
self . print_generic_params ( & generics. params ) ;
@@ -1102,7 +1110,9 @@ impl<'a> State<'a> {
1102
1110
self . word_space ( "=" ) ;
1103
1111
self . print_type ( ty) ;
1104
1112
}
1105
- self . s . word ( ";" )
1113
+ self . s . word ( ";" ) ;
1114
+ self . end ( ) ; // end inner head-block
1115
+ self . end ( ) ; // end outer head-block
1106
1116
}
1107
1117
1108
1118
/// Pretty-prints an item.
@@ -1133,13 +1143,17 @@ impl<'a> State<'a> {
1133
1143
self . end ( ) ; // end outer head-block
1134
1144
}
1135
1145
ast:: ItemKind :: Static ( ref ty, mutbl, ref body) => {
1136
- self . print_item_const ( item. ident , Some ( mutbl) , ty, body. as_deref ( ) , & item. vis ) ;
1146
+ let def = ast:: Defaultness :: Final ;
1147
+ self . print_item_const ( item. ident , Some ( mutbl) , ty, body. as_deref ( ) , & item. vis , def) ;
1137
1148
}
1138
1149
ast:: ItemKind :: Const ( ref ty, ref body) => {
1139
- self . print_item_const ( item. ident , None , ty, body. as_deref ( ) , & item. vis ) ;
1150
+ let def = ast:: Defaultness :: Final ;
1151
+ self . print_item_const ( item. ident , None , ty, body. as_deref ( ) , & item. vis , def) ;
1140
1152
}
1141
1153
ast:: ItemKind :: Fn ( ref sig, ref gen, ref body) => {
1142
- self . print_fn_full ( sig, item. ident , gen, & item. vis , body. as_deref ( ) , & item. attrs ) ;
1154
+ let def = ast:: Defaultness :: Final ;
1155
+ let body = body. as_deref ( ) ;
1156
+ self . print_fn_full ( sig, item. ident , gen, & item. vis , def, body, & item. attrs ) ;
1143
1157
}
1144
1158
ast:: ItemKind :: Mod ( ref _mod) => {
1145
1159
self . head ( visibility_qualified ( & item. vis , "mod" ) ) ;
@@ -1171,18 +1185,10 @@ impl<'a> State<'a> {
1171
1185
self . s . word ( ga. asm . to_string ( ) ) ;
1172
1186
self . end ( ) ;
1173
1187
}
1174
- ast:: ItemKind :: TyAlias ( ref ty, ref generics) => {
1175
- self . head ( visibility_qualified ( & item. vis , "type" ) ) ;
1176
- self . print_ident ( item. ident ) ;
1177
- self . print_generic_params ( & generics. params ) ;
1178
- self . end ( ) ; // end the inner ibox
1179
-
1180
- self . print_where_clause ( & generics. where_clause ) ;
1181
- self . s . space ( ) ;
1182
- self . word_space ( "=" ) ;
1183
- self . print_type ( ty) ;
1184
- self . s . word ( ";" ) ;
1185
- self . end ( ) ; // end the outer ibox
1188
+ ast:: ItemKind :: TyAlias ( ref generics, ref bounds, ref ty) => {
1189
+ let def = ast:: Defaultness :: Final ;
1190
+ let ty = ty. as_deref ( ) ;
1191
+ self . print_associated_type ( item. ident , generics, bounds, ty, & item. vis , def) ;
1186
1192
}
1187
1193
ast:: ItemKind :: Enum ( ref enum_definition, ref params) => {
1188
1194
self . print_enum_def ( enum_definition, params, item. ident , item. span , & item. vis ) ;
@@ -2370,13 +2376,16 @@ impl<'a> State<'a> {
2370
2376
name : ast:: Ident ,
2371
2377
generics : & ast:: Generics ,
2372
2378
vis : & ast:: Visibility ,
2379
+ defaultness : ast:: Defaultness ,
2373
2380
body : Option < & ast:: Block > ,
2374
2381
attrs : & [ ast:: Attribute ] ,
2375
2382
) {
2376
2383
if body. is_some ( ) {
2377
2384
self . head ( "" ) ;
2378
2385
}
2379
- self . print_fn ( & sig. decl , sig. header , Some ( name) , generics, vis) ;
2386
+ self . print_visibility ( vis) ;
2387
+ self . print_defaultness ( defaultness) ;
2388
+ self . print_fn ( & sig. decl , sig. header , Some ( name) , generics) ;
2380
2389
if let Some ( body) = body {
2381
2390
self . nbsp ( ) ;
2382
2391
self . print_block_with_attrs ( body, attrs) ;
@@ -2391,10 +2400,8 @@ impl<'a> State<'a> {
2391
2400
header : ast:: FnHeader ,
2392
2401
name : Option < ast:: Ident > ,
2393
2402
generics : & ast:: Generics ,
2394
- vis : & ast:: Visibility ,
2395
2403
) {
2396
- self . print_fn_header_info ( header, vis) ;
2397
-
2404
+ self . print_fn_header_info ( header) ;
2398
2405
if let Some ( name) = name {
2399
2406
self . nbsp ( ) ;
2400
2407
self . print_ident ( name) ;
@@ -2672,8 +2679,7 @@ impl<'a> State<'a> {
2672
2679
span : rustc_span:: DUMMY_SP ,
2673
2680
} ;
2674
2681
let header = ast:: FnHeader { unsafety, ext, ..ast:: FnHeader :: default ( ) } ;
2675
- let vis = dummy_spanned ( ast:: VisibilityKind :: Inherited ) ;
2676
- self . print_fn ( decl, header, name, & generics, & vis) ;
2682
+ self . print_fn ( decl, header, name, & generics) ;
2677
2683
self . end ( ) ;
2678
2684
}
2679
2685
@@ -2700,9 +2706,7 @@ impl<'a> State<'a> {
2700
2706
}
2701
2707
}
2702
2708
2703
- crate fn print_fn_header_info ( & mut self , header : ast:: FnHeader , vis : & ast:: Visibility ) {
2704
- self . s . word ( visibility_qualified ( vis, "" ) ) ;
2705
-
2709
+ crate fn print_fn_header_info ( & mut self , header : ast:: FnHeader ) {
2706
2710
self . print_constness ( header. constness ) ;
2707
2711
self . print_asyncness ( header. asyncness ) ;
2708
2712
self . print_unsafety ( header. unsafety ) ;
0 commit comments