@@ -827,6 +827,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
827827 constness : hir:: Constness :: NotConst ,
828828 arg_names,
829829 sig : self . lazy ( & tcx. fn_sig ( def_id) ) ,
830+ qualif : None ,
830831 }
831832 } else {
832833 bug ! ( )
@@ -880,6 +881,20 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
880881 !self . tcx . sess . opts . output_types . should_codegen ( )
881882 }
882883
884+ fn const_fn_qualif (
885+ & self ,
886+ def_id : DefId ,
887+ body_id : hir:: BodyId ,
888+ span : Span ,
889+ ) -> Option < ConstQualif > {
890+ if self . tcx . is_const_fn ( def_id) {
891+ let mir = self . tcx . at ( span) . mir_const_qualif ( def_id) . 0 ;
892+ Some ( self . const_qualif ( mir, body_id) )
893+ } else {
894+ None
895+ }
896+ }
897+
883898 fn const_qualif ( & self , mir : u8 , body_id : hir:: BodyId ) -> ConstQualif {
884899 let body_owner_def_id = self . tcx . hir . body_owner_def_id ( body_id) ;
885900 let ast_promotable = self . tcx . const_is_rvalue_promotable_to_static ( body_owner_def_id) ;
@@ -915,11 +930,12 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
915930 }
916931 }
917932 ty:: AssociatedKind :: Method => {
918- let fn_data = if let hir:: ImplItemKind :: Method ( ref sig, body ) = ast_item. node {
933+ let fn_data = if let hir:: ImplItemKind :: Method ( ref sig, body_id ) = ast_item. node {
919934 FnData {
920935 constness : sig. constness ,
921- arg_names : self . encode_fn_arg_names_for_body ( body ) ,
936+ arg_names : self . encode_fn_arg_names_for_body ( body_id ) ,
922937 sig : self . lazy ( & tcx. fn_sig ( def_id) ) ,
938+ qualif : self . const_fn_qualif ( def_id, body_id, ast_item. span ) ,
923939 }
924940 } else {
925941 bug ! ( )
@@ -1045,13 +1061,13 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
10451061 self . encode_rendered_const_for_body ( body_id)
10461062 )
10471063 }
1048- hir:: ItemFn ( _, _, constness, .., body ) => {
1064+ hir:: ItemFn ( _, _, constness, .., body_id ) => {
10491065 let data = FnData {
10501066 constness,
1051- arg_names : self . encode_fn_arg_names_for_body ( body ) ,
1067+ arg_names : self . encode_fn_arg_names_for_body ( body_id ) ,
10521068 sig : self . lazy ( & tcx. fn_sig ( def_id) ) ,
1069+ qualif : self . const_fn_qualif ( def_id, body_id, item. span ) ,
10531070 } ;
1054-
10551071 EntryKind :: Fn ( self . lazy ( & data) )
10561072 }
10571073 hir:: ItemMod ( ref m) => {
@@ -1565,6 +1581,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
15651581 constness : hir:: Constness :: NotConst ,
15661582 arg_names : self . encode_fn_arg_names ( names) ,
15671583 sig : self . lazy ( & tcx. fn_sig ( def_id) ) ,
1584+ qualif : None ,
15681585 } ;
15691586 EntryKind :: ForeignFn ( self . lazy ( & data) )
15701587 }
0 commit comments