]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_typeck/src/errors.rs
Auto merge of #85546 - hyd-dev:unwind, r=RalfJung
[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 = "E0203"]
87 pub struct MultipleRelaxedDefaultBounds {
88     #[message = "type parameter has more than one relaxed default bound, only one is supported"]
89     pub span: Span,
90 }
91
92 #[derive(SessionDiagnostic)]
93 #[error = "E0206"]
94 pub struct CopyImplOnNonAdt {
95     #[message = "the trait `Copy` may not be implemented for this type"]
96     #[label = "type is not a structure or enumeration"]
97     pub span: Span,
98 }
99
100 #[derive(SessionDiagnostic)]
101 #[error = "E0224"]
102 pub struct TraitObjectDeclaredWithNoTraits {
103     #[message = "at least one trait is required for an object type"]
104     pub span: Span,
105 }
106
107 #[derive(SessionDiagnostic)]
108 #[error = "E0227"]
109 pub struct AmbiguousLifetimeBound {
110     #[message = "ambiguous lifetime bound, explicit lifetime bound required"]
111     pub span: Span,
112 }
113
114 #[derive(SessionDiagnostic)]
115 #[error = "E0229"]
116 pub struct AssocTypeBindingNotAllowed {
117     #[message = "associated type bindings are not allowed here"]
118     #[label = "associated type not allowed here"]
119     pub span: Span,
120 }
121
122 #[derive(SessionDiagnostic)]
123 #[error = "E0439"]
124 pub struct SimdShuffleMissingLength {
125     #[message = "invalid `simd_shuffle`, needs length: `{name}`"]
126     pub span: Span,
127     pub name: Symbol,
128 }
129
130 #[derive(SessionDiagnostic)]
131 #[error = "E0436"]
132 pub struct FunctionalRecordUpdateOnNonStruct {
133     #[message = "functional record update syntax requires a struct"]
134     pub span: Span,
135 }
136
137 #[derive(SessionDiagnostic)]
138 #[error = "E0516"]
139 pub struct TypeofReservedKeywordUsed {
140     #[message = "`typeof` is a reserved keyword but unimplemented"]
141     #[label = "reserved keyword"]
142     pub span: Span,
143 }
144
145 #[derive(SessionDiagnostic)]
146 #[error = "E0572"]
147 pub struct ReturnStmtOutsideOfFnBody {
148     #[message = "return statement outside of function body"]
149     pub span: Span,
150 }
151
152 #[derive(SessionDiagnostic)]
153 #[error = "E0627"]
154 pub struct YieldExprOutsideOfGenerator {
155     #[message = "yield expression outside of generator literal"]
156     pub span: Span,
157 }
158
159 #[derive(SessionDiagnostic)]
160 #[error = "E0639"]
161 pub struct StructExprNonExhaustive {
162     #[message = "cannot create non-exhaustive {what} using struct expression"]
163     pub span: Span,
164     pub what: &'static str,
165 }
166
167 #[derive(SessionDiagnostic)]
168 #[error = "E0699"]
169 pub struct MethodCallOnUnknownType {
170     #[message = "the type of this value must be known to call a method on a raw pointer on it"]
171     pub span: Span,
172 }
173
174 #[derive(SessionDiagnostic)]
175 #[error = "E0719"]
176 pub struct ValueOfAssociatedStructAlreadySpecified {
177     #[message = "the value of the associated type `{item_name}` (from trait `{def_path}`) is already specified"]
178     #[label = "re-bound here"]
179     pub span: Span,
180     #[label = "`{item_name}` bound here first"]
181     pub prev_span: Span,
182     pub item_name: Ident,
183     pub def_path: String,
184 }
185
186 #[derive(SessionDiagnostic)]
187 #[error = "E0745"]
188 pub struct AddressOfTemporaryTaken {
189     #[message = "cannot take address of a temporary"]
190     #[label = "temporary value"]
191     pub span: Span,
192 }