@@ -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" ) ) ; 
@@ -2370,13 +2384,16 @@ impl<'a> State<'a> {
23702384        name :  ast:: Ident , 
23712385        generics :  & ast:: Generics , 
23722386        vis :  & ast:: Visibility , 
2387+         defaultness :  ast:: Defaultness , 
23732388        body :  Option < & ast:: Block > , 
23742389        attrs :  & [ ast:: Attribute ] , 
23752390    )  { 
23762391        if  body. is_some ( )  { 
23772392            self . head ( "" ) ; 
23782393        } 
2379-         self . print_fn ( & sig. decl ,  sig. header ,  Some ( name) ,  generics,  vis) ; 
2394+         self . print_visibility ( vis) ; 
2395+         self . print_defaultness ( defaultness) ; 
2396+         self . print_fn ( & sig. decl ,  sig. header ,  Some ( name) ,  generics) ; 
23802397        if  let  Some ( body)  = body { 
23812398            self . nbsp ( ) ; 
23822399            self . print_block_with_attrs ( body,  attrs) ; 
@@ -2391,10 +2408,8 @@ impl<'a> State<'a> {
23912408        header :  ast:: FnHeader , 
23922409        name :  Option < ast:: Ident > , 
23932410        generics :  & ast:: Generics , 
2394-         vis :  & ast:: Visibility , 
23952411    )  { 
2396-         self . print_fn_header_info ( header,  vis) ; 
2397- 
2412+         self . print_fn_header_info ( header) ; 
23982413        if  let  Some ( name)  = name { 
23992414            self . nbsp ( ) ; 
24002415            self . print_ident ( name) ; 
@@ -2672,8 +2687,7 @@ impl<'a> State<'a> {
26722687            span :  rustc_span:: DUMMY_SP , 
26732688        } ; 
26742689        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) ; 
2690+         self . print_fn ( decl,  header,  name,  & generics) ; 
26772691        self . end ( ) ; 
26782692    } 
26792693
@@ -2700,9 +2714,7 @@ impl<'a> State<'a> {
27002714        } 
27012715    } 
27022716
2703-     crate  fn  print_fn_header_info ( & mut  self ,  header :  ast:: FnHeader ,  vis :  & ast:: Visibility )  { 
2704-         self . s . word ( visibility_qualified ( vis,  "" ) ) ; 
2705- 
2717+     crate  fn  print_fn_header_info ( & mut  self ,  header :  ast:: FnHeader )  { 
27062718        self . print_constness ( header. constness ) ; 
27072719        self . print_asyncness ( header. asyncness ) ; 
27082720        self . print_unsafety ( header. unsafety ) ; 
0 commit comments