]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_typeck/src/errors.rs
7531a231e3951daaa0970e73f0ef82b5f5e0dad1
[rust.git] / compiler / rustc_typeck / src / errors.rs
1 //! Errors emitted by typeck.
2 use rustc_macros::SessionDiagnostic;
3 use rustc_span::{symbol::Ident, Span, Symbol};
4
5 #[derive(SessionDiagnostic)]
6 #[error(code = "E0062", slug = "typeck-field-multiply-specified-in-initializer")]
7 pub struct FieldMultiplySpecifiedInInitializer {
8     #[primary_span]
9     #[label = "used more than once"]
10     pub span: Span,
11     #[label = "first use of `{ident}`"]
12     pub prev_span: Span,
13     pub ident: Ident,
14 }
15
16 #[derive(SessionDiagnostic)]
17 #[error(code = "E0092", slug = "typeck-unrecognized-atomic-operation")]
18 pub struct UnrecognizedAtomicOperation<'a> {
19     #[primary_span]
20     #[label = "unrecognized atomic operation"]
21     pub span: Span,
22     pub op: &'a str,
23 }
24
25 #[derive(SessionDiagnostic)]
26 #[error(code = "E0094", slug = "typeck-wrong-number-of-generic-arguments-to-intrinsic")]
27 pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
28     #[primary_span]
29     #[label = "expected {expected} {descr} parameter{expected_pluralize}"]
30     pub span: Span,
31     pub found: usize,
32     pub expected: usize,
33     pub expected_pluralize: &'a str,
34     pub descr: &'a str,
35 }
36
37 #[derive(SessionDiagnostic)]
38 #[error(code = "E0093", slug = "typeck-unrecognized-intrinsic-function")]
39 pub struct UnrecognizedIntrinsicFunction {
40     #[primary_span]
41     #[label = "unrecognized intrinsic"]
42     pub span: Span,
43     pub name: Symbol,
44 }
45
46 #[derive(SessionDiagnostic)]
47 #[error(code = "E0195", slug = "typeck-lifetimes-or-bounds-mismatch-on-trait")]
48 pub struct LifetimesOrBoundsMismatchOnTrait {
49     #[primary_span]
50     #[label = "lifetimes do not match {item_kind} in trait"]
51     pub span: Span,
52     #[label = "lifetimes in impl do not match this {item_kind} in trait"]
53     pub generics_span: Option<Span>,
54     pub item_kind: &'static str,
55     pub ident: Ident,
56 }
57
58 #[derive(SessionDiagnostic)]
59 #[error(code = "E0120", slug = "typeck-drop-impl-on-wrong-item")]
60 pub struct DropImplOnWrongItem {
61     #[primary_span]
62     #[label = "must be a struct, enum, or union"]
63     pub span: Span,
64 }
65
66 #[derive(SessionDiagnostic)]
67 #[error(code = "E0124", slug = "typeck-field-already-declared")]
68 pub struct FieldAlreadyDeclared {
69     pub field_name: Ident,
70     #[primary_span]
71     #[label = "field already declared"]
72     pub span: Span,
73     #[label = "`{field_name}` first declared here"]
74     pub prev_span: Span,
75 }
76
77 #[derive(SessionDiagnostic)]
78 #[error(code = "E0184", slug = "typeck-copy-impl-on-type-with-dtor")]
79 pub struct CopyImplOnTypeWithDtor {
80     #[primary_span]
81     #[label = "Copy not allowed on types with destructors"]
82     pub span: Span,
83 }
84
85 #[derive(SessionDiagnostic)]
86 #[error(code = "E0203", slug = "typeck-multiple-relaxed-default-bounds")]
87 pub struct MultipleRelaxedDefaultBounds {
88     #[primary_span]
89     pub span: Span,
90 }
91
92 #[derive(SessionDiagnostic)]
93 #[error(code = "E0206", slug = "typeck-copy-impl-on-non-adt")]
94 pub struct CopyImplOnNonAdt {
95     #[primary_span]
96     #[label = "type is not a structure or enumeration"]
97     pub span: Span,
98 }
99
100 #[derive(SessionDiagnostic)]
101 #[error(code = "E0224", slug = "typeck-trait-object-declared-with-no-traits")]
102 pub struct TraitObjectDeclaredWithNoTraits {
103     #[primary_span]
104     pub span: Span,
105 }
106
107 #[derive(SessionDiagnostic)]
108 #[error(code = "E0227", slug = "typeck-ambiguous-lifetime-bound")]
109 pub struct AmbiguousLifetimeBound {
110     #[primary_span]
111     pub span: Span,
112 }
113
114 #[derive(SessionDiagnostic)]
115 #[error(code = "E0229", slug = "typeck-assoc-type-binding-not-allowed")]
116 pub struct AssocTypeBindingNotAllowed {
117     #[primary_span]
118     #[label = "associated type not allowed here"]
119     pub span: Span,
120 }
121
122 #[derive(SessionDiagnostic)]
123 #[error(code = "E0436", slug = "typeck-functional-record-update-on-non-struct")]
124 pub struct FunctionalRecordUpdateOnNonStruct {
125     #[primary_span]
126     pub span: Span,
127 }
128
129 #[derive(SessionDiagnostic)]
130 #[error(code = "E0516", slug = "typeck-typeof-reserved-keyword-used")]
131 pub struct TypeofReservedKeywordUsed {
132     #[primary_span]
133     #[label = "reserved keyword"]
134     pub span: Span,
135 }
136
137 #[derive(SessionDiagnostic)]
138 #[error(code = "E0572", slug = "typeck-return-stmt-outside-of-fn-body")]
139 pub struct ReturnStmtOutsideOfFnBody {
140     #[primary_span]
141     pub span: Span,
142     #[label = "the return is part of this body..."]
143     pub encl_body_span: Option<Span>,
144     #[label = "...not the enclosing function body"]
145     pub encl_fn_span: Option<Span>,
146 }
147
148 #[derive(SessionDiagnostic)]
149 #[error(code = "E0627", slug = "typeck-yield-expr-outside-of-generator")]
150 pub struct YieldExprOutsideOfGenerator {
151     #[primary_span]
152     pub span: Span,
153 }
154
155 #[derive(SessionDiagnostic)]
156 #[error(code = "E0639", slug = "typeck-struct-expr-non-exhaustive")]
157 pub struct StructExprNonExhaustive {
158     #[primary_span]
159     pub span: Span,
160     pub what: &'static str,
161 }
162
163 #[derive(SessionDiagnostic)]
164 #[error(code = "E0699", slug = "typeck-method-call-on-unknown-type")]
165 pub struct MethodCallOnUnknownType {
166     #[primary_span]
167     pub span: Span,
168 }
169
170 #[derive(SessionDiagnostic)]
171 #[error(code = "E0719", slug = "typeck-value-of-associated-struct-already-specified")]
172 pub struct ValueOfAssociatedStructAlreadySpecified {
173     #[primary_span]
174     #[label = "re-bound here"]
175     pub span: Span,
176     #[label = "`{item_name}` bound here first"]
177     pub prev_span: Span,
178     pub item_name: Ident,
179     pub def_path: String,
180 }
181
182 #[derive(SessionDiagnostic)]
183 #[error(code = "E0745", slug = "typeck-address-of-temporary-taken")]
184 pub struct AddressOfTemporaryTaken {
185     #[primary_span]
186     #[label = "temporary value"]
187     pub span: Span,
188 }