1 //! Errors emitted by typeck.
2 use rustc_macros::SessionDiagnostic;
3 use rustc_span::{symbol::Ident, Span, Symbol};
5 #[derive(SessionDiagnostic)]
6 #[error(code = "E0062", slug = "typeck-field-multiply-specified-in-initializer")]
7 pub struct FieldMultiplySpecifiedInInitializer {
9 #[label = "used more than once"]
11 #[label = "first use of `{ident}`"]
16 #[derive(SessionDiagnostic)]
17 #[error(code = "E0092", slug = "typeck-unrecognized-atomic-operation")]
18 pub struct UnrecognizedAtomicOperation<'a> {
20 #[label = "unrecognized atomic operation"]
25 #[derive(SessionDiagnostic)]
26 #[error(code = "E0094", slug = "typeck-wrong-number-of-generic-arguments-to-intrinsic")]
27 pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
29 #[label = "expected {expected} {descr} parameter{expected_pluralize}"]
33 pub expected_pluralize: &'a str,
37 #[derive(SessionDiagnostic)]
38 #[error(code = "E0093", slug = "typeck-unrecognized-intrinsic-function")]
39 pub struct UnrecognizedIntrinsicFunction {
41 #[label = "unrecognized intrinsic"]
46 #[derive(SessionDiagnostic)]
47 #[error(code = "E0195", slug = "typeck-lifetimes-or-bounds-mismatch-on-trait")]
48 pub struct LifetimesOrBoundsMismatchOnTrait {
50 #[label = "lifetimes do not match {item_kind} in trait"]
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,
58 #[derive(SessionDiagnostic)]
59 #[error(code = "E0120", slug = "typeck-drop-impl-on-wrong-item")]
60 pub struct DropImplOnWrongItem {
62 #[label = "must be a struct, enum, or union"]
66 #[derive(SessionDiagnostic)]
67 #[error(code = "E0124", slug = "typeck-field-already-declared")]
68 pub struct FieldAlreadyDeclared {
69 pub field_name: Ident,
71 #[label = "field already declared"]
73 #[label = "`{field_name}` first declared here"]
77 #[derive(SessionDiagnostic)]
78 #[error(code = "E0184", slug = "typeck-copy-impl-on-type-with-dtor")]
79 pub struct CopyImplOnTypeWithDtor {
81 #[label = "Copy not allowed on types with destructors"]
85 #[derive(SessionDiagnostic)]
86 #[error(code = "E0203", slug = "typeck-multiple-relaxed-default-bounds")]
87 pub struct MultipleRelaxedDefaultBounds {
92 #[derive(SessionDiagnostic)]
93 #[error(code = "E0206", slug = "typeck-copy-impl-on-non-adt")]
94 pub struct CopyImplOnNonAdt {
96 #[label = "type is not a structure or enumeration"]
100 #[derive(SessionDiagnostic)]
101 #[error(code = "E0224", slug = "typeck-trait-object-declared-with-no-traits")]
102 pub struct TraitObjectDeclaredWithNoTraits {
107 #[derive(SessionDiagnostic)]
108 #[error(code = "E0227", slug = "typeck-ambiguous-lifetime-bound")]
109 pub struct AmbiguousLifetimeBound {
114 #[derive(SessionDiagnostic)]
115 #[error(code = "E0229", slug = "typeck-assoc-type-binding-not-allowed")]
116 pub struct AssocTypeBindingNotAllowed {
118 #[label = "associated type not allowed here"]
122 #[derive(SessionDiagnostic)]
123 #[error(code = "E0436", slug = "typeck-functional-record-update-on-non-struct")]
124 pub struct FunctionalRecordUpdateOnNonStruct {
129 #[derive(SessionDiagnostic)]
130 #[error(code = "E0516", slug = "typeck-typeof-reserved-keyword-used")]
131 pub struct TypeofReservedKeywordUsed {
133 #[label = "reserved keyword"]
137 #[derive(SessionDiagnostic)]
138 #[error(code = "E0572", slug = "typeck-return-stmt-outside-of-fn-body")]
139 pub struct ReturnStmtOutsideOfFnBody {
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>,
148 #[derive(SessionDiagnostic)]
149 #[error(code = "E0627", slug = "typeck-yield-expr-outside-of-generator")]
150 pub struct YieldExprOutsideOfGenerator {
155 #[derive(SessionDiagnostic)]
156 #[error(code = "E0639", slug = "typeck-struct-expr-non-exhaustive")]
157 pub struct StructExprNonExhaustive {
160 pub what: &'static str,
163 #[derive(SessionDiagnostic)]
164 #[error(code = "E0699", slug = "typeck-method-call-on-unknown-type")]
165 pub struct MethodCallOnUnknownType {
170 #[derive(SessionDiagnostic)]
171 #[error(code = "E0719", slug = "typeck-value-of-associated-struct-already-specified")]
172 pub struct ValueOfAssociatedStructAlreadySpecified {
174 #[label = "re-bound here"]
176 #[label = "`{item_name}` bound here first"]
178 pub item_name: Ident,
179 pub def_path: String,
182 #[derive(SessionDiagnostic)]
183 #[error(code = "E0745", slug = "typeck-address-of-temporary-taken")]
184 pub struct AddressOfTemporaryTaken {
186 #[label = "temporary value"]