pub span: Span,
pub s: String,
}
+
+#[derive(SessionDiagnostic)]
+#[error(const_eval::unallowed_fn_pointer_call)]
+pub(crate) struct UnallowedFnPointerCall {
+ #[primary_span]
+ pub span: Span,
+ pub kind: ConstContext,
+}
use super::ConstCx;
use crate::errors::{
MutDerefErr, NonConstOpErr, PanicNonStrErr, RawPtrToIntErr, StaticAccessErr,
- TransientMutBorrowErr, TransientMutBorrowErrRaw,
+ TransientMutBorrowErr, TransientMutBorrowErrRaw, UnallowedFnPointerCall,
};
use crate::util::{call_kind, CallDesugaringKind, CallKind};
ccx: &ConstCx<'_, 'tcx>,
span: Span,
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
- ccx.tcx.sess.struct_span_err(
- span,
- &format!("function pointer calls are not allowed in {}s", ccx.const_kind()),
- )
+ ccx.tcx.sess.create_err(UnallowedFnPointerCall { span, kind: ccx.const_kind() })
}
}
const_eval_transient_mut_borrow_raw = raw mutable references are not allowed in {$kind}s
const_evaL_max_num_nodes_exceeded = maximum number of nodes exceeded in constant {$s}
+
+const_eval_unallowed_fn_pointer_call = function pointer calls are not allowed in {$const_kind}s
\ No newline at end of file