Migrated Unallowed function pointer calls in interpreter/ops
This commit is contained in:
parent
6af8e46a9a
commit
70ea98633e
3 changed files with 12 additions and 5 deletions
|
@ -95,3 +95,11 @@ pub(crate) struct MaxNumNodesExceeded {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub s: String,
|
pub s: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(SessionDiagnostic)]
|
||||||
|
#[error(const_eval::unallowed_fn_pointer_call)]
|
||||||
|
pub(crate) struct UnallowedFnPointerCall {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
pub kind: ConstContext,
|
||||||
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ use rustc_trait_selection::traits::SelectionContext;
|
||||||
use super::ConstCx;
|
use super::ConstCx;
|
||||||
use crate::errors::{
|
use crate::errors::{
|
||||||
MutDerefErr, NonConstOpErr, PanicNonStrErr, RawPtrToIntErr, StaticAccessErr,
|
MutDerefErr, NonConstOpErr, PanicNonStrErr, RawPtrToIntErr, StaticAccessErr,
|
||||||
TransientMutBorrowErr, TransientMutBorrowErrRaw,
|
TransientMutBorrowErr, TransientMutBorrowErrRaw, UnallowedFnPointerCall,
|
||||||
};
|
};
|
||||||
use crate::util::{call_kind, CallDesugaringKind, CallKind};
|
use crate::util::{call_kind, CallDesugaringKind, CallKind};
|
||||||
|
|
||||||
|
@ -97,10 +97,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallIndirect {
|
||||||
ccx: &ConstCx<'_, 'tcx>,
|
ccx: &ConstCx<'_, 'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||||
ccx.tcx.sess.struct_span_err(
|
ccx.tcx.sess.create_err(UnallowedFnPointerCall { span, kind: ccx.const_kind() })
|
||||||
span,
|
|
||||||
&format!("function pointer calls are not allowed in {}s", ccx.const_kind()),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,3 +31,5 @@ const_eval_transient_mut_borrow = mutable references are not allowed in {$kind}s
|
||||||
const_eval_transient_mut_borrow_raw = raw mutable references are not allowed in {$kind}s
|
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_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
|
Loading…
Add table
Add a link
Reference in a new issue