@@ -10,7 +10,7 @@ use crate::{
1010 body:: Expander ,
1111 db:: DefDatabase ,
1212 intern:: Interned ,
13- item_tree:: { AssocItem , FunctionQualifier , ItemTreeId , ModItem , Param } ,
13+ item_tree:: { AssocItem , FnFlags , ItemTreeId , ModItem , Param } ,
1414 type_ref:: { TraitRef , TypeBound , TypeRef } ,
1515 visibility:: RawVisibility ,
1616 AssocContainerId , AssocItemId , ConstId , ConstLoc , FunctionId , FunctionLoc , HasModule , ImplId ,
@@ -23,14 +23,9 @@ pub struct FunctionData {
2323 pub params : Vec < Interned < TypeRef > > ,
2424 pub ret_type : Interned < TypeRef > ,
2525 pub attrs : Attrs ,
26- /// True if the first param is `self`. This is relevant to decide whether this
27- /// can be called as a method.
28- pub has_self_param : bool ,
29- pub has_body : bool ,
30- pub qualifier : FunctionQualifier ,
31- pub is_in_extern_block : bool ,
32- pub is_varargs : bool ,
3326 pub visibility : RawVisibility ,
27+ pub abi : Option < Interned < str > > ,
28+ flags : FnFlags ,
3429}
3530
3631impl FunctionData {
@@ -53,6 +48,11 @@ impl FunctionData {
5348 . next_back ( )
5449 . map_or ( false , |param| matches ! ( item_tree[ param] , Param :: Varargs ) ) ;
5550
51+ let mut flags = func. flags ;
52+ if is_varargs {
53+ flags |= FnFlags :: IS_VARARGS ;
54+ }
55+
5656 Arc :: new ( FunctionData {
5757 name : func. name . clone ( ) ,
5858 params : enabled_params
@@ -64,14 +64,45 @@ impl FunctionData {
6464 . collect ( ) ,
6565 ret_type : func. ret_type . clone ( ) ,
6666 attrs : item_tree. attrs ( db, krate, ModItem :: from ( loc. id . value ) . into ( ) ) ,
67- has_self_param : func. has_self_param ,
68- has_body : func. has_body ,
69- qualifier : func. qualifier . clone ( ) ,
70- is_in_extern_block : func. is_in_extern_block ,
71- is_varargs,
7267 visibility : item_tree[ func. visibility ] . clone ( ) ,
68+ abi : func. abi . clone ( ) ,
69+ flags,
7370 } )
7471 }
72+
73+ pub fn has_body ( & self ) -> bool {
74+ self . flags . contains ( FnFlags :: HAS_BODY )
75+ }
76+
77+ /// True if the first param is `self`. This is relevant to decide whether this
78+ /// can be called as a method.
79+ pub fn has_self_param ( & self ) -> bool {
80+ self . flags . contains ( FnFlags :: HAS_SELF_PARAM )
81+ }
82+
83+ pub fn is_default ( & self ) -> bool {
84+ self . flags . contains ( FnFlags :: IS_DEFAULT )
85+ }
86+
87+ pub fn is_const ( & self ) -> bool {
88+ self . flags . contains ( FnFlags :: IS_CONST )
89+ }
90+
91+ pub fn is_async ( & self ) -> bool {
92+ self . flags . contains ( FnFlags :: IS_ASYNC )
93+ }
94+
95+ pub fn is_unsafe ( & self ) -> bool {
96+ self . flags . contains ( FnFlags :: IS_UNSAFE )
97+ }
98+
99+ pub fn is_in_extern_block ( & self ) -> bool {
100+ self . flags . contains ( FnFlags :: IS_IN_EXTERN_BLOCK )
101+ }
102+
103+ pub fn is_varargs ( & self ) -> bool {
104+ self . flags . contains ( FnFlags :: IS_VARARGS )
105+ }
75106}
76107
77108#[ derive( Debug , Clone , PartialEq , Eq ) ]
0 commit comments