1 use rustc_errors::{fluent, AddToDiagnostic, Applicability, Diagnostic, DiagnosticArgFromDisplay};
2 use rustc_macros::{Diagnostic, Subdiagnostic};
3 use rustc_span::{symbol::Ident, Span, Symbol};
5 #[derive(Diagnostic, Clone, Copy)]
6 #[diag(ast_lowering::generic_type_with_parentheses, code = "E0214")]
7 pub struct GenericTypeWithParentheses {
12 pub sub: Option<UseAngleBrackets>,
15 #[derive(Clone, Copy)]
16 pub struct UseAngleBrackets {
18 pub close_param: Span,
21 impl AddToDiagnostic for UseAngleBrackets {
22 fn add_to_diagnostic(self, diag: &mut Diagnostic) {
23 diag.multipart_suggestion(
24 fluent::ast_lowering::use_angle_brackets,
25 vec![(self.open_param, String::from("<")), (self.close_param, String::from(">"))],
26 Applicability::MaybeIncorrect,
32 #[diag(ast_lowering::invalid_abi, code = "E0703")]
34 pub struct InvalidAbi {
41 pub suggestion: Option<InvalidAbiSuggestion>,
44 #[derive(Subdiagnostic)]
46 ast_lowering::invalid_abi_suggestion,
47 code = "{suggestion}",
48 applicability = "maybe-incorrect"
50 pub struct InvalidAbiSuggestion {
53 pub suggestion: String,
56 #[derive(Diagnostic, Clone, Copy)]
57 #[diag(ast_lowering::assoc_ty_parentheses)]
58 pub struct AssocTyParentheses {
62 pub sub: AssocTyParenthesesSub,
65 #[derive(Clone, Copy)]
66 pub enum AssocTyParenthesesSub {
67 Empty { parentheses_span: Span },
68 NotEmpty { open_param: Span, close_param: Span },
71 impl AddToDiagnostic for AssocTyParenthesesSub {
72 fn add_to_diagnostic(self, diag: &mut Diagnostic) {
74 Self::Empty { parentheses_span } => diag.multipart_suggestion(
75 fluent::ast_lowering::remove_parentheses,
76 vec![(parentheses_span, String::new())],
77 Applicability::MaybeIncorrect,
79 Self::NotEmpty { open_param, close_param } => diag.multipart_suggestion(
80 fluent::ast_lowering::use_angle_brackets,
81 vec![(open_param, String::from("<")), (close_param, String::from(">"))],
82 Applicability::MaybeIncorrect,
89 #[diag(ast_lowering::misplaced_impl_trait, code = "E0562")]
90 pub struct MisplacedImplTrait<'a> {
93 pub position: DiagnosticArgFromDisplay<'a>,
96 #[derive(Diagnostic, Clone, Copy)]
97 #[diag(ast_lowering::rustc_box_attribute_error)]
98 pub struct RustcBoxAttributeError {
103 #[derive(Diagnostic, Clone, Copy)]
104 #[diag(ast_lowering::underscore_expr_lhs_assign)]
105 pub struct UnderscoreExprLhsAssign {
111 #[derive(Diagnostic, Clone, Copy)]
112 #[diag(ast_lowering::base_expression_double_dot)]
113 pub struct BaseExpressionDoubleDot {
119 #[derive(Diagnostic, Clone, Copy)]
120 #[diag(ast_lowering::await_only_in_async_fn_and_blocks, code = "E0728")]
121 pub struct AwaitOnlyInAsyncFnAndBlocks {
124 pub dot_await_span: Span,
125 #[label(ast_lowering::this_not_async)]
126 pub item_span: Option<Span>,
129 #[derive(Diagnostic, Clone, Copy)]
130 #[diag(ast_lowering::generator_too_many_parameters, code = "E0628")]
131 pub struct GeneratorTooManyParameters {
133 pub fn_decl_span: Span,
136 #[derive(Diagnostic, Clone, Copy)]
137 #[diag(ast_lowering::closure_cannot_be_static, code = "E0697")]
138 pub struct ClosureCannotBeStatic {
140 pub fn_decl_span: Span,
143 #[derive(Diagnostic, Clone, Copy)]
145 #[diag(ast_lowering::async_non_move_closure_not_supported, code = "E0708")]
146 pub struct AsyncNonMoveClosureNotSupported {
148 pub fn_decl_span: Span,
151 #[derive(Diagnostic, Clone, Copy)]
152 #[diag(ast_lowering::functional_record_update_destructuring_assignment)]
153 pub struct FunctionalRecordUpdateDestructuringAssignemnt {
155 #[suggestion(code = "", applicability = "machine-applicable")]
159 #[derive(Diagnostic, Clone, Copy)]
160 #[diag(ast_lowering::async_generators_not_supported, code = "E0727")]
161 pub struct AsyncGeneratorsNotSupported {
166 #[derive(Diagnostic, Clone, Copy)]
167 #[diag(ast_lowering::inline_asm_unsupported_target, code = "E0472")]
168 pub struct InlineAsmUnsupportedTarget {
173 #[derive(Diagnostic, Clone, Copy)]
174 #[diag(ast_lowering::att_syntax_only_x86)]
175 pub struct AttSyntaxOnlyX86 {
180 #[derive(Diagnostic, Clone, Copy)]
181 #[diag(ast_lowering::abi_specified_multiple_times)]
182 pub struct AbiSpecifiedMultipleTimes {
185 pub prev_name: Symbol,
189 pub equivalent: Option<()>,
192 #[derive(Diagnostic, Clone, Copy)]
193 #[diag(ast_lowering::clobber_abi_not_supported)]
194 pub struct ClobberAbiNotSupported {
199 #[derive(Diagnostic)]
201 #[diag(ast_lowering::invalid_abi_clobber_abi)]
202 pub struct InvalidAbiClobberAbi {
205 pub supported_abis: String,
208 #[derive(Diagnostic, Clone, Copy)]
209 #[diag(ast_lowering::invalid_register)]
210 pub struct InvalidRegister<'a> {
217 #[derive(Diagnostic, Clone, Copy)]
218 #[diag(ast_lowering::invalid_register_class)]
219 pub struct InvalidRegisterClass<'a> {
222 pub reg_class: Symbol,
226 #[derive(Diagnostic)]
227 #[diag(ast_lowering::invalid_asm_template_modifier_reg_class)]
228 pub struct InvalidAsmTemplateModifierRegClass {
230 #[label(ast_lowering::template_modifier)]
231 pub placeholder_span: Span,
232 #[label(ast_lowering::argument)]
235 pub sub: InvalidAsmTemplateModifierRegClassSub,
238 #[derive(Subdiagnostic)]
239 pub enum InvalidAsmTemplateModifierRegClassSub {
240 #[note(ast_lowering::support_modifiers)]
241 SupportModifier { class_name: Symbol, modifiers: String },
242 #[note(ast_lowering::does_not_support_modifiers)]
243 DoesNotSupportModifier { class_name: Symbol },
246 #[derive(Diagnostic, Clone, Copy)]
247 #[diag(ast_lowering::invalid_asm_template_modifier_const)]
248 pub struct InvalidAsmTemplateModifierConst {
250 #[label(ast_lowering::template_modifier)]
251 pub placeholder_span: Span,
252 #[label(ast_lowering::argument)]
256 #[derive(Diagnostic, Clone, Copy)]
257 #[diag(ast_lowering::invalid_asm_template_modifier_sym)]
258 pub struct InvalidAsmTemplateModifierSym {
260 #[label(ast_lowering::template_modifier)]
261 pub placeholder_span: Span,
262 #[label(ast_lowering::argument)]
266 #[derive(Diagnostic, Clone, Copy)]
267 #[diag(ast_lowering::register_class_only_clobber)]
268 pub struct RegisterClassOnlyClobber {
271 pub reg_class_name: Symbol,
274 #[derive(Diagnostic, Clone, Copy)]
275 #[diag(ast_lowering::register_conflict)]
276 pub struct RegisterConflict<'a> {
278 #[label(ast_lowering::register1)]
280 #[label(ast_lowering::register2)]
282 pub reg1_name: &'a str,
283 pub reg2_name: &'a str,
285 pub in_out: Option<Span>,
288 #[derive(Diagnostic, Clone, Copy)]
290 #[diag(ast_lowering::sub_tuple_binding)]
291 pub struct SubTupleBinding<'a> {
294 #[suggestion_verbose(
295 ast_lowering::sub_tuple_binding_suggestion,
297 applicability = "maybe-incorrect"
301 pub ident_name: Symbol,
305 #[derive(Diagnostic, Clone, Copy)]
306 #[diag(ast_lowering::extra_double_dot)]
307 pub struct ExtraDoubleDot<'a> {
311 #[label(ast_lowering::previously_used_here)]
316 #[derive(Diagnostic, Clone, Copy)]
318 #[diag(ast_lowering::misplaced_double_dot)]
319 pub struct MisplacedDoubleDot {
324 #[derive(Diagnostic, Clone, Copy)]
325 #[diag(ast_lowering::misplaced_relax_trait_bound)]
326 pub struct MisplacedRelaxTraitBound {
331 #[derive(Diagnostic, Clone, Copy)]
332 #[diag(ast_lowering::not_supported_for_lifetime_binder_async_closure)]
333 pub struct NotSupportedForLifetimeBinderAsyncClosure {
338 #[derive(Diagnostic, Clone, Copy)]
339 #[diag(ast_lowering::arbitrary_expression_in_pattern)]
340 pub struct ArbitraryExpressionInPattern {
345 #[derive(Diagnostic, Clone, Copy)]
346 #[diag(ast_lowering::inclusive_range_with_no_end)]
347 pub struct InclusiveRangeWithNoEnd {
352 #[derive(Diagnostic, Clone, Copy)]
353 #[diag(ast_lowering::trait_fn_async, code = "E0706")]
355 #[note(ast_lowering::note2)]
356 pub struct TraitFnAsync {