2022-06-28 22:32:32 -07:00
|
|
|
use rustc_hir::ConstContext;
|
2022-11-02 11:57:40 +00:00
|
|
|
use rustc_macros::{Diagnostic, LintDiagnostic};
|
2022-06-28 21:26:05 -07:00
|
|
|
use rustc_span::Span;
|
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_unstable_in_stable)]
|
2022-06-28 21:26:05 -07:00
|
|
|
pub(crate) struct UnstableInStable {
|
|
|
|
pub gate: String,
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[suggestion(
|
2022-10-13 10:13:02 +01:00
|
|
|
const_eval_unstable_sugg,
|
2022-06-28 21:26:05 -07:00
|
|
|
code = "#[rustc_const_unstable(feature = \"...\", issue = \"...\")]\n",
|
|
|
|
applicability = "has-placeholders"
|
|
|
|
)]
|
|
|
|
#[suggestion(
|
2022-10-13 10:13:02 +01:00
|
|
|
const_eval_bypass_sugg,
|
2022-06-28 21:26:05 -07:00
|
|
|
code = "#[rustc_allow_const_fn_unstable({gate})]\n",
|
|
|
|
applicability = "has-placeholders"
|
|
|
|
)]
|
|
|
|
pub attr_span: Span,
|
|
|
|
}
|
2022-06-28 21:46:01 -07:00
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_thread_local_access, code = "E0625")]
|
2022-06-28 21:46:01 -07:00
|
|
|
pub(crate) struct NonConstOpErr {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
2022-06-28 22:32:32 -07:00
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_static_access, code = "E0013")]
|
2022-06-28 22:32:32 -07:00
|
|
|
#[help]
|
|
|
|
pub(crate) struct StaticAccessErr {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub kind: ConstContext,
|
2022-10-13 10:13:02 +01:00
|
|
|
#[note(const_eval_teach_note)]
|
|
|
|
#[help(const_eval_teach_help)]
|
2022-06-28 22:32:32 -07:00
|
|
|
pub teach: Option<()>,
|
|
|
|
}
|
2022-06-28 22:46:25 -07:00
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_raw_ptr_to_int)]
|
2022-06-28 22:46:25 -07:00
|
|
|
#[note]
|
2022-10-13 10:13:02 +01:00
|
|
|
#[note(const_eval_note2)]
|
2022-06-28 22:46:25 -07:00
|
|
|
pub(crate) struct RawPtrToIntErr {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_raw_ptr_comparison)]
|
2022-06-28 22:46:25 -07:00
|
|
|
#[note]
|
|
|
|
pub(crate) struct RawPtrComparisonErr {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_panic_non_str)]
|
2022-06-28 22:46:25 -07:00
|
|
|
pub(crate) struct PanicNonStrErr {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
2022-06-28 23:22:15 -07:00
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_mut_deref, code = "E0658")]
|
2022-06-28 23:22:15 -07:00
|
|
|
pub(crate) struct MutDerefErr {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub kind: ConstContext,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_transient_mut_borrow, code = "E0658")]
|
2022-06-28 23:22:15 -07:00
|
|
|
pub(crate) struct TransientMutBorrowErr {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub kind: ConstContext,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_transient_mut_borrow_raw, code = "E0658")]
|
2022-06-28 23:22:15 -07:00
|
|
|
pub(crate) struct TransientMutBorrowErrRaw {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub kind: ConstContext,
|
|
|
|
}
|
2022-08-18 01:54:11 -03:00
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_max_num_nodes_in_const)]
|
2022-08-20 16:27:41 -03:00
|
|
|
pub(crate) struct MaxNumNodesInConstErr {
|
2022-08-18 01:54:11 -03:00
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-08-22 12:14:49 -03:00
|
|
|
pub global_const_id: String,
|
2022-08-18 01:54:11 -03:00
|
|
|
}
|
2022-08-18 02:11:52 -03:00
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_unallowed_fn_pointer_call)]
|
2022-08-18 02:11:52 -03:00
|
|
|
pub(crate) struct UnallowedFnPointerCall {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub kind: ConstContext,
|
|
|
|
}
|
2022-08-18 22:49:59 -03:00
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_unstable_const_fn)]
|
2022-08-18 22:49:59 -03:00
|
|
|
pub(crate) struct UnstableConstFn {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-08-20 16:27:41 -03:00
|
|
|
pub def_path: String,
|
2022-08-18 22:49:59 -03:00
|
|
|
}
|
2022-08-19 15:36:09 -03:00
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_unallowed_mutable_refs, code = "E0764")]
|
2022-08-19 15:36:09 -03:00
|
|
|
pub(crate) struct UnallowedMutableRefs {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub kind: ConstContext,
|
2022-10-13 10:13:02 +01:00
|
|
|
#[note(const_eval_teach_note)]
|
2022-08-19 15:36:09 -03:00
|
|
|
pub teach: Option<()>,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_unallowed_mutable_refs_raw, code = "E0764")]
|
2022-08-19 15:36:09 -03:00
|
|
|
pub(crate) struct UnallowedMutableRefsRaw {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub kind: ConstContext,
|
2022-10-13 10:13:02 +01:00
|
|
|
#[note(const_eval_teach_note)]
|
2022-08-19 15:36:09 -03:00
|
|
|
pub teach: Option<()>,
|
|
|
|
}
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_non_const_fmt_macro_call, code = "E0015")]
|
2022-08-19 15:36:09 -03:00
|
|
|
pub(crate) struct NonConstFmtMacroCall {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub kind: ConstContext,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_non_const_fn_call, code = "E0015")]
|
2022-08-19 15:36:09 -03:00
|
|
|
pub(crate) struct NonConstFnCall {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub def_path_str: String,
|
|
|
|
pub kind: ConstContext,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_unallowed_op_in_const_context)]
|
2022-08-19 15:36:09 -03:00
|
|
|
pub(crate) struct UnallowedOpInConstContext {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub msg: String,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_unallowed_heap_allocations, code = "E0010")]
|
2022-08-19 15:36:09 -03:00
|
|
|
pub(crate) struct UnallowedHeapAllocations {
|
|
|
|
#[primary_span]
|
2022-08-20 16:27:41 -03:00
|
|
|
#[label]
|
2022-08-19 15:36:09 -03:00
|
|
|
pub span: Span,
|
|
|
|
pub kind: ConstContext,
|
2022-10-13 10:13:02 +01:00
|
|
|
#[note(const_eval_teach_note)]
|
2022-08-19 15:36:09 -03:00
|
|
|
pub teach: Option<()>,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_unallowed_inline_asm, code = "E0015")]
|
2022-08-19 15:36:09 -03:00
|
|
|
pub(crate) struct UnallowedInlineAsm {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub kind: ConstContext,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_interior_mutable_data_refer, code = "E0492")]
|
2022-08-19 15:36:09 -03:00
|
|
|
pub(crate) struct InteriorMutableDataRefer {
|
|
|
|
#[primary_span]
|
2022-08-20 16:27:41 -03:00
|
|
|
#[label]
|
2022-08-19 15:36:09 -03:00
|
|
|
pub span: Span,
|
|
|
|
#[help]
|
|
|
|
pub opt_help: Option<()>,
|
|
|
|
pub kind: ConstContext,
|
2022-10-13 10:13:02 +01:00
|
|
|
#[note(const_eval_teach_note)]
|
2022-08-19 15:36:09 -03:00
|
|
|
pub teach: Option<()>,
|
|
|
|
}
|
|
|
|
|
2022-09-18 11:46:56 -04:00
|
|
|
#[derive(Diagnostic)]
|
2022-10-22 11:07:54 +02:00
|
|
|
#[diag(const_eval_interior_mutability_borrow)]
|
2022-08-19 15:36:09 -03:00
|
|
|
pub(crate) struct InteriorMutabilityBorrow {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
2022-11-02 11:57:40 +00:00
|
|
|
|
|
|
|
#[derive(LintDiagnostic)]
|
|
|
|
#[diag(const_eval_long_running)]
|
|
|
|
#[note]
|
|
|
|
pub struct LongRunning {
|
|
|
|
#[help]
|
|
|
|
pub item_span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(const_eval_long_running)]
|
|
|
|
pub struct LongRunningWarn {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
|
|
|
#[help]
|
|
|
|
pub item_span: Span,
|
|
|
|
}
|