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,
33 #[diag(ast_lowering::invalid_abi, code = "E0703")]
34 pub struct InvalidAbi {
39 pub valid_abis: String,
42 #[derive(Diagnostic, Clone, Copy)]
43 #[diag(ast_lowering::assoc_ty_parentheses)]
44 pub struct AssocTyParentheses {
48 pub sub: AssocTyParenthesesSub,
51 #[derive(Clone, Copy)]
52 pub enum AssocTyParenthesesSub {
53 Empty { parentheses_span: Span },
54 NotEmpty { open_param: Span, close_param: Span },
57 impl AddToDiagnostic for AssocTyParenthesesSub {
58 fn add_to_diagnostic(self, diag: &mut Diagnostic) {
60 Self::Empty { parentheses_span } => diag.multipart_suggestion(
61 fluent::ast_lowering::remove_parentheses,
62 vec![(parentheses_span, String::new())],
63 Applicability::MaybeIncorrect,
65 Self::NotEmpty { open_param, close_param } => diag.multipart_suggestion(
66 fluent::ast_lowering::use_angle_brackets,
67 vec![(open_param, String::from("<")), (close_param, String::from(">"))],
68 Applicability::MaybeIncorrect,
75 #[diag(ast_lowering::misplaced_impl_trait, code = "E0562")]
76 pub struct MisplacedImplTrait<'a> {
79 pub position: DiagnosticArgFromDisplay<'a>,
82 #[derive(Diagnostic, Clone, Copy)]
83 #[diag(ast_lowering::rustc_box_attribute_error)]
84 pub struct RustcBoxAttributeError {
89 #[derive(Diagnostic, Clone, Copy)]
90 #[diag(ast_lowering::underscore_expr_lhs_assign)]
91 pub struct UnderscoreExprLhsAssign {
97 #[derive(Diagnostic, Clone, Copy)]
98 #[diag(ast_lowering::base_expression_double_dot)]
99 pub struct BaseExpressionDoubleDot {
105 #[derive(Diagnostic, Clone, Copy)]
106 #[diag(ast_lowering::await_only_in_async_fn_and_blocks, code = "E0728")]
107 pub struct AwaitOnlyInAsyncFnAndBlocks {
110 pub dot_await_span: Span,
111 #[label(ast_lowering::this_not_async)]
112 pub item_span: Option<Span>,
115 #[derive(Diagnostic, Clone, Copy)]
116 #[diag(ast_lowering::generator_too_many_parameters, code = "E0628")]
117 pub struct GeneratorTooManyParameters {
119 pub fn_decl_span: Span,
122 #[derive(Diagnostic, Clone, Copy)]
123 #[diag(ast_lowering::closure_cannot_be_static, code = "E0697")]
124 pub struct ClosureCannotBeStatic {
126 pub fn_decl_span: Span,
129 #[derive(Diagnostic, Clone, Copy)]
131 #[diag(ast_lowering::async_non_move_closure_not_supported, code = "E0708")]
132 pub struct AsyncNonMoveClosureNotSupported {
134 pub fn_decl_span: Span,
137 #[derive(Diagnostic, Clone, Copy)]
138 #[diag(ast_lowering::functional_record_update_destructuring_assignment)]
139 pub struct FunctionalRecordUpdateDestructuringAssignemnt {
141 #[suggestion(code = "", applicability = "machine-applicable")]
145 #[derive(Diagnostic, Clone, Copy)]
146 #[diag(ast_lowering::async_generators_not_supported, code = "E0727")]
147 pub struct AsyncGeneratorsNotSupported {
152 #[derive(Diagnostic, Clone, Copy)]
153 #[diag(ast_lowering::inline_asm_unsupported_target, code = "E0472")]
154 pub struct InlineAsmUnsupportedTarget {
159 #[derive(Diagnostic, Clone, Copy)]
160 #[diag(ast_lowering::att_syntax_only_x86)]
161 pub struct AttSyntaxOnlyX86 {
166 #[derive(Diagnostic, Clone, Copy)]
167 #[diag(ast_lowering::abi_specified_multiple_times)]
168 pub struct AbiSpecifiedMultipleTimes {
171 pub prev_name: Symbol,
175 pub equivalent: Option<()>,
178 #[derive(Diagnostic, Clone, Copy)]
179 #[diag(ast_lowering::clobber_abi_not_supported)]
180 pub struct ClobberAbiNotSupported {
185 #[derive(Diagnostic)]
187 #[diag(ast_lowering::invalid_abi_clobber_abi)]
188 pub struct InvalidAbiClobberAbi {
191 pub supported_abis: String,
194 #[derive(Diagnostic, Clone, Copy)]
195 #[diag(ast_lowering::invalid_register)]
196 pub struct InvalidRegister<'a> {
203 #[derive(Diagnostic, Clone, Copy)]
204 #[diag(ast_lowering::invalid_register_class)]
205 pub struct InvalidRegisterClass<'a> {
208 pub reg_class: Symbol,
212 #[derive(Diagnostic)]
213 #[diag(ast_lowering::invalid_asm_template_modifier_reg_class)]
214 pub struct InvalidAsmTemplateModifierRegClass {
216 #[label(ast_lowering::template_modifier)]
217 pub placeholder_span: Span,
218 #[label(ast_lowering::argument)]
221 pub sub: InvalidAsmTemplateModifierRegClassSub,
224 #[derive(Subdiagnostic)]
225 pub enum InvalidAsmTemplateModifierRegClassSub {
226 #[note(ast_lowering::support_modifiers)]
227 SupportModifier { class_name: Symbol, modifiers: String },
228 #[note(ast_lowering::does_not_support_modifiers)]
229 DoesNotSupportModifier { class_name: Symbol },
232 #[derive(Diagnostic, Clone, Copy)]
233 #[diag(ast_lowering::invalid_asm_template_modifier_const)]
234 pub struct InvalidAsmTemplateModifierConst {
236 #[label(ast_lowering::template_modifier)]
237 pub placeholder_span: Span,
238 #[label(ast_lowering::argument)]
242 #[derive(Diagnostic, Clone, Copy)]
243 #[diag(ast_lowering::invalid_asm_template_modifier_sym)]
244 pub struct InvalidAsmTemplateModifierSym {
246 #[label(ast_lowering::template_modifier)]
247 pub placeholder_span: Span,
248 #[label(ast_lowering::argument)]
252 #[derive(Diagnostic, Clone, Copy)]
253 #[diag(ast_lowering::register_class_only_clobber)]
254 pub struct RegisterClassOnlyClobber {
257 pub reg_class_name: Symbol,
260 #[derive(Diagnostic, Clone, Copy)]
261 #[diag(ast_lowering::register_conflict)]
262 pub struct RegisterConflict<'a> {
264 #[label(ast_lowering::register1)]
266 #[label(ast_lowering::register2)]
268 pub reg1_name: &'a str,
269 pub reg2_name: &'a str,
271 pub in_out: Option<Span>,
274 #[derive(Diagnostic, Clone, Copy)]
276 #[diag(ast_lowering::sub_tuple_binding)]
277 pub struct SubTupleBinding<'a> {
280 #[suggestion_verbose(
281 ast_lowering::sub_tuple_binding_suggestion,
283 applicability = "maybe-incorrect"
287 pub ident_name: Symbol,
291 #[derive(Diagnostic, Clone, Copy)]
292 #[diag(ast_lowering::extra_double_dot)]
293 pub struct ExtraDoubleDot<'a> {
297 #[label(ast_lowering::previously_used_here)]
302 #[derive(Diagnostic, Clone, Copy)]
304 #[diag(ast_lowering::misplaced_double_dot)]
305 pub struct MisplacedDoubleDot {
310 #[derive(Diagnostic, Clone, Copy)]
311 #[diag(ast_lowering::misplaced_relax_trait_bound)]
312 pub struct MisplacedRelaxTraitBound {
317 #[derive(Diagnostic, Clone, Copy)]
318 #[diag(ast_lowering::not_supported_for_lifetime_binder_async_closure)]
319 pub struct NotSupportedForLifetimeBinderAsyncClosure {
324 #[derive(Diagnostic, Clone, Copy)]
325 #[diag(ast_lowering::arbitrary_expression_in_pattern)]
326 pub struct ArbitraryExpressionInPattern {
331 #[derive(Diagnostic, Clone, Copy)]
332 #[diag(ast_lowering::inclusive_range_with_no_end)]
333 pub struct InclusiveRangeWithNoEnd {
338 #[derive(Diagnostic, Clone, Copy)]
339 #[diag(ast_lowering::trait_fn_async, code = "E0706")]
341 #[note(ast_lowering::note2)]
342 pub struct TraitFnAsync {