@@ -3640,7 +3640,7 @@ impl<'hir> Item<'hir> {
36403640 ItemKind :: Const ( ty, generics, body) , ( ty, generics, * body) ;
36413641
36423642 expect_fn, ( & FnSig <' hir>, & ' hir Generics <' hir>, BodyId ) ,
3643- ItemKind :: Fn ( sig, generics, body) , ( sig, generics, * body) ;
3643+ ItemKind :: Fn { sig, generics, body, .. } , ( sig, generics, * body) ;
36443644
36453645 expect_macro, ( & ast:: MacroDef , MacroKind ) , ItemKind :: Macro ( def, mk) , ( def, * mk) ;
36463646
@@ -3768,7 +3768,15 @@ pub enum ItemKind<'hir> {
37683768 /// A `const` item.
37693769 Const ( & ' hir Ty < ' hir > , & ' hir Generics < ' hir > , BodyId ) ,
37703770 /// A function declaration.
3771- Fn ( FnSig < ' hir > , & ' hir Generics < ' hir > , BodyId ) ,
3771+ Fn {
3772+ sig : FnSig < ' hir > ,
3773+ generics : & ' hir Generics < ' hir > ,
3774+ body : BodyId ,
3775+ /// Whether this function actually has a body.
3776+ /// For functions without a body, `body` is synthesized (to avoid ICEs all over the
3777+ /// compiler), but that code should never be translated.
3778+ has_body : bool ,
3779+ } ,
37723780 /// A MBE macro definition (`macro_rules!` or `macro`).
37733781 Macro ( & ' hir ast:: MacroDef , MacroKind ) ,
37743782 /// A module.
@@ -3819,7 +3827,7 @@ pub struct Impl<'hir> {
38193827impl ItemKind < ' _ > {
38203828 pub fn generics ( & self ) -> Option < & Generics < ' _ > > {
38213829 Some ( match * self {
3822- ItemKind :: Fn ( _ , ref generics, _ )
3830+ ItemKind :: Fn { ref generics, .. }
38233831 | ItemKind :: TyAlias ( _, ref generics)
38243832 | ItemKind :: Const ( _, ref generics, _)
38253833 | ItemKind :: Enum ( _, ref generics)
@@ -3838,7 +3846,7 @@ impl ItemKind<'_> {
38383846 ItemKind :: Use ( ..) => "`use` import" ,
38393847 ItemKind :: Static ( ..) => "static item" ,
38403848 ItemKind :: Const ( ..) => "constant item" ,
3841- ItemKind :: Fn ( .. ) => "function" ,
3849+ ItemKind :: Fn { .. } => "function" ,
38423850 ItemKind :: Macro ( ..) => "macro" ,
38433851 ItemKind :: Mod ( ..) => "module" ,
38443852 ItemKind :: ForeignMod { .. } => "extern block" ,
@@ -4004,7 +4012,7 @@ impl<'hir> OwnerNode<'hir> {
40044012 match self {
40054013 OwnerNode :: TraitItem ( TraitItem { kind : TraitItemKind :: Fn ( fn_sig, _) , .. } )
40064014 | OwnerNode :: ImplItem ( ImplItem { kind : ImplItemKind :: Fn ( fn_sig, _) , .. } )
4007- | OwnerNode :: Item ( Item { kind : ItemKind :: Fn ( fn_sig, _ , _ ) , .. } )
4015+ | OwnerNode :: Item ( Item { kind : ItemKind :: Fn { sig : fn_sig, .. } , .. } )
40084016 | OwnerNode :: ForeignItem ( ForeignItem {
40094017 kind : ForeignItemKind :: Fn ( fn_sig, _, _) , ..
40104018 } ) => Some ( fn_sig) ,
@@ -4016,7 +4024,7 @@ impl<'hir> OwnerNode<'hir> {
40164024 match self {
40174025 OwnerNode :: TraitItem ( TraitItem { kind : TraitItemKind :: Fn ( fn_sig, _) , .. } )
40184026 | OwnerNode :: ImplItem ( ImplItem { kind : ImplItemKind :: Fn ( fn_sig, _) , .. } )
4019- | OwnerNode :: Item ( Item { kind : ItemKind :: Fn ( fn_sig, _ , _ ) , .. } )
4027+ | OwnerNode :: Item ( Item { kind : ItemKind :: Fn { sig : fn_sig, .. } , .. } )
40204028 | OwnerNode :: ForeignItem ( ForeignItem {
40214029 kind : ForeignItemKind :: Fn ( fn_sig, _, _) , ..
40224030 } ) => Some ( fn_sig. decl ) ,
@@ -4030,7 +4038,7 @@ impl<'hir> OwnerNode<'hir> {
40304038 kind :
40314039 ItemKind :: Static ( _, _, body)
40324040 | ItemKind :: Const ( _, _, body)
4033- | ItemKind :: Fn ( _ , _ , body) ,
4041+ | ItemKind :: Fn { body, .. } ,
40344042 ..
40354043 } )
40364044 | OwnerNode :: TraitItem ( TraitItem {
@@ -4206,7 +4214,7 @@ impl<'hir> Node<'hir> {
42064214 match self {
42074215 Node :: TraitItem ( TraitItem { kind : TraitItemKind :: Fn ( fn_sig, _) , .. } )
42084216 | Node :: ImplItem ( ImplItem { kind : ImplItemKind :: Fn ( fn_sig, _) , .. } )
4209- | Node :: Item ( Item { kind : ItemKind :: Fn ( fn_sig, _ , _ ) , .. } )
4217+ | Node :: Item ( Item { kind : ItemKind :: Fn { sig : fn_sig, .. } , .. } )
42104218 | Node :: ForeignItem ( ForeignItem { kind : ForeignItemKind :: Fn ( fn_sig, _, _) , .. } ) => {
42114219 Some ( fn_sig. decl )
42124220 }
@@ -4236,7 +4244,7 @@ impl<'hir> Node<'hir> {
42364244 match self {
42374245 Node :: TraitItem ( TraitItem { kind : TraitItemKind :: Fn ( fn_sig, _) , .. } )
42384246 | Node :: ImplItem ( ImplItem { kind : ImplItemKind :: Fn ( fn_sig, _) , .. } )
4239- | Node :: Item ( Item { kind : ItemKind :: Fn ( fn_sig, _ , _ ) , .. } )
4247+ | Node :: Item ( Item { kind : ItemKind :: Fn { sig : fn_sig, .. } , .. } )
42404248 | Node :: ForeignItem ( ForeignItem { kind : ForeignItemKind :: Fn ( fn_sig, _, _) , .. } ) => {
42414249 Some ( fn_sig)
42424250 }
@@ -4281,7 +4289,7 @@ impl<'hir> Node<'hir> {
42814289 Node :: Item ( Item {
42824290 owner_id,
42834291 kind :
4284- ItemKind :: Const ( _, _, body) | ItemKind :: Static ( .., body) | ItemKind :: Fn ( .. , body ) ,
4292+ ItemKind :: Const ( _, _, body) | ItemKind :: Static ( .., body) | ItemKind :: Fn { body , .. } ,
42854293 ..
42864294 } )
42874295 | Node :: TraitItem ( TraitItem {
@@ -4338,7 +4346,7 @@ impl<'hir> Node<'hir> {
43384346 pub fn fn_kind ( self ) -> Option < FnKind < ' hir > > {
43394347 match self {
43404348 Node :: Item ( i) => match i. kind {
4341- ItemKind :: Fn ( ref sig, ref generics, _ ) => {
4349+ ItemKind :: Fn { sig, generics, .. } => {
43424350 Some ( FnKind :: ItemFn ( i. ident , generics, sig. header ) )
43434351 }
43444352 _ => None ,
0 commit comments