]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_typeck/src/errors.rs
Rustdoc render public underscore_imports as Re-exports
[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 = "E0062"]
7 pub struct FieldMultiplySpecifiedInInitializer {
8     #[message = "field `{ident}` specified more than once"]
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 = "E0092"]
18 pub struct UnrecognizedAtomicOperation<'a> {
19     #[message = "unrecognized atomic operation function: `{op}`"]
20     #[label = "unrecognized atomic operation"]
21     pub span: Span,
22     pub op: &'a str,
23 }
24
25 #[derive(SessionDiagnostic)]
26 #[error = "E0094"]
27 pub struct WrongNumberOfTypeArgumentsToInstrinsic {
28     #[message = "intrinsic has wrong number of type \
29                          parameters: found {found}, expected {expected}"]
30     #[label = "expected {expected} type parameter"]
31     pub span: Span,
32     pub found: usize,
33     pub expected: usize,
34 }
35
36 #[derive(SessionDiagnostic)]
37 #[error = "E0093"]
38 pub struct UnrecognizedIntrinsicFunction {
39     #[message = "unrecognized intrinsic function: `{name}`"]
40     #[label = "unrecognized intrinsic"]
41     pub span: Span,
42     pub name: Symbol,
43 }
44
45 #[derive(SessionDiagnostic)]
46 #[error = "E0195"]
47 pub struct LifetimesOrBoundsMismatchOnTrait {
48     #[message = "lifetime parameters or bounds on {item_kind} `{ident}` do not match the trait declaration"]
49     #[label = "lifetimes do not match {item_kind} in trait"]
50     pub span: Span,
51     #[label = "lifetimes in impl do not match this {item_kind} in trait"]
52     pub generics_span: Option<Span>,
53     pub item_kind: &'static str,
54     pub ident: Ident,
55 }
56
57 #[derive(SessionDiagnostic)]
58 #[error = "E0120"]
59 pub struct DropImplOnWrongItem {
60     #[message = "the `Drop` trait may only be implemented for structs, enums, and unions"]
61     #[label = "must be a struct, enum, or union"]
62     pub span: Span,
63 }
64
65 #[derive(SessionDiagnostic)]
66 #[error = "E0124"]
67 pub struct FieldAlreadyDeclared {
68     pub field_name: Ident,
69     #[message = "field `{field_name}` is already declared"]
70     #[label = "field already declared"]
71     pub span: Span,
72     #[label = "`{field_name}` first declared here"]
73     pub prev_span: Span,
74 }
75
76 #[derive(SessionDiagnostic)]
77 #[error = "E0184"]
78 pub struct CopyImplOnTypeWithDtor {
79     #[message = "the trait `Copy` may not be implemented for this type; the \
80                               type has a destructor"]
81     #[label = "Copy not allowed on types with destructors"]
82     pub span: Span,
83 }
84
85 #[derive(SessionDiagnostic)]
86 #[error = "E0202"]
87 pub struct AssocTypeOnInherentImpl {
88     #[message = "associated types are not yet supported in inherent impls (see #8995)"]
89     pub span: Span,
90 }
91
92 #[derive(SessionDiagnostic)]
93 #[error = "E0203"]
94 pub struct MultipleRelaxedDefaultBounds {
95     #[message = "type parameter has more than one relaxed default bound, only one is supported"]
96     pub span: Span,
97 }
98
99 #[derive(SessionDiagnostic)]
100 #[error = "E0206"]
101 pub struct CopyImplOnNonAdt {
102     #[message = "the trait `Copy` may not be implemented for this type"]
103     #[label = "type is not a structure or enumeration"]
104     pub span: Span,
105 }
106
107 #[derive(SessionDiagnostic)]
108 #[error = "E0224"]
109 pub struct TraitObjectDeclaredWithNoTraits {
110     #[message = "at least one trait is required for an object type"]
111     pub span: Span,
112 }
113
114 #[derive(SessionDiagnostic)]
115 #[error = "E0227"]
116 pub struct AmbiguousLifetimeBound {
117     #[message = "ambiguous lifetime bound, explicit lifetime bound required"]
118     pub span: Span,
119 }
120
121 #[derive(SessionDiagnostic)]
122 #[error = "E0229"]
123 pub struct AssocTypeBindingNotAllowed {
124     #[message = "associated type bindings are not allowed here"]
125     #[label = "associated type not allowed here"]
126     pub span: Span,
127 }
128
129 #[derive(SessionDiagnostic)]
130 #[error = "E0439"]
131 pub struct SimdShuffleMissingLength {
132     #[message = "invalid `simd_shuffle`, needs length: `{name}`"]
133     pub span: Span,
134     pub name: Symbol,
135 }
136
137 #[derive(SessionDiagnostic)]
138 #[error = "E0436"]
139 pub struct FunctionalRecordUpdateOnNonStruct {
140     #[message = "functional record update syntax requires a struct"]
141     pub span: Span,
142 }
143
144 #[derive(SessionDiagnostic)]
145 #[error = "E0516"]
146 pub struct TypeofReservedKeywordUsed {
147     #[message = "`typeof` is a reserved keyword but unimplemented"]
148     #[label = "reserved keyword"]
149     pub span: Span,
150 }
151
152 #[derive(SessionDiagnostic)]
153 #[error = "E0572"]
154 pub struct ReturnStmtOutsideOfFnBody {
155     #[message = "return statement outside of function body"]
156     pub span: Span,
157 }
158
159 #[derive(SessionDiagnostic)]
160 #[error = "E0627"]
161 pub struct YieldExprOutsideOfGenerator {
162     #[message = "yield expression outside of generator literal"]
163     pub span: Span,
164 }
165
166 #[derive(SessionDiagnostic)]
167 #[error = "E0639"]
168 pub struct StructExprNonExhaustive {
169     #[message = "cannot create non-exhaustive {what} using struct expression"]
170     pub span: Span,
171     pub what: &'static str,
172 }
173
174 #[derive(SessionDiagnostic)]
175 #[error = "E0699"]
176 pub struct MethodCallOnUnknownType {
177     #[message = "the type of this value must be known to call a method on a raw pointer on it"]
178     pub span: Span,
179 }
180
181 #[derive(SessionDiagnostic)]
182 #[error = "E0719"]
183 pub struct ValueOfAssociatedStructAlreadySpecified {
184     #[message = "the value of the associated type `{item_name}` (from trait `{def_path}`) is already specified"]
185     #[label = "re-bound here"]
186     pub span: Span,
187     #[label = "`{item_name}` bound here first"]
188     pub prev_span: Span,
189     pub item_name: Ident,
190     pub def_path: String,
191 }
192
193 #[derive(SessionDiagnostic)]
194 #[error = "E0745"]
195 pub struct AddressOfTemporaryTaken {
196     #[message = "cannot take address of a temporary"]
197     #[label = "temporary value"]
198     pub span: Span,
199 }