1 //! Errors emitted by typeck.
2 use rustc_macros::SessionDiagnostic;
3 use rustc_span::{symbol::Ident, Span, Symbol};
5 #[derive(SessionDiagnostic)]
7 pub struct FieldMultiplySpecifiedInInitializer {
8 #[message = "field `{ident}` specified more than once"]
9 #[label = "used more than once"]
11 #[label = "first use of `{ident}`"]
16 #[derive(SessionDiagnostic)]
18 pub struct UnrecognizedAtomicOperation<'a> {
19 #[message = "unrecognized atomic operation function: `{op}`"]
20 #[label = "unrecognized atomic operation"]
25 #[derive(SessionDiagnostic)]
27 pub struct WrongNumberOfTypeArgumentsToInstrinsic {
28 #[message = "intrinsic has wrong number of type \
29 parameters: found {found}, expected {expected}"]
30 #[label = "expected {expected} type parameter"]
36 #[derive(SessionDiagnostic)]
38 pub struct UnrecognizedIntrinsicFunction {
39 #[message = "unrecognized intrinsic function: `{name}`"]
40 #[label = "unrecognized intrinsic"]
45 #[derive(SessionDiagnostic)]
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"]
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,
57 #[derive(SessionDiagnostic)]
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"]
65 #[derive(SessionDiagnostic)]
67 pub struct FieldAlreadyDeclared {
68 pub field_name: Ident,
69 #[message = "field `{field_name}` is already declared"]
70 #[label = "field already declared"]
72 #[label = "`{field_name}` first declared here"]
76 #[derive(SessionDiagnostic)]
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"]
85 #[derive(SessionDiagnostic)]
87 pub struct AssocTypeOnInherentImpl {
88 #[message = "associated types are not yet supported in inherent impls (see #8995)"]
92 #[derive(SessionDiagnostic)]
94 pub struct MultipleRelaxedDefaultBounds {
95 #[message = "type parameter has more than one relaxed default bound, only one is supported"]
99 #[derive(SessionDiagnostic)]
101 pub struct CopyImplOnNonAdt {
102 #[message = "the trait `Copy` may not be implemented for this type"]
103 #[label = "type is not a structure or enumeration"]
107 #[derive(SessionDiagnostic)]
109 pub struct TraitObjectDeclaredWithNoTraits {
110 #[message = "at least one trait is required for an object type"]
114 #[derive(SessionDiagnostic)]
116 pub struct AmbiguousLifetimeBound {
117 #[message = "ambiguous lifetime bound, explicit lifetime bound required"]
121 #[derive(SessionDiagnostic)]
123 pub struct AssocTypeBindingNotAllowed {
124 #[message = "associated type bindings are not allowed here"]
125 #[label = "associated type not allowed here"]
129 #[derive(SessionDiagnostic)]
131 pub struct SimdShuffleMissingLength {
132 #[message = "invalid `simd_shuffle`, needs length: `{name}`"]
137 #[derive(SessionDiagnostic)]
139 pub struct FunctionalRecordUpdateOnNonStruct {
140 #[message = "functional record update syntax requires a struct"]
144 #[derive(SessionDiagnostic)]
146 pub struct TypeofReservedKeywordUsed {
147 #[message = "`typeof` is a reserved keyword but unimplemented"]
148 #[label = "reserved keyword"]
152 #[derive(SessionDiagnostic)]
154 pub struct ReturnStmtOutsideOfFnBody {
155 #[message = "return statement outside of function body"]
159 #[derive(SessionDiagnostic)]
161 pub struct YieldExprOutsideOfGenerator {
162 #[message = "yield expression outside of generator literal"]
166 #[derive(SessionDiagnostic)]
168 pub struct StructExprNonExhaustive {
169 #[message = "cannot create non-exhaustive {what} using struct expression"]
171 pub what: &'static str,
174 #[derive(SessionDiagnostic)]
176 pub struct MethodCallOnUnknownType {
177 #[message = "the type of this value must be known to call a method on a raw pointer on it"]
181 #[derive(SessionDiagnostic)]
183 pub struct ValueOfAssociatedStructAlreadySpecified {
184 #[message = "the value of the associated type `{item_name}` (from trait `{def_path}`) is already specified"]
185 #[label = "re-bound here"]
187 #[label = "`{item_name}` bound here first"]
189 pub item_name: Ident,
190 pub def_path: String,
193 #[derive(SessionDiagnostic)]
195 pub struct AddressOfTemporaryTaken {
196 #[message = "cannot take address of a temporary"]
197 #[label = "temporary value"]