]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_const_eval/src/errors.rs
Rollup merge of #100458 - compiler-errors:fn-argument-span, r=estebank
[rust.git] / compiler / rustc_const_eval / src / errors.rs
1 use rustc_hir::ConstContext;
2 use rustc_macros::SessionDiagnostic;
3 use rustc_span::Span;
4
5 #[derive(SessionDiagnostic)]
6 #[error(const_eval::unstable_in_stable)]
7 pub(crate) struct UnstableInStable {
8     pub gate: String,
9     #[primary_span]
10     pub span: Span,
11     #[suggestion(
12         const_eval::unstable_sugg,
13         code = "#[rustc_const_unstable(feature = \"...\", issue = \"...\")]\n",
14         applicability = "has-placeholders"
15     )]
16     #[suggestion(
17         const_eval::bypass_sugg,
18         code = "#[rustc_allow_const_fn_unstable({gate})]\n",
19         applicability = "has-placeholders"
20     )]
21     pub attr_span: Span,
22 }
23
24 #[derive(SessionDiagnostic)]
25 #[error(const_eval::thread_local_access, code = "E0625")]
26 pub(crate) struct NonConstOpErr {
27     #[primary_span]
28     pub span: Span,
29 }
30
31 #[derive(SessionDiagnostic)]
32 #[error(const_eval::static_access, code = "E0013")]
33 #[help]
34 pub(crate) struct StaticAccessErr {
35     #[primary_span]
36     pub span: Span,
37     pub kind: ConstContext,
38     #[note(const_eval::teach_note)]
39     #[help(const_eval::teach_help)]
40     pub teach: Option<()>,
41 }
42
43 #[derive(SessionDiagnostic)]
44 #[error(const_eval::raw_ptr_to_int)]
45 #[note]
46 #[note(const_eval::note2)]
47 pub(crate) struct RawPtrToIntErr {
48     #[primary_span]
49     pub span: Span,
50 }
51
52 #[derive(SessionDiagnostic)]
53 #[error(const_eval::raw_ptr_comparison)]
54 #[note]
55 pub(crate) struct RawPtrComparisonErr {
56     #[primary_span]
57     pub span: Span,
58 }
59
60 #[derive(SessionDiagnostic)]
61 #[error(const_eval::panic_non_str)]
62 pub(crate) struct PanicNonStrErr {
63     #[primary_span]
64     pub span: Span,
65 }
66
67 #[derive(SessionDiagnostic)]
68 #[error(const_eval::mut_deref, code = "E0658")]
69 pub(crate) struct MutDerefErr {
70     #[primary_span]
71     pub span: Span,
72     pub kind: ConstContext,
73 }
74
75 #[derive(SessionDiagnostic)]
76 #[error(const_eval::transient_mut_borrow, code = "E0658")]
77 pub(crate) struct TransientMutBorrowErr {
78     #[primary_span]
79     pub span: Span,
80     pub kind: ConstContext,
81 }
82
83 #[derive(SessionDiagnostic)]
84 #[error(const_eval::transient_mut_borrow_raw, code = "E0658")]
85 pub(crate) struct TransientMutBorrowErrRaw {
86     #[primary_span]
87     pub span: Span,
88     pub kind: ConstContext,
89 }