@@ -2,7 +2,7 @@ use crate::pp::Breaks::{Consistent, Inconsistent};
22use crate :: pp:: { self , Breaks } ;
33
44use rustc_span:: edition:: Edition ;
5- use rustc_span:: source_map:: { dummy_spanned , SourceMap , Spanned } ;
5+ use rustc_span:: source_map:: { SourceMap , Spanned } ;
66use rustc_span:: symbol:: { kw, sym} ;
77use rustc_span:: { BytePos , FileName , Span } ;
88use syntax:: ast:: { self , BlockCheckMode , PatKind , RangeEnd , RangeSyntax } ;
@@ -1026,27 +1026,26 @@ impl<'a> State<'a> {
10261026 span : Span ,
10271027 ident : ast:: Ident ,
10281028 attrs : & [ Attribute ] ,
1029- defaultness : ast:: Defaultness ,
1029+ def : ast:: Defaultness ,
10301030 kind : & ast:: AssocItemKind ,
10311031 vis : & ast:: Visibility ,
10321032 ) {
10331033 self . ann . pre ( self , AnnNode :: SubItem ( id) ) ;
10341034 self . hardbreak_if_not_bol ( ) ;
10351035 self . maybe_print_comment ( span. lo ( ) ) ;
10361036 self . print_outer_attributes ( attrs) ;
1037- self . print_defaultness ( defaultness) ;
10381037 match kind {
10391038 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) ;
10411040 }
10421041 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 ) ;
10441043 }
10451044 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 ) ;
10471046 }
10481047 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 ) ;
10501049 }
10511050 ast:: ForeignItemKind :: Macro ( m) => {
10521051 self . print_mac ( m) ;
@@ -1065,13 +1064,17 @@ impl<'a> State<'a> {
10651064 ty : & ast:: Ty ,
10661065 body : Option < & ast:: Expr > ,
10671066 vis : & ast:: Visibility ,
1067+ defaultness : ast:: Defaultness ,
10681068 ) {
1069+ self . head ( "" ) ;
1070+ self . print_visibility ( vis) ;
1071+ self . print_defaultness ( defaultness) ;
10691072 let leading = match mutbl {
10701073 None => "const" ,
10711074 Some ( ast:: Mutability :: Not ) => "static" ,
10721075 Some ( ast:: Mutability :: Mut ) => "static mut" ,
10731076 } ;
1074- self . head ( visibility_qualified ( vis , leading) ) ;
1077+ self . word_space ( leading) ;
10751078 self . print_ident ( ident) ;
10761079 self . word_space ( ":" ) ;
10771080 self . print_type ( ty) ;
@@ -1091,7 +1094,12 @@ impl<'a> State<'a> {
10911094 generics : & ast:: Generics ,
10921095 bounds : & ast:: GenericBounds ,
10931096 ty : Option < & ast:: Ty > ,
1097+ vis : & ast:: Visibility ,
1098+ defaultness : ast:: Defaultness ,
10941099 ) {
1100+ self . head ( "" ) ;
1101+ self . print_visibility ( vis) ;
1102+ self . print_defaultness ( defaultness) ;
10951103 self . word_space ( "type" ) ;
10961104 self . print_ident ( ident) ;
10971105 self . print_generic_params ( & generics. params ) ;
@@ -1102,7 +1110,9 @@ impl<'a> State<'a> {
11021110 self . word_space ( "=" ) ;
11031111 self . print_type ( ty) ;
11041112 }
1105- self . s . word ( ";" )
1113+ self . s . word ( ";" ) ;
1114+ self . end ( ) ; // end inner head-block
1115+ self . end ( ) ; // end outer head-block
11061116 }
11071117
11081118 /// Pretty-prints an item.
@@ -1133,13 +1143,17 @@ impl<'a> State<'a> {
11331143 self . end ( ) ; // end outer head-block
11341144 }
11351145 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) ;
11371148 }
11381149 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) ;
11401152 }
11411153 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 ) ;
11431157 }
11441158 ast:: ItemKind :: Mod ( ref _mod) => {
11451159 self . head ( visibility_qualified ( & item. vis , "mod" ) ) ;
@@ -1171,18 +1185,10 @@ impl<'a> State<'a> {
11711185 self . s . word ( ga. asm . to_string ( ) ) ;
11721186 self . end ( ) ;
11731187 }
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) ;
11861192 }
11871193 ast:: ItemKind :: Enum ( ref enum_definition, ref params) => {
11881194 self . print_enum_def ( enum_definition, params, item. ident , item. span , & item. vis ) ;
@@ -2370,13 +2376,16 @@ impl<'a> State<'a> {
23702376 name : ast:: Ident ,
23712377 generics : & ast:: Generics ,
23722378 vis : & ast:: Visibility ,
2379+ defaultness : ast:: Defaultness ,
23732380 body : Option < & ast:: Block > ,
23742381 attrs : & [ ast:: Attribute ] ,
23752382 ) {
23762383 if body. is_some ( ) {
23772384 self . head ( "" ) ;
23782385 }
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) ;
23802389 if let Some ( body) = body {
23812390 self . nbsp ( ) ;
23822391 self . print_block_with_attrs ( body, attrs) ;
@@ -2391,10 +2400,8 @@ impl<'a> State<'a> {
23912400 header : ast:: FnHeader ,
23922401 name : Option < ast:: Ident > ,
23932402 generics : & ast:: Generics ,
2394- vis : & ast:: Visibility ,
23952403 ) {
2396- self . print_fn_header_info ( header, vis) ;
2397-
2404+ self . print_fn_header_info ( header) ;
23982405 if let Some ( name) = name {
23992406 self . nbsp ( ) ;
24002407 self . print_ident ( name) ;
@@ -2672,8 +2679,7 @@ impl<'a> State<'a> {
26722679 span : rustc_span:: DUMMY_SP ,
26732680 } ;
26742681 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) ;
26772683 self . end ( ) ;
26782684 }
26792685
@@ -2700,9 +2706,7 @@ impl<'a> State<'a> {
27002706 }
27012707 }
27022708
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 ) {
27062710 self . print_constness ( header. constness ) ;
27072711 self . print_asyncness ( header. asyncness ) ;
27082712 self . print_unsafety ( header. unsafety ) ;
0 commit comments