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 {
106 #[label = "alias-span"]
107 pub trait_alias_span: Option<Span>,
110 #[derive(SessionDiagnostic)]
111 #[error(code = "E0227", slug = "typeck-ambiguous-lifetime-bound")]
112 pub struct AmbiguousLifetimeBound {
117 #[derive(SessionDiagnostic)]
118 #[error(code = "E0229", slug = "typeck-assoc-type-binding-not-allowed")]
119 pub struct AssocTypeBindingNotAllowed {
125 #[derive(SessionDiagnostic)]
126 #[error(code = "E0436", slug = "typeck-functional-record-update-on-non-struct")]
127 pub struct FunctionalRecordUpdateOnNonStruct {
132 #[derive(SessionDiagnostic)]
133 #[error(code = "E0516", slug = "typeck-typeof-reserved-keyword-used")]
134 pub struct TypeofReservedKeywordUsed<'tcx> {
139 #[suggestion_verbose(code = "{ty}")]
140 pub opt_sugg: Option<(Span, Applicability)>,
143 #[derive(SessionDiagnostic)]
144 #[error(code = "E0572", slug = "typeck-return-stmt-outside-of-fn-body")]
145 pub struct ReturnStmtOutsideOfFnBody {
148 #[label = "encl-body-label"]
149 pub encl_body_span: Option<Span>,
150 #[label = "encl-fn-label"]
151 pub encl_fn_span: Option<Span>,
154 #[derive(SessionDiagnostic)]
155 #[error(code = "E0627", slug = "typeck-yield-expr-outside-of-generator")]
156 pub struct YieldExprOutsideOfGenerator {
161 #[derive(SessionDiagnostic)]
162 #[error(code = "E0639", slug = "typeck-struct-expr-non-exhaustive")]
163 pub struct StructExprNonExhaustive {
166 pub what: &'static str,
169 #[derive(SessionDiagnostic)]
170 #[error(code = "E0699", slug = "typeck-method-call-on-unknown-type")]
171 pub struct MethodCallOnUnknownType {
176 #[derive(SessionDiagnostic)]
177 #[error(code = "E0719", slug = "typeck-value-of-associated-struct-already-specified")]
178 pub struct ValueOfAssociatedStructAlreadySpecified {
182 #[label = "previous-bound-label"]
184 pub item_name: Ident,
185 pub def_path: String,
188 #[derive(SessionDiagnostic)]
189 #[error(code = "E0745", slug = "typeck-address-of-temporary-taken")]
190 pub struct AddressOfTemporaryTaken {
196 #[derive(SessionSubdiagnostic)]
197 pub enum AddReturnTypeSuggestion<'tcx> {
199 slug = "typeck-add-return-type-add",
200 code = "-> {found} ",
201 applicability = "machine-applicable"
209 slug = "typeck-add-return-type-missing-here",
211 applicability = "has-placeholders"
219 #[derive(SessionSubdiagnostic)]
220 pub enum ExpectedReturnTypeLabel<'tcx> {
221 #[label(slug = "typeck-expected-default-return-type")]
226 #[label(slug = "typeck-expected-return-type")]
234 #[derive(SessionDiagnostic)]
235 #[error(slug = "typeck-unconstrained-opaque-type")]
237 pub struct UnconstrainedOpaqueType {
243 #[derive(SessionDiagnostic)]
244 #[error(code = "E0632", slug = "typeck-explicit-generic-args-with-impl-trait")]
246 pub struct ExplicitGenericArgsWithImplTrait {
249 pub spans: Vec<Span>,
252 #[derive(SessionSubdiagnostic)]
253 #[help(slug = "typeck-explicit-generic-args-with-impl-trait-feature")]
254 pub struct ExplicitGenericArgsWithImplTraitFeature;