@@ -2,7 +2,7 @@ use std::cell::{Cell, RefCell};
22use std:: rc:: Rc ;
33
44use rustc_ast:: { ast, attr:: HasAttrs , token:: DelimToken , visit} ;
5- use rustc_span:: { symbol, BytePos , Pos , Span } ;
5+ use rustc_span:: { symbol, BytePos , Pos , Span , DUMMY_SP } ;
66
77use crate :: attr:: * ;
88use crate :: comment:: { rewrite_comment, CodeCharKind , CommentCodeSlices } ;
@@ -25,8 +25,8 @@ use crate::spanned::Spanned;
2525use crate :: stmt:: Stmt ;
2626use crate :: syntux:: session:: ParseSess ;
2727use crate :: utils:: {
28- self , contains_skip, count_newlines, depr_skip_annotation, inner_attributes , last_line_width ,
29- mk_sp, ptr_vec_to_ref_vec, rewrite_ident, stmt_expr,
28+ self , contains_skip, count_newlines, depr_skip_annotation, format_unsafety , inner_attributes ,
29+ last_line_width , mk_sp, ptr_vec_to_ref_vec, rewrite_ident, stmt_expr,
3030} ;
3131use crate :: { ErrorKind , FormatReport , FormattingError } ;
3232
@@ -603,7 +603,11 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
603603 }
604604 ast:: AssocItemKind :: Fn ( defaultness, ref sig, ref generics, Some ( ref body) ) => {
605605 let inner_attrs = inner_attributes ( & ti. attrs ) ;
606- let vis = rustc_span:: source_map:: dummy_spanned ( ast:: VisibilityKind :: Inherited ) ;
606+ let vis = ast:: Visibility {
607+ kind : ast:: VisibilityKind :: Inherited ,
608+ span : DUMMY_SP ,
609+ tokens : None ,
610+ } ;
607611 let fn_ctxt = visit:: FnCtxt :: Assoc ( visit:: AssocCtxt :: Trait ) ;
608612 self . visit_fn (
609613 visit:: FnKind :: Fn ( fn_ctxt, ti. ident , sig, & vis, Some ( body) ) ,
@@ -902,6 +906,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
902906 ) {
903907 let vis_str = utils:: format_visibility ( & self . get_context ( ) , vis) ;
904908 self . push_str ( & * vis_str) ;
909+ self . push_str ( format_unsafety ( m. unsafety ) ) ;
905910 self . push_str ( "mod " ) ;
906911 // Calling `to_owned()` to work around borrow checker.
907912 let ident_str = rewrite_ident ( & self . get_context ( ) , ident) . to_owned ( ) ;
0 commit comments