1use flux_errors::E0999;
2use flux_macros::Diagnostic;
3use flux_syntax::surface;
4use rustc_span::{Span, Symbol};
5
6#[derive(Diagnostic)]
7#[diag("integer literal is too large", code = E0999)]
8pub(super) struct IntTooLarge {
9 #[primary_span]
10 pub(super) span: Span,
11}
12
13#[derive(Diagnostic)]
14#[diag("unexpected literal", code = E0999)]
15pub(super) struct UnexpectedLiteral {
16 #[primary_span]
17 pub(super) span: Span,
18}
19
20#[derive(Diagnostic)]
21#[diag("invalid use of path in constructor", code = E0999)]
22pub(super) struct InvalidConstructorPath {
23 #[primary_span]
24 pub(super) span: Span,
25}
26
27#[derive(Diagnostic)]
28#[diag("expected an `&strg` parameter", code = E0999)]
29pub(super) struct InvalidLoc {
30 #[primary_span]
31 pub(super) span: Span,
32}
33
34#[derive(Diagnostic)]
35#[diag("invalid suffix `{$suffix}` for number literal", code = E0999)]
36pub(super) struct InvalidNumericSuffix {
37 #[primary_span]
38 #[label(
39 "the suffix must be the numeric sort `int`; use a float literal (e.g. `1.0`) for `real`"
40 )]
41 span: Span,
42 suffix: Symbol,
43}
44
45impl InvalidNumericSuffix {
46 pub(super) fn new(span: Span, suffix: Symbol) -> Self {
47 Self { span, suffix }
48 }
49}
50
51#[derive(Diagnostic)]
52#[diag("invalid alias refinement", code = E0999)]
53pub(super) struct InvalidAliasReft {
54 #[primary_span]
55 #[label("this must be a trait")]
56 pub(super) span: Span,
57}
58
59impl InvalidAliasReft {
60 pub(super) fn new(path: &surface::Path) -> Self {
61 Self { span: path.span }
62 }
63}
64
65#[derive(Diagnostic)]
66#[diag("invalid variant return type", code = E0999)]
67pub(super) struct InvalidVariantRet {
68 #[primary_span]
69 pub(super) span: Span,
70}
71
72impl InvalidVariantRet {
73 pub(super) fn new(path: &surface::Path) -> Self {
74 Self { span: path.span }
75 }
76}
77
78#[derive(Diagnostic)]
79#[diag("reflected types cannot have refinement annotations", code = E0999)]
80pub(super) struct InvalidReflectedVariant {
81 #[primary_span]
82 pub(super) span: Span,
83}
84
85impl InvalidReflectedVariant {
86 pub(super) fn new(span: Span) -> Self {
87 Self { span }
88 }
89}
90
91#[derive(Diagnostic)]
92#[diag("multiple spreads found in constructor", code = E0999)]
93pub(super) struct MultipleSpreadsInConstructor {
94 #[primary_span]
95 pub(super) span: Span,
96 #[help("previous spread found here. consider removing it")]
97 pub(super) prev_span: Span,
98}
99
100impl MultipleSpreadsInConstructor {
101 pub(super) fn new(span: Span, prev_span: Span) -> Self {
102 Self { span, prev_span }
103 }
104}
105
106#[derive(Diagnostic)]
107#[diag("expression not allowed in this position", code = E0999)]
108pub(super) struct UnsupportedPosition {
109 #[primary_span]
110 span: Span,
111}
112
113impl UnsupportedPosition {
114 pub(super) fn new(span: Span) -> Self {
115 Self { span }
116 }
117}
118
119#[derive(Diagnostic)]
120#[diag("invalid ABI: found `{$abi}`", code = E0999)]
121pub(super) struct InvalidAbi {
122 #[primary_span]
123 #[label("invalid ABI")]
124 span: Span,
125 abi: Symbol,
126}
127
128impl InvalidAbi {
129 pub(super) fn new(abi: flux_syntax::surface::Ident) -> Self {
130 Self { span: abi.span, abi: abi.name }
131 }
132}
133
134#[derive(Diagnostic)]
135#[diag("invalid use of `_`", code = E0999)]
136pub(super) struct UnsupportedHole {
137 #[primary_span]
138 #[label("holes cannot be filled in this position")]
139 span: Span,
140}
141
142impl UnsupportedHole {
143 pub(super) fn new(span: Span) -> Self {
144 Self { span }
145 }
146}
147
148#[derive(Diagnostic)]
149#[diag("final associated refinements must have a body", code = E0999)]
150pub(super) struct FinalAssocReftWithoutBody {
151 #[primary_span]
152 span: Span,
153}
154
155impl FinalAssocReftWithoutBody {
156 pub(super) fn new(span: Span) -> Self {
157 Self { span }
158 }
159}
160
161#[derive(Diagnostic)]
162#[diag("`{$res_descr}` not supported in this position", code = E0999)]
163pub(super) struct UnsupportedConstGenericArg {
164 #[primary_span]
165 #[label("help: try using `_` instead")]
166 span: Span,
167 res_descr: &'static str,
168}
169
170impl UnsupportedConstGenericArg {
171 pub(super) fn new(span: Span, res_descr: &'static str) -> Self {
172 Self { span, res_descr }
173 }
174}
175
176#[derive(Diagnostic)]
177#[diag("unsupported function signature", code = E0999)]
178#[note("{$note}")]
179pub(super) struct UnsupportedSignature<'a> {
180 #[primary_span]
181 pub span: Span,
182 pub note: &'a str,
183}