Migration on ops.rs for unstable const functions
This commit is contained in:
parent
70ea98633e
commit
33e8aaf830
3 changed files with 14 additions and 6 deletions
|
@ -103,3 +103,11 @@ pub(crate) struct UnallowedFnPointerCall {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub kind: ConstContext,
|
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 super::ConstCx;
|
||||||
use crate::errors::{
|
use crate::errors::{
|
||||||
MutDerefErr, NonConstOpErr, PanicNonStrErr, RawPtrToIntErr, StaticAccessErr,
|
MutDerefErr, NonConstOpErr, PanicNonStrErr, RawPtrToIntErr, StaticAccessErr,
|
||||||
TransientMutBorrowErr, TransientMutBorrowErrRaw, UnallowedFnPointerCall,
|
TransientMutBorrowErr, TransientMutBorrowErrRaw, UnallowedFnPointerCall, UnstableConstFn,
|
||||||
};
|
};
|
||||||
use crate::util::{call_kind, CallDesugaringKind, CallKind};
|
use crate::util::{call_kind, CallDesugaringKind, CallKind};
|
||||||
|
|
||||||
|
@ -351,10 +351,8 @@ impl<'tcx> NonConstOp<'tcx> for FnCallUnstable {
|
||||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||||
let FnCallUnstable(def_id, feature) = *self;
|
let FnCallUnstable(def_id, feature) = *self;
|
||||||
|
|
||||||
let mut err = ccx.tcx.sess.struct_span_err(
|
let mut err =
|
||||||
span,
|
ccx.tcx.sess.create_err(UnstableConstFn { span, def_id: ccx.tcx.def_path_str(def_id) });
|
||||||
&format!("`{}` is not yet stable as a const fn", ccx.tcx.def_path_str(def_id)),
|
|
||||||
);
|
|
||||||
|
|
||||||
if ccx.is_const_stable_const_fn() {
|
if ccx.is_const_stable_const_fn() {
|
||||||
err.help("const-stable functions can only call other const-stable functions");
|
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_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…
Add table
Add a link
Reference in a new issue