]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_typeck/src/errors.rs
Rollup merge of #86652 - nagisa:nagisa/non-leaf-fp, r=petrochenkov
[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     #[label = "the return is part of this body..."]
151     pub encl_body_span: Option<Span>,
152     #[label = "...not the enclosing function body"]
153     pub encl_fn_span: Option<Span>,
154 }
155
156 #[derive(SessionDiagnostic)]
157 #[error = "E0627"]
158 pub struct YieldExprOutsideOfGenerator {
159     #[message = "yield expression outside of generator literal"]
160     pub span: Span,
161 }
162
163 #[derive(SessionDiagnostic)]
164 #[error = "E0639"]
165 pub struct StructExprNonExhaustive {
166     #[message = "cannot create non-exhaustive {what} using struct expression"]
167     pub span: Span,
168     pub what: &'static str,
169 }
170
171 #[derive(SessionDiagnostic)]
172 #[error = "E0699"]
173 pub struct MethodCallOnUnknownType {
174     #[message = "the type of this value must be known to call a method on a raw pointer on it"]
175     pub span: Span,
176 }
177
178 #[derive(SessionDiagnostic)]
179 #[error = "E0719"]
180 pub struct ValueOfAssociatedStructAlreadySpecified {
181     #[message = "the value of the associated type `{item_name}` (from trait `{def_path}`) is already specified"]
182     #[label = "re-bound here"]
183     pub span: Span,
184     #[label = "`{item_name}` bound here first"]
185     pub prev_span: Span,
186     pub item_name: Ident,
187     pub def_path: String,
188 }
189
190 #[derive(SessionDiagnostic)]
191 #[error = "E0745"]
192 pub struct AddressOfTemporaryTaken {
193     #[message = "cannot take address of a temporary"]
194     #[label = "temporary value"]
195     pub span: Span,
196 }