1 //! Errors emitted by typeck.
2 use rustc_errors::Applicability;
3 use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
4 use rustc_middle::ty::Ty;
5 use rustc_span::{symbol::Ident, Span, Symbol};
7 #[derive(SessionDiagnostic)]
8 #[error(code = "E0062", slug = "typeck-field-multiply-specified-in-initializer")]
9 pub struct FieldMultiplySpecifiedInInitializer {
13 #[label = "previous-use-label"]
18 #[derive(SessionDiagnostic)]
19 #[error(code = "E0092", slug = "typeck-unrecognized-atomic-operation")]
20 pub struct UnrecognizedAtomicOperation<'a> {
27 #[derive(SessionDiagnostic)]
28 #[error(code = "E0094", slug = "typeck-wrong-number-of-generic-arguments-to-intrinsic")]
29 pub struct WrongNumberOfGenericArgumentsToIntrinsic<'a> {
38 #[derive(SessionDiagnostic)]
39 #[error(code = "E0093", slug = "typeck-unrecognized-intrinsic-function")]
40 pub struct UnrecognizedIntrinsicFunction {
47 #[derive(SessionDiagnostic)]
48 #[error(code = "E0195", slug = "typeck-lifetimes-or-bounds-mismatch-on-trait")]
49 pub struct LifetimesOrBoundsMismatchOnTrait {
53 #[label = "generics-label"]
54 pub generics_span: Option<Span>,
55 pub item_kind: &'static str,
59 #[derive(SessionDiagnostic)]
60 #[error(code = "E0120", slug = "typeck-drop-impl-on-wrong-item")]
61 pub struct DropImplOnWrongItem {
67 #[derive(SessionDiagnostic)]
68 #[error(code = "E0124", slug = "typeck-field-already-declared")]
69 pub struct FieldAlreadyDeclared {
70 pub field_name: Ident,
74 #[label = "previous-decl-label"]
78 #[derive(SessionDiagnostic)]
79 #[error(code = "E0184", slug = "typeck-copy-impl-on-type-with-dtor")]
80 pub struct CopyImplOnTypeWithDtor {
86 #[derive(SessionDiagnostic)]
87 #[error(code = "E0203", slug = "typeck-multiple-relaxed-default-bounds")]
88 pub struct MultipleRelaxedDefaultBounds {
93 #[derive(SessionDiagnostic)]
94 #[error(code = "E0206", slug = "typeck-copy-impl-on-non-adt")]
95 pub struct CopyImplOnNonAdt {
101 #[derive(SessionDiagnostic)]
102 #[error(code = "E0224", slug = "typeck-trait-object-declared-with-no-traits")]
103 pub struct TraitObjectDeclaredWithNoTraits {
108 #[derive(SessionDiagnostic)]
109 #[error(code = "E0227", slug = "typeck-ambiguous-lifetime-bound")]
110 pub struct AmbiguousLifetimeBound {
115 #[derive(SessionDiagnostic)]
116 #[error(code = "E0229", slug = "typeck-assoc-type-binding-not-allowed")]
117 pub struct AssocTypeBindingNotAllowed {
123 #[derive(SessionDiagnostic)]
124 #[error(code = "E0436", slug = "typeck-functional-record-update-on-non-struct")]
125 pub struct FunctionalRecordUpdateOnNonStruct {
130 #[derive(SessionDiagnostic)]
131 #[error(code = "E0516", slug = "typeck-typeof-reserved-keyword-used")]
132 pub struct TypeofReservedKeywordUsed<'tcx> {
137 #[suggestion_verbose(code = "{ty}")]
138 pub opt_sugg: Option<(Span, Applicability)>,
141 #[derive(SessionDiagnostic)]
142 #[error(code = "E0572", slug = "typeck-return-stmt-outside-of-fn-body")]
143 pub struct ReturnStmtOutsideOfFnBody {
146 #[label = "encl-body-label"]
147 pub encl_body_span: Option<Span>,
148 #[label = "encl-fn-label"]
149 pub encl_fn_span: Option<Span>,
152 #[derive(SessionDiagnostic)]
153 #[error(code = "E0627", slug = "typeck-yield-expr-outside-of-generator")]
154 pub struct YieldExprOutsideOfGenerator {
159 #[derive(SessionDiagnostic)]
160 #[error(code = "E0639", slug = "typeck-struct-expr-non-exhaustive")]
161 pub struct StructExprNonExhaustive {
164 pub what: &'static str,
167 #[derive(SessionDiagnostic)]
168 #[error(code = "E0699", slug = "typeck-method-call-on-unknown-type")]
169 pub struct MethodCallOnUnknownType {
174 #[derive(SessionDiagnostic)]
175 #[error(code = "E0719", slug = "typeck-value-of-associated-struct-already-specified")]
176 pub struct ValueOfAssociatedStructAlreadySpecified {
180 #[label = "previous-bound-label"]
182 pub item_name: Ident,
183 pub def_path: String,
186 #[derive(SessionDiagnostic)]
187 #[error(code = "E0745", slug = "typeck-address-of-temporary-taken")]
188 pub struct AddressOfTemporaryTaken {
194 #[derive(SessionSubdiagnostic)]
195 pub enum AddReturnTypeSuggestion<'tcx> {
197 slug = "typeck-add-return-type-add",
198 code = "-> {found} ",
199 applicability = "machine-applicable"
207 slug = "typeck-add-return-type-missing-here",
209 applicability = "has-placeholders"
217 #[derive(SessionSubdiagnostic)]
218 pub enum ExpectedReturnTypeLabel<'tcx> {
219 #[label(slug = "typeck-expected-default-return-type")]
224 #[label(slug = "typeck-expected-return-type")]
232 #[derive(SessionDiagnostic)]
233 #[error(slug = "typeck-unconstrained-opaque-type")]
235 pub struct UnconstrainedOpaqueType {
241 #[derive(SessionDiagnostic)]
242 #[error(code = "E0632", slug = "typeck-explicit-generic-args-with-impl-trait")]
244 pub struct ExplicitGenericArgsWithImplTrait {
247 pub spans: Vec<Span>,
250 #[derive(SessionSubdiagnostic)]
251 #[help(slug = "typeck-explicit-generic-args-with-impl-trait-feature")]
252 pub struct ExplicitGenericArgsWithImplTraitFeature;