@@ -213,11 +213,21 @@ impl NonConstOp for FnPtrCast {
213
213
const STOPS_CONST_CHECKING : bool = true ;
214
214
215
215
fn status_in_item ( & self , ccx : & ConstCx < ' _ , ' _ > ) -> Status {
216
- mcf_status_in_item ( ccx)
216
+ if ccx. const_kind ( ) != hir:: ConstContext :: ConstFn {
217
+ Status :: Allowed
218
+ } else {
219
+ Status :: Unstable ( sym:: const_fn_fn_ptr_basics)
220
+ }
217
221
}
218
222
219
223
fn emit_error ( & self , ccx : & ConstCx < ' _ , ' _ > , span : Span ) {
220
- mcf_emit_error ( ccx, span, "function pointer casts are not allowed in const fn" ) ;
224
+ feature_err (
225
+ & ccx. tcx . sess . parse_sess ,
226
+ sym:: const_fn_fn_ptr_basics,
227
+ span,
228
+ & format ! ( "function pointer casts are not allowed in {}s" , ccx. const_kind( ) ) ,
229
+ )
230
+ . emit ( )
221
231
}
222
232
}
223
233
@@ -596,17 +606,21 @@ pub mod ty {
596
606
const STOPS_CONST_CHECKING : bool = true ;
597
607
598
608
fn status_in_item ( & self , ccx : & ConstCx < ' _ , ' _ > ) -> Status {
599
- // FIXME: This attribute a hack to allow the specialization of the `futures` API. See
600
- // #59739. We should have a proper feature gate for this.
601
- if ccx. tcx . has_attr ( ccx. def_id . to_def_id ( ) , sym:: rustc_allow_const_fn_ptr) {
609
+ if ccx. const_kind ( ) != hir:: ConstContext :: ConstFn {
602
610
Status :: Allowed
603
611
} else {
604
- mcf_status_in_item ( ccx )
612
+ Status :: Unstable ( sym :: const_fn_fn_ptr_basics )
605
613
}
606
614
}
607
615
608
616
fn emit_error ( & self , ccx : & ConstCx < ' _ , ' _ > , span : Span ) {
609
- mcf_emit_error ( ccx, span, "function pointers in const fn are unstable" ) ;
617
+ feature_err (
618
+ & ccx. tcx . sess . parse_sess ,
619
+ sym:: const_fn_fn_ptr_basics,
620
+ span,
621
+ & format ! ( "function pointers cannot appear in {}s" , ccx. const_kind( ) ) ,
622
+ )
623
+ . emit ( )
610
624
}
611
625
}
612
626
0 commit comments