@@ -74,16 +74,16 @@ enum ConstKind {
74
74
}
75
75
76
76
impl ConstKind {
77
- fn for_body ( body : & hir:: Body < ' _ > , hir_map : Map < ' _ > ) -> Option < Self > {
78
- let is_const_fn = |id| hir_map. fn_sig_by_hir_id ( id) . unwrap ( ) . header . is_const ( ) ;
79
-
80
- let owner = hir_map. body_owner ( body. id ( ) ) ;
81
- let const_kind = match hir_map. body_owner_kind ( owner) {
77
+ fn for_body ( body : & hir:: Body < ' _ > , tcx : TyCtxt < ' _ > ) -> Option < Self > {
78
+ let owner = tcx. hir ( ) . body_owner ( body. id ( ) ) ;
79
+ let const_kind = match tcx. hir ( ) . body_owner_kind ( owner) {
82
80
hir:: BodyOwnerKind :: Const => Self :: Const ,
83
81
hir:: BodyOwnerKind :: Static ( Mutability :: Mut ) => Self :: StaticMut ,
84
82
hir:: BodyOwnerKind :: Static ( Mutability :: Not ) => Self :: Static ,
85
83
86
- hir:: BodyOwnerKind :: Fn if is_const_fn ( owner) => Self :: ConstFn ,
84
+ hir:: BodyOwnerKind :: Fn if tcx. is_const_fn_raw ( tcx. hir ( ) . local_def_id ( owner) ) => {
85
+ Self :: ConstFn
86
+ }
87
87
hir:: BodyOwnerKind :: Fn | hir:: BodyOwnerKind :: Closure => return None ,
88
88
} ;
89
89
@@ -211,7 +211,7 @@ impl<'tcx> Visitor<'tcx> for CheckConstVisitor<'tcx> {
211
211
}
212
212
213
213
fn visit_body ( & mut self , body : & ' tcx hir:: Body < ' tcx > ) {
214
- let kind = ConstKind :: for_body ( body, self . tcx . hir ( ) ) ;
214
+ let kind = ConstKind :: for_body ( body, self . tcx ) ;
215
215
self . recurse_into ( kind, |this| intravisit:: walk_body ( this, body) ) ;
216
216
}
217
217
0 commit comments