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 MultipleRelaxedDefaultBounds {
88 #[message = "type parameter has more than one relaxed default bound, only one is supported"]
92 #[derive(SessionDiagnostic)]
94 pub struct CopyImplOnNonAdt {
95 #[message = "the trait `Copy` may not be implemented for this type"]
96 #[label = "type is not a structure or enumeration"]
100 #[derive(SessionDiagnostic)]
102 pub struct TraitObjectDeclaredWithNoTraits {
103 #[message = "at least one trait is required for an object type"]
107 #[derive(SessionDiagnostic)]
109 pub struct AmbiguousLifetimeBound {
110 #[message = "ambiguous lifetime bound, explicit lifetime bound required"]
114 #[derive(SessionDiagnostic)]
116 pub struct AssocTypeBindingNotAllowed {
117 #[message = "associated type bindings are not allowed here"]
118 #[label = "associated type not allowed here"]
122 #[derive(SessionDiagnostic)]
124 pub struct SimdShuffleMissingLength {
125 #[message = "invalid `simd_shuffle`, needs length: `{name}`"]
130 #[derive(SessionDiagnostic)]
132 pub struct FunctionalRecordUpdateOnNonStruct {
133 #[message = "functional record update syntax requires a struct"]
137 #[derive(SessionDiagnostic)]
139 pub struct TypeofReservedKeywordUsed {
140 #[message = "`typeof` is a reserved keyword but unimplemented"]
141 #[label = "reserved keyword"]
145 #[derive(SessionDiagnostic)]
147 pub struct ReturnStmtOutsideOfFnBody {
148 #[message = "return statement outside of function body"]
152 #[derive(SessionDiagnostic)]
154 pub struct YieldExprOutsideOfGenerator {
155 #[message = "yield expression outside of generator literal"]
159 #[derive(SessionDiagnostic)]
161 pub struct StructExprNonExhaustive {
162 #[message = "cannot create non-exhaustive {what} using struct expression"]
164 pub what: &'static str,
167 #[derive(SessionDiagnostic)]
169 pub struct MethodCallOnUnknownType {
170 #[message = "the type of this value must be known to call a method on a raw pointer on it"]
174 #[derive(SessionDiagnostic)]
176 pub struct ValueOfAssociatedStructAlreadySpecified {
177 #[message = "the value of the associated type `{item_name}` (from trait `{def_path}`) is already specified"]
178 #[label = "re-bound here"]
180 #[label = "`{item_name}` bound here first"]
182 pub item_name: Ident,
183 pub def_path: String,
186 #[derive(SessionDiagnostic)]
188 pub struct AddressOfTemporaryTaken {
189 #[message = "cannot take address of a temporary"]
190 #[label = "temporary value"]