@@ -827,6 +827,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
827
827
constness : hir:: Constness :: NotConst ,
828
828
arg_names,
829
829
sig : self . lazy ( & tcx. fn_sig ( def_id) ) ,
830
+ qualif : None ,
830
831
}
831
832
} else {
832
833
bug ! ( )
@@ -880,6 +881,20 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
880
881
!self . tcx . sess . opts . output_types . should_codegen ( )
881
882
}
882
883
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
+
883
898
fn const_qualif ( & self , mir : u8 , body_id : hir:: BodyId ) -> ConstQualif {
884
899
let body_owner_def_id = self . tcx . hir . body_owner_def_id ( body_id) ;
885
900
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> {
915
930
}
916
931
}
917
932
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 {
919
934
FnData {
920
935
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 ) ,
922
937
sig : self . lazy ( & tcx. fn_sig ( def_id) ) ,
938
+ qualif : self . const_fn_qualif ( def_id, body_id, ast_item. span ) ,
923
939
}
924
940
} else {
925
941
bug ! ( )
@@ -1045,13 +1061,13 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
1045
1061
self . encode_rendered_const_for_body ( body_id)
1046
1062
)
1047
1063
}
1048
- hir:: ItemFn ( _, _, constness, .., body ) => {
1064
+ hir:: ItemFn ( _, _, constness, .., body_id ) => {
1049
1065
let data = FnData {
1050
1066
constness,
1051
- arg_names : self . encode_fn_arg_names_for_body ( body ) ,
1067
+ arg_names : self . encode_fn_arg_names_for_body ( body_id ) ,
1052
1068
sig : self . lazy ( & tcx. fn_sig ( def_id) ) ,
1069
+ qualif : self . const_fn_qualif ( def_id, body_id, item. span ) ,
1053
1070
} ;
1054
-
1055
1071
EntryKind :: Fn ( self . lazy ( & data) )
1056
1072
}
1057
1073
hir:: ItemMod ( ref m) => {
@@ -1565,6 +1581,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
1565
1581
constness : hir:: Constness :: NotConst ,
1566
1582
arg_names : self . encode_fn_arg_names ( names) ,
1567
1583
sig : self . lazy ( & tcx. fn_sig ( def_id) ) ,
1584
+ qualif : None ,
1568
1585
} ;
1569
1586
EntryKind :: ForeignFn ( self . lazy ( & data) )
1570
1587
}
0 commit comments