Migration on ops.rs for unstable const functions
This commit is contained in:
parent
70ea98633e
commit
33e8aaf830
@ -103,3 +103,11 @@ pub(crate) struct UnallowedFnPointerCall {
|
||||
pub span: Span,
|
||||
pub kind: ConstContext,
|
||||
}
|
||||
|
||||
#[derive(SessionDiagnostic)]
|
||||
#[error(const_eval::unstable_const_fn)]
|
||||
pub(crate) struct UnstableConstFn {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub def_id: String,
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ use rustc_trait_selection::traits::SelectionContext;
|
||||
use super::ConstCx;
|
||||
use crate::errors::{
|
||||
MutDerefErr, NonConstOpErr, PanicNonStrErr, RawPtrToIntErr, StaticAccessErr,
|
||||
TransientMutBorrowErr, TransientMutBorrowErrRaw, UnallowedFnPointerCall,
|
||||
TransientMutBorrowErr, TransientMutBorrowErrRaw, UnallowedFnPointerCall, UnstableConstFn,
|
||||
};
|
||||
use crate::util::{call_kind, CallDesugaringKind, CallKind};
|
||||
|
||||
@ -351,10 +351,8 @@ impl<'tcx> NonConstOp<'tcx> for FnCallUnstable {
|
||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||
let FnCallUnstable(def_id, feature) = *self;
|
||||
|
||||
let mut err = ccx.tcx.sess.struct_span_err(
|
||||
span,
|
||||
&format!("`{}` is not yet stable as a const fn", ccx.tcx.def_path_str(def_id)),
|
||||
);
|
||||
let mut err =
|
||||
ccx.tcx.sess.create_err(UnstableConstFn { span, def_id: ccx.tcx.def_path_str(def_id) });
|
||||
|
||||
if ccx.is_const_stable_const_fn() {
|
||||
err.help("const-stable functions can only call other const-stable functions");
|
||||
|
@ -32,4 +32,6 @@ const_eval_transient_mut_borrow_raw = raw mutable references are not allowed in
|
||||
|
||||
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
|
||||
const_eval_unallowed_fn_pointer_call = function pointer calls are not allowed in {$kind}s
|
||||
|
||||
const_eval_unstable_const_fn = `{$def_id}` is not yet stable as a const fn
|
Loading…
x
Reference in New Issue
Block a user