@@ -225,15 +225,22 @@ crate fn from_ctor_kind(struct_type: CtorKind) -> StructType {
225225 }
226226}
227227
228- fn stringify_header ( header : & rustc_hir:: FnHeader ) -> String {
229- let mut s = String :: from ( header. unsafety . prefix_str ( ) ) ;
230- if header. asyncness == rustc_hir:: IsAsync :: Async {
231- s. push_str ( "async " )
228+ crate fn from_fn_header ( header : & rustc_hir:: FnHeader ) -> Vec < Modifiers > {
229+ let mut v = Vec :: new ( ) ;
230+
231+ if let rustc_hir:: Unsafety :: Unsafe = header. unsafety {
232+ v. push ( Modifiers :: Unsafe ) ;
233+ }
234+
235+ if let rustc_hir:: IsAsync :: Async = header. asyncness {
236+ v. push ( Modifiers :: Async ) ;
232237 }
233- if header. constness == rustc_hir:: Constness :: Const {
234- s. push_str ( "const " )
238+
239+ if let rustc_hir:: Constness :: Const = header. constness {
240+ v. push ( Modifiers :: Const ) ;
235241 }
236- s
242+
243+ v
237244}
238245
239246impl From < clean:: Function > for Function {
@@ -242,7 +249,7 @@ impl From<clean::Function> for Function {
242249 Function {
243250 decl : decl. into ( ) ,
244251 generics : generics. into ( ) ,
245- header : stringify_header ( & header) ,
252+ header : from_fn_header ( & header) ,
246253 abi : header. abi . to_string ( ) ,
247254 }
248255 }
@@ -364,7 +371,11 @@ impl From<clean::BareFunctionDecl> for FunctionPointer {
364371 fn from ( bare_decl : clean:: BareFunctionDecl ) -> Self {
365372 let clean:: BareFunctionDecl { unsafety, generic_params, decl, abi } = bare_decl;
366373 FunctionPointer {
367- is_unsafe : unsafety == rustc_hir:: Unsafety :: Unsafe ,
374+ header : if let rustc_hir:: Unsafety :: Unsafe = unsafety {
375+ vec ! [ Modifiers :: Unsafe ]
376+ } else {
377+ vec ! [ ]
378+ } ,
368379 generic_params : generic_params. into_iter ( ) . map ( Into :: into) . collect ( ) ,
369380 decl : decl. into ( ) ,
370381 abi : abi. to_string ( ) ,
@@ -439,7 +450,7 @@ crate fn from_function_method(function: clean::Function, has_body: bool) -> Meth
439450 Method {
440451 decl : decl. into ( ) ,
441452 generics : generics. into ( ) ,
442- header : stringify_header ( & header) ,
453+ header : from_fn_header ( & header) ,
443454 abi : header. abi . to_string ( ) ,
444455 has_body,
445456 }
0 commit comments