Migrate NonConstOp diagnostic
This commit is contained in:
parent
934079fd9e
commit
1c4afbd1de
3 changed files with 12 additions and 7 deletions
|
@ -19,3 +19,10 @@ pub(crate) struct UnstableInStable {
|
||||||
)]
|
)]
|
||||||
pub attr_span: Span,
|
pub attr_span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(SessionDiagnostic)]
|
||||||
|
#[error(const_eval::thread_local_access, code = "E0625")]
|
||||||
|
pub(crate) struct NonConstOpErr {
|
||||||
|
#[primary_span]
|
||||||
|
pub span: Span,
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ use rustc_span::{BytePos, Pos, Span, Symbol};
|
||||||
use rustc_trait_selection::traits::SelectionContext;
|
use rustc_trait_selection::traits::SelectionContext;
|
||||||
|
|
||||||
use super::ConstCx;
|
use super::ConstCx;
|
||||||
|
use crate::errors::NonConstOpErr;
|
||||||
use crate::util::{call_kind, CallDesugaringKind, CallKind};
|
use crate::util::{call_kind, CallDesugaringKind, CallKind};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
|
@ -760,13 +761,7 @@ impl<'tcx> NonConstOp<'tcx> for ThreadLocalAccess {
|
||||||
ccx: &ConstCx<'_, 'tcx>,
|
ccx: &ConstCx<'_, 'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||||
struct_span_err!(
|
ccx.tcx.sess.create_err(NonConstOpErr { span })
|
||||||
ccx.tcx.sess,
|
|
||||||
span,
|
|
||||||
E0625,
|
|
||||||
"thread-local statics cannot be \
|
|
||||||
accessed at compile-time"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,3 +2,6 @@ const-eval-unstable-in-stable =
|
||||||
const-stable function cannot use `#[feature({$gate})]`
|
const-stable function cannot use `#[feature({$gate})]`
|
||||||
.unstable-sugg = if it is not part of the public API, make this function unstably const
|
.unstable-sugg = if it is not part of the public API, make this function unstably const
|
||||||
.bypass-sugg = otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks
|
.bypass-sugg = otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks
|
||||||
|
|
||||||
|
const-eval-thread-local-access =
|
||||||
|
thread-local statics cannot be accessed at compile-time
|
Loading…
Add table
Add a link
Reference in a new issue