@@ -2,7 +2,7 @@ use std::cell::{Cell, RefCell};
2
2
use std:: rc:: Rc ;
3
3
4
4
use 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 } ;
6
6
7
7
use crate :: attr:: * ;
8
8
use crate :: comment:: { rewrite_comment, CodeCharKind , CommentCodeSlices } ;
@@ -25,8 +25,8 @@ use crate::spanned::Spanned;
25
25
use crate :: stmt:: Stmt ;
26
26
use crate :: syntux:: session:: ParseSess ;
27
27
use 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,
30
30
} ;
31
31
use crate :: { ErrorKind , FormatReport , FormattingError } ;
32
32
@@ -603,7 +603,11 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
603
603
}
604
604
ast:: AssocItemKind :: Fn ( defaultness, ref sig, ref generics, Some ( ref body) ) => {
605
605
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
+ } ;
607
611
let fn_ctxt = visit:: FnCtxt :: Assoc ( visit:: AssocCtxt :: Trait ) ;
608
612
self . visit_fn (
609
613
visit:: FnKind :: Fn ( fn_ctxt, ti. ident , sig, & vis, Some ( body) ) ,
@@ -902,6 +906,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
902
906
) {
903
907
let vis_str = utils:: format_visibility ( & self . get_context ( ) , vis) ;
904
908
self . push_str ( & * vis_str) ;
909
+ self . push_str ( format_unsafety ( m. unsafety ) ) ;
905
910
self . push_str ( "mod " ) ;
906
911
// Calling `to_owned()` to work around borrow checker.
907
912
let ident_str = rewrite_ident ( & self . get_context ( ) , ident) . to_owned ( ) ;
0 commit comments