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