@@ -3640,7 +3640,7 @@ impl<'hir> Item<'hir> {
3640
3640
ItemKind :: Const ( ty, generics, body) , ( ty, generics, * body) ;
3641
3641
3642
3642
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) ;
3644
3644
3645
3645
expect_macro, ( & ast:: MacroDef , MacroKind ) , ItemKind :: Macro ( def, mk) , ( def, * mk) ;
3646
3646
@@ -3768,7 +3768,15 @@ pub enum ItemKind<'hir> {
3768
3768
/// A `const` item.
3769
3769
Const ( & ' hir Ty < ' hir > , & ' hir Generics < ' hir > , BodyId ) ,
3770
3770
/// 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
+ } ,
3772
3780
/// A MBE macro definition (`macro_rules!` or `macro`).
3773
3781
Macro ( & ' hir ast:: MacroDef , MacroKind ) ,
3774
3782
/// A module.
@@ -3819,7 +3827,7 @@ pub struct Impl<'hir> {
3819
3827
impl ItemKind < ' _ > {
3820
3828
pub fn generics ( & self ) -> Option < & Generics < ' _ > > {
3821
3829
Some ( match * self {
3822
- ItemKind :: Fn ( _ , ref generics, _ )
3830
+ ItemKind :: Fn { ref generics, .. }
3823
3831
| ItemKind :: TyAlias ( _, ref generics)
3824
3832
| ItemKind :: Const ( _, ref generics, _)
3825
3833
| ItemKind :: Enum ( _, ref generics)
@@ -3838,7 +3846,7 @@ impl ItemKind<'_> {
3838
3846
ItemKind :: Use ( ..) => "`use` import" ,
3839
3847
ItemKind :: Static ( ..) => "static item" ,
3840
3848
ItemKind :: Const ( ..) => "constant item" ,
3841
- ItemKind :: Fn ( .. ) => "function" ,
3849
+ ItemKind :: Fn { .. } => "function" ,
3842
3850
ItemKind :: Macro ( ..) => "macro" ,
3843
3851
ItemKind :: Mod ( ..) => "module" ,
3844
3852
ItemKind :: ForeignMod { .. } => "extern block" ,
@@ -4004,7 +4012,7 @@ impl<'hir> OwnerNode<'hir> {
4004
4012
match self {
4005
4013
OwnerNode :: TraitItem ( TraitItem { kind : TraitItemKind :: Fn ( fn_sig, _) , .. } )
4006
4014
| 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, .. } , .. } )
4008
4016
| OwnerNode :: ForeignItem ( ForeignItem {
4009
4017
kind : ForeignItemKind :: Fn ( fn_sig, _, _) , ..
4010
4018
} ) => Some ( fn_sig) ,
@@ -4016,7 +4024,7 @@ impl<'hir> OwnerNode<'hir> {
4016
4024
match self {
4017
4025
OwnerNode :: TraitItem ( TraitItem { kind : TraitItemKind :: Fn ( fn_sig, _) , .. } )
4018
4026
| 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, .. } , .. } )
4020
4028
| OwnerNode :: ForeignItem ( ForeignItem {
4021
4029
kind : ForeignItemKind :: Fn ( fn_sig, _, _) , ..
4022
4030
} ) => Some ( fn_sig. decl ) ,
@@ -4030,7 +4038,7 @@ impl<'hir> OwnerNode<'hir> {
4030
4038
kind :
4031
4039
ItemKind :: Static ( _, _, body)
4032
4040
| ItemKind :: Const ( _, _, body)
4033
- | ItemKind :: Fn ( _ , _ , body) ,
4041
+ | ItemKind :: Fn { body, .. } ,
4034
4042
..
4035
4043
} )
4036
4044
| OwnerNode :: TraitItem ( TraitItem {
@@ -4206,7 +4214,7 @@ impl<'hir> Node<'hir> {
4206
4214
match self {
4207
4215
Node :: TraitItem ( TraitItem { kind : TraitItemKind :: Fn ( fn_sig, _) , .. } )
4208
4216
| 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, .. } , .. } )
4210
4218
| Node :: ForeignItem ( ForeignItem { kind : ForeignItemKind :: Fn ( fn_sig, _, _) , .. } ) => {
4211
4219
Some ( fn_sig. decl )
4212
4220
}
@@ -4236,7 +4244,7 @@ impl<'hir> Node<'hir> {
4236
4244
match self {
4237
4245
Node :: TraitItem ( TraitItem { kind : TraitItemKind :: Fn ( fn_sig, _) , .. } )
4238
4246
| 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, .. } , .. } )
4240
4248
| Node :: ForeignItem ( ForeignItem { kind : ForeignItemKind :: Fn ( fn_sig, _, _) , .. } ) => {
4241
4249
Some ( fn_sig)
4242
4250
}
@@ -4281,7 +4289,7 @@ impl<'hir> Node<'hir> {
4281
4289
Node :: Item ( Item {
4282
4290
owner_id,
4283
4291
kind :
4284
- ItemKind :: Const ( _, _, body) | ItemKind :: Static ( .., body) | ItemKind :: Fn ( .. , body ) ,
4292
+ ItemKind :: Const ( _, _, body) | ItemKind :: Static ( .., body) | ItemKind :: Fn { body , .. } ,
4285
4293
..
4286
4294
} )
4287
4295
| Node :: TraitItem ( TraitItem {
@@ -4338,7 +4346,7 @@ impl<'hir> Node<'hir> {
4338
4346
pub fn fn_kind ( self ) -> Option < FnKind < ' hir > > {
4339
4347
match self {
4340
4348
Node :: Item ( i) => match i. kind {
4341
- ItemKind :: Fn ( ref sig, ref generics, _ ) => {
4349
+ ItemKind :: Fn { sig, generics, .. } => {
4342
4350
Some ( FnKind :: ItemFn ( i. ident , generics, sig. header ) )
4343
4351
}
4344
4352
_ => None ,
0 commit comments