@@ -298,7 +298,7 @@ impl<'a> FmtVisitor<'a> {
298298
299299 fn format_foreign_item ( & mut self , item : & ast:: ForeignItem ) {
300300 let rewrite = item. rewrite ( & self . get_context ( ) , self . shape ( ) ) ;
301- self . push_rewrite ( item. span ( ) , rewrite) ;
301+ self . push_rewrite ( item. span , rewrite) ;
302302 self . last_pos = item. span . hi ( ) ;
303303 }
304304
@@ -629,7 +629,7 @@ impl<'a> FmtVisitor<'a> {
629629 use crate :: ast:: AssocItemKind :: * ;
630630 fn need_empty_line ( a : & ast:: AssocItemKind , b : & ast:: AssocItemKind ) -> bool {
631631 match ( a, b) {
632- ( TyAlias ( _, ref lty) , TyAlias ( _, ref rty) )
632+ ( TyAlias ( _, _ , _ , ref lty) , TyAlias ( _ , _ , _, ref rty) )
633633 if both_type ( lty, rty) || both_opaque ( lty, rty) =>
634634 {
635635 false
@@ -640,7 +640,7 @@ impl<'a> FmtVisitor<'a> {
640640 }
641641
642642 buffer. sort_by ( |( _, a) , ( _, b) | match ( & a. kind , & b. kind ) {
643- ( TyAlias ( _, ref lty) , TyAlias ( _, ref rty) )
643+ ( TyAlias ( _, _ , _ , ref lty) , TyAlias ( _ , _ , _, ref rty) )
644644 if both_type ( lty, rty) || both_opaque ( lty, rty) =>
645645 {
646646 a. ident . as_str ( ) . cmp ( & b. ident . as_str ( ) )
@@ -649,8 +649,8 @@ impl<'a> FmtVisitor<'a> {
649649 a. ident . as_str ( ) . cmp ( & b. ident . as_str ( ) )
650650 }
651651 ( Fn ( ..) , Fn ( ..) ) => a. span . lo ( ) . cmp ( & b. span . lo ( ) ) ,
652- ( TyAlias ( _, ref ty) , _) if is_type ( ty) => Ordering :: Less ,
653- ( _, TyAlias ( _, ref ty) ) if is_type ( ty) => Ordering :: Greater ,
652+ ( TyAlias ( _, _ , _ , ref ty) , _) if is_type ( ty) => Ordering :: Less ,
653+ ( _, TyAlias ( _, _ , _ , ref ty) ) if is_type ( ty) => Ordering :: Greater ,
654654 ( TyAlias ( ..) , _) => Ordering :: Less ,
655655 ( _, TyAlias ( ..) ) => Ordering :: Greater ,
656656 ( Const ( ..) , _) => Ordering :: Less ,
@@ -1714,9 +1714,13 @@ pub(crate) struct StaticParts<'a> {
17141714
17151715impl < ' a > StaticParts < ' a > {
17161716 pub ( crate ) fn from_item ( item : & ' a ast:: Item ) -> Self {
1717- let ( prefix, ty, mutability, expr) = match item. kind {
1718- ast:: ItemKind :: Static ( ref ty, mutability, ref expr) => ( "static" , ty, mutability, expr) ,
1719- ast:: ItemKind :: Const ( ref ty, ref expr) => ( "const" , ty, ast:: Mutability :: Not , expr) ,
1717+ let ( defaultness, prefix, ty, mutability, expr) = match item. kind {
1718+ ast:: ItemKind :: Static ( ref ty, mutability, ref expr) => {
1719+ ( None , "static" , ty, mutability, expr)
1720+ }
1721+ ast:: ItemKind :: Const ( defaultness, ref ty, ref expr) => {
1722+ ( Some ( defaultness) , "const" , ty, ast:: Mutability :: Not , expr)
1723+ }
17201724 _ => unreachable ! ( ) ,
17211725 } ;
17221726 StaticParts {
@@ -1725,15 +1729,17 @@ impl<'a> StaticParts<'a> {
17251729 ident : item. ident ,
17261730 ty,
17271731 mutability,
1728- expr_opt : Some ( expr) ,
1729- defaultness : None ,
1732+ expr_opt : expr. as_ref ( ) ,
1733+ defaultness : defaultness ,
17301734 span : item. span ,
17311735 }
17321736 }
17331737
17341738 pub ( crate ) fn from_trait_item ( ti : & ' a ast:: AssocItem ) -> Self {
1735- let ( ty, expr_opt) = match ti. kind {
1736- ast:: AssocItemKind :: Const ( ref ty, ref expr_opt) => ( ty, expr_opt) ,
1739+ let ( defaultness, ty, expr_opt) = match ti. kind {
1740+ ast:: AssocItemKind :: Const ( defaultness, ref ty, ref expr_opt) => {
1741+ ( defaultness, ty, expr_opt)
1742+ }
17371743 _ => unreachable ! ( ) ,
17381744 } ;
17391745 StaticParts {
@@ -1743,14 +1749,14 @@ impl<'a> StaticParts<'a> {
17431749 ty,
17441750 mutability : ast:: Mutability :: Not ,
17451751 expr_opt : expr_opt. as_ref ( ) ,
1746- defaultness : None ,
1752+ defaultness : Some ( defaultness ) ,
17471753 span : ti. span ,
17481754 }
17491755 }
17501756
17511757 pub ( crate ) fn from_impl_item ( ii : & ' a ast:: AssocItem ) -> Self {
1752- let ( ty, expr) = match ii. kind {
1753- ast:: AssocItemKind :: Const ( ref ty, ref expr) => ( ty, expr) ,
1758+ let ( defaultness , ty, expr) = match ii. kind {
1759+ ast:: AssocItemKind :: Const ( defaultness , ref ty, ref expr) => ( defaultness , ty, expr) ,
17541760 _ => unreachable ! ( ) ,
17551761 } ;
17561762 StaticParts {
@@ -1760,7 +1766,7 @@ impl<'a> StaticParts<'a> {
17601766 ty,
17611767 mutability : ast:: Mutability :: Not ,
17621768 expr_opt : expr. as_ref ( ) ,
1763- defaultness : Some ( ii . defaultness ) ,
1769+ defaultness : Some ( defaultness) ,
17641770 span : ii. span ,
17651771 }
17661772 }
@@ -1903,7 +1909,7 @@ pub(crate) fn rewrite_associated_impl_type(
19031909 let result = rewrite_associated_type ( ident, ty_opt, generics, None , context, indent) ?;
19041910
19051911 match defaultness {
1906- ast:: Defaultness :: Default => Some ( format ! ( "default {}" , result) ) ,
1912+ ast:: Defaultness :: Default ( .. ) => Some ( format ! ( "default {}" , result) ) ,
19071913 _ => Some ( result) ,
19081914 }
19091915}
@@ -3083,7 +3089,7 @@ impl Rewrite for ast::ForeignItem {
30833089 let span = mk_sp ( self . span . lo ( ) , self . span . hi ( ) - BytePos ( 1 ) ) ;
30843090
30853091 let item_str = match self . kind {
3086- ast:: ForeignItemKind :: Fn ( ref fn_sig, ref generics, _) => rewrite_fn_base (
3092+ ast:: ForeignItemKind :: Fn ( _ , ref fn_sig, ref generics, _) => rewrite_fn_base (
30873093 context,
30883094 shape. indent ,
30893095 self . ident ,
@@ -3092,7 +3098,7 @@ impl Rewrite for ast::ForeignItem {
30923098 FnBraceStyle :: None ,
30933099 )
30943100 . map ( |( s, _) | format ! ( "{};" , s) ) ,
3095- ast:: ForeignItemKind :: Static ( ref ty, mutability) => {
3101+ ast:: ForeignItemKind :: Static ( ref ty, mutability, _ ) => {
30963102 // FIXME(#21): we're dropping potential comments in between the
30973103 // function kw here.
30983104 let vis = format_visibility ( context, & self . vis ) ;
@@ -3106,7 +3112,7 @@ impl Rewrite for ast::ForeignItem {
31063112 // 1 = ;
31073113 rewrite_assign_rhs ( context, prefix, & * * ty, shape. sub_width ( 1 ) ?) . map ( |s| s + ";" )
31083114 }
3109- ast:: ForeignItemKind :: Ty => {
3115+ ast:: ForeignItemKind :: TyAlias ( .. ) => {
31103116 let vis = format_visibility ( context, & self . vis ) ;
31113117 Some ( format ! (
31123118 "{}type {};" ,
0 commit comments