@@ -1915,6 +1915,7 @@ pub(crate) fn rewrite_struct_field(
19151915
19161916pub ( crate ) struct StaticParts < ' a > {
19171917 prefix : & ' a str ,
1918+ safety : ast:: Safety ,
19181919 vis : & ' a ast:: Visibility ,
19191920 ident : symbol:: Ident ,
19201921 ty : & ' a ast:: Ty ,
@@ -1926,11 +1927,12 @@ pub(crate) struct StaticParts<'a> {
19261927
19271928impl < ' a > StaticParts < ' a > {
19281929 pub ( crate ) fn from_item ( item : & ' a ast:: Item ) -> Self {
1929- let ( defaultness, prefix, ty, mutability, expr) = match & item. kind {
1930- ast:: ItemKind :: Static ( s) => ( None , "static" , & s. ty , s. mutability , & s. expr ) ,
1930+ let ( defaultness, prefix, safety , ty, mutability, expr) = match & item. kind {
1931+ ast:: ItemKind :: Static ( s) => ( None , "static" , s . safety , & s. ty , s. mutability , & s. expr ) ,
19311932 ast:: ItemKind :: Const ( c) => (
19321933 Some ( c. defaultness ) ,
19331934 "const" ,
1935+ ast:: Safety :: Default ,
19341936 & c. ty ,
19351937 ast:: Mutability :: Not ,
19361938 & c. expr ,
@@ -1939,6 +1941,7 @@ impl<'a> StaticParts<'a> {
19391941 } ;
19401942 StaticParts {
19411943 prefix,
1944+ safety,
19421945 vis : & item. vis ,
19431946 ident : item. ident ,
19441947 ty,
@@ -1956,6 +1959,7 @@ impl<'a> StaticParts<'a> {
19561959 } ;
19571960 StaticParts {
19581961 prefix : "const" ,
1962+ safety : ast:: Safety :: Default ,
19591963 vis : & ti. vis ,
19601964 ident : ti. ident ,
19611965 ty,
@@ -1973,6 +1977,7 @@ impl<'a> StaticParts<'a> {
19731977 } ;
19741978 StaticParts {
19751979 prefix : "const" ,
1980+ safety : ast:: Safety :: Default ,
19761981 vis : & ii. vis ,
19771982 ident : ii. ident ,
19781983 ty,
@@ -1989,11 +1994,13 @@ fn rewrite_static(
19891994 static_parts : & StaticParts < ' _ > ,
19901995 offset : Indent ,
19911996) -> Option < String > {
1997+ println ! ( "rewriting static" ) ;
19921998 let colon = colon_spaces ( context. config ) ;
19931999 let mut prefix = format ! (
1994- "{}{}{} {}{}{}" ,
2000+ "{}{}{}{} {}{}{}" ,
19952001 format_visibility( context, static_parts. vis) ,
19962002 static_parts. defaultness. map_or( "" , format_defaultness) ,
2003+ format_safety( static_parts. safety) ,
19972004 static_parts. prefix,
19982005 format_mutability( static_parts. mutability) ,
19992006 rewrite_ident( context, static_parts. ident) ,
@@ -3338,10 +3345,12 @@ impl Rewrite for ast::ForeignItem {
33383345 // FIXME(#21): we're dropping potential comments in between the
33393346 // function kw here.
33403347 let vis = format_visibility ( context, & self . vis ) ;
3348+ let safety = format_safety ( static_foreign_item. safety ) ;
33413349 let mut_str = format_mutability ( static_foreign_item. mutability ) ;
33423350 let prefix = format ! (
3343- "{}static {}{}:" ,
3351+ "{}{} static {}{}:" ,
33443352 vis,
3353+ safety,
33453354 mut_str,
33463355 rewrite_ident( context, self . ident)
33473356 ) ;
0 commit comments