2022-09-22 11:39:17 -05:00
|
|
|
use rustc_ast::token::Token;
|
2022-09-14 13:11:42 -05:00
|
|
|
use rustc_ast::Path;
|
2022-09-04 03:14:00 -05:00
|
|
|
use rustc_errors::{fluent, AddToDiagnostic, Applicability, EmissionGuarantee, IntoDiagnostic};
|
2022-08-30 06:19:17 -05:00
|
|
|
use rustc_macros::{Diagnostic, Subdiagnostic};
|
|
|
|
use rustc_session::errors::ExprParenthesesNeeded;
|
|
|
|
use rustc_span::symbol::Ident;
|
|
|
|
use rustc_span::{Span, Symbol};
|
|
|
|
|
2022-09-22 11:39:17 -05:00
|
|
|
use crate::parser::TokenDescription;
|
2022-09-04 03:14:00 -05:00
|
|
|
|
2022-08-30 06:19:17 -05:00
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_maybe_report_ambiguous_plus)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct AmbiguousPlus {
|
|
|
|
pub sum_ty: String,
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(code = "({sum_ty})")]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_maybe_recover_from_bad_type_plus, code = "E0178")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct BadTypePlus {
|
|
|
|
pub ty: String,
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sub: BadTypePlusSub,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum BadTypePlusSub {
|
|
|
|
#[suggestion(
|
2022-11-07 12:47:32 -06:00
|
|
|
parse_add_paren,
|
2022-08-30 06:19:17 -05:00
|
|
|
code = "{sum_with_parens}",
|
|
|
|
applicability = "machine-applicable"
|
|
|
|
)]
|
|
|
|
AddParen {
|
|
|
|
sum_with_parens: String,
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
2022-11-07 12:47:32 -06:00
|
|
|
#[label(parse_forgot_paren)]
|
2022-08-30 06:19:17 -05:00
|
|
|
ForgotParen {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
2022-11-07 12:47:32 -06:00
|
|
|
#[label(parse_expect_path)]
|
2022-08-30 06:19:17 -05:00
|
|
|
ExpectPath {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_maybe_recover_from_bad_qpath_stage_2)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct BadQPathStage2 {
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(code = "", applicability = "maybe-incorrect")]
|
|
|
|
pub span: Span,
|
|
|
|
pub ty: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_incorrect_semicolon)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct IncorrectSemicolon<'a> {
|
|
|
|
#[primary_span]
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(style = "short", code = "", applicability = "machine-applicable")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub span: Span,
|
|
|
|
#[help]
|
|
|
|
pub opt_help: Option<()>,
|
|
|
|
pub name: &'a str,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_incorrect_use_of_await)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct IncorrectUseOfAwait {
|
|
|
|
#[primary_span]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[suggestion(parentheses_suggestion, code = "", applicability = "machine-applicable")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_incorrect_use_of_await)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct IncorrectAwait {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-10-22 04:07:54 -05:00
|
|
|
#[suggestion(postfix_suggestion, code = "{expr}.await{question_mark}")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub sugg_span: (Span, Applicability),
|
|
|
|
pub expr: String,
|
|
|
|
pub question_mark: &'static str,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_in_in_typo)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct InInTypo {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[suggestion(code = "", applicability = "machine-applicable")]
|
|
|
|
pub sugg_span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_invalid_variable_declaration)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct InvalidVariableDeclaration {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sub: InvalidVariableDeclarationSub,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum InvalidVariableDeclarationSub {
|
2022-11-07 12:47:32 -06:00
|
|
|
#[suggestion(parse_switch_mut_let_order, applicability = "maybe-incorrect", code = "let mut")]
|
2022-08-30 06:19:17 -05:00
|
|
|
SwitchMutLetOrder(#[primary_span] Span),
|
|
|
|
#[suggestion(
|
2022-11-07 12:47:32 -06:00
|
|
|
parse_missing_let_before_mut,
|
2022-08-30 06:19:17 -05:00
|
|
|
applicability = "machine-applicable",
|
|
|
|
code = "let mut"
|
|
|
|
)]
|
|
|
|
MissingLet(#[primary_span] Span),
|
2022-11-07 12:47:32 -06:00
|
|
|
#[suggestion(parse_use_let_not_auto, applicability = "machine-applicable", code = "let")]
|
2022-08-30 06:19:17 -05:00
|
|
|
UseLetNotAuto(#[primary_span] Span),
|
2022-11-07 12:47:32 -06:00
|
|
|
#[suggestion(parse_use_let_not_var, applicability = "machine-applicable", code = "let")]
|
2022-08-30 06:19:17 -05:00
|
|
|
UseLetNotVar(#[primary_span] Span),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_invalid_comparison_operator)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct InvalidComparisonOperator {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub invalid: String,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sub: InvalidComparisonOperatorSub,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum InvalidComparisonOperatorSub {
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(
|
|
|
|
use_instead,
|
|
|
|
style = "short",
|
|
|
|
applicability = "machine-applicable",
|
|
|
|
code = "{correct}"
|
|
|
|
)]
|
2022-08-30 06:19:17 -05:00
|
|
|
Correctable {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
invalid: String,
|
|
|
|
correct: String,
|
|
|
|
},
|
2022-10-22 04:07:54 -05:00
|
|
|
#[label(spaceship_operator_invalid)]
|
2022-08-30 06:19:17 -05:00
|
|
|
Spaceship(#[primary_span] Span),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_invalid_logical_operator)]
|
2022-08-30 06:19:17 -05:00
|
|
|
#[note]
|
|
|
|
pub(crate) struct InvalidLogicalOperator {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub incorrect: String,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sub: InvalidLogicalOperatorSub,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum InvalidLogicalOperatorSub {
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(
|
2022-10-22 04:07:54 -05:00
|
|
|
use_amp_amp_for_conjunction,
|
2022-10-22 08:48:55 -05:00
|
|
|
style = "short",
|
2022-08-30 06:19:17 -05:00
|
|
|
applicability = "machine-applicable",
|
|
|
|
code = "&&"
|
|
|
|
)]
|
|
|
|
Conjunction(#[primary_span] Span),
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(
|
2022-10-22 04:07:54 -05:00
|
|
|
use_pipe_pipe_for_disjunction,
|
2022-10-22 08:48:55 -05:00
|
|
|
style = "short",
|
2022-08-30 06:19:17 -05:00
|
|
|
applicability = "machine-applicable",
|
|
|
|
code = "||"
|
|
|
|
)]
|
|
|
|
Disjunction(#[primary_span] Span),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_tilde_is_not_unary_operator)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct TildeAsUnaryOperator(
|
|
|
|
#[primary_span]
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(style = "short", applicability = "machine-applicable", code = "!")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub Span,
|
|
|
|
);
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_unexpected_token_after_not)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct NotAsNegationOperator {
|
|
|
|
#[primary_span]
|
|
|
|
pub negated: Span,
|
|
|
|
pub negated_desc: String,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sub: NotAsNegationOperatorSub,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub enum NotAsNegationOperatorSub {
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(
|
2022-11-07 12:47:32 -06:00
|
|
|
parse_unexpected_token_after_not_default,
|
2022-10-22 08:48:55 -05:00
|
|
|
style = "short",
|
2022-08-30 06:19:17 -05:00
|
|
|
applicability = "machine-applicable",
|
|
|
|
code = "!"
|
|
|
|
)]
|
|
|
|
SuggestNotDefault(#[primary_span] Span),
|
|
|
|
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(
|
2022-11-07 12:47:32 -06:00
|
|
|
parse_unexpected_token_after_not_bitwise,
|
2022-10-22 08:48:55 -05:00
|
|
|
style = "short",
|
2022-08-30 06:19:17 -05:00
|
|
|
applicability = "machine-applicable",
|
|
|
|
code = "!"
|
|
|
|
)]
|
|
|
|
SuggestNotBitwise(#[primary_span] Span),
|
|
|
|
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(
|
2022-11-07 12:47:32 -06:00
|
|
|
parse_unexpected_token_after_not_logical,
|
2022-10-22 08:48:55 -05:00
|
|
|
style = "short",
|
2022-08-30 06:19:17 -05:00
|
|
|
applicability = "machine-applicable",
|
|
|
|
code = "!"
|
|
|
|
)]
|
|
|
|
SuggestNotLogical(#[primary_span] Span),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_malformed_loop_label)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct MalformedLoopLabel {
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(applicability = "machine-applicable", code = "{correct_label}")]
|
|
|
|
pub span: Span,
|
|
|
|
pub correct_label: Ident,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_lifetime_in_borrow_expression)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct LifetimeInBorrowExpression {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[suggestion(applicability = "machine-applicable", code = "")]
|
|
|
|
#[label]
|
|
|
|
pub lifetime_span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_field_expression_with_generic)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct FieldExpressionWithGeneric(#[primary_span] pub Span);
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_macro_invocation_with_qualified_path)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct MacroInvocationWithQualifiedPath(#[primary_span] pub Span);
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_unexpected_token_after_label)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct UnexpectedTokenAfterLabel {
|
|
|
|
#[primary_span]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[label(parse_unexpected_token_after_label)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub span: Span,
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(suggestion_remove_label, style = "verbose", code = "")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub remove_label: Option<Span>,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub enclose_in_block: Option<UnexpectedTokenAfterLabelSugg>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[multipart_suggestion(suggestion_enclose_in_block, applicability = "machine-applicable")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct UnexpectedTokenAfterLabelSugg {
|
|
|
|
#[suggestion_part(code = "{{ ")]
|
|
|
|
pub left: Span,
|
|
|
|
#[suggestion_part(code = " }}")]
|
|
|
|
pub right: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_require_colon_after_labeled_expression)]
|
2022-08-30 06:19:17 -05:00
|
|
|
#[note]
|
|
|
|
pub(crate) struct RequireColonAfterLabeledExpression {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[label]
|
|
|
|
pub label: Span,
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(style = "short", applicability = "machine-applicable", code = ": ")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub label_end: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_do_catch_syntax_removed)]
|
2022-08-30 06:19:17 -05:00
|
|
|
#[note]
|
|
|
|
pub(crate) struct DoCatchSyntaxRemoved {
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(applicability = "machine-applicable", code = "try")]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_float_literal_requires_integer_part)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct FloatLiteralRequiresIntegerPart {
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(applicability = "machine-applicable", code = "{correct}")]
|
|
|
|
pub span: Span,
|
|
|
|
pub correct: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_missing_semicolon_before_array)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct MissingSemicolonBeforeArray {
|
|
|
|
#[primary_span]
|
|
|
|
pub open_delim: Span,
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(style = "verbose", applicability = "maybe-incorrect", code = ";")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub semicolon: Span,
|
|
|
|
}
|
|
|
|
|
2022-10-13 10:27:17 -05:00
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_expect_dotdot_not_dotdotdot)]
|
2022-10-13 10:27:17 -05:00
|
|
|
pub(crate) struct MissingDotDot {
|
|
|
|
#[primary_span]
|
|
|
|
pub token_span: Span,
|
2022-10-13 17:52:23 -05:00
|
|
|
#[suggestion(applicability = "maybe-incorrect", code = "..", style = "verbose")]
|
2022-10-13 10:27:17 -05:00
|
|
|
pub sugg_span: Span,
|
|
|
|
}
|
|
|
|
|
2022-08-30 06:19:17 -05:00
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_invalid_block_macro_segment)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct InvalidBlockMacroSegment {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[label]
|
|
|
|
pub context: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_if_expression_missing_then_block)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct IfExpressionMissingThenBlock {
|
|
|
|
#[primary_span]
|
|
|
|
pub if_span: Span,
|
|
|
|
#[subdiagnostic]
|
2023-01-23 22:31:45 -06:00
|
|
|
pub missing_then_block_sub: IfExpressionMissingThenBlockSub,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub let_else_sub: Option<IfExpressionLetSomeSub>,
|
2022-08-30 06:19:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum IfExpressionMissingThenBlockSub {
|
2022-10-22 04:07:54 -05:00
|
|
|
#[help(condition_possibly_unfinished)]
|
2022-08-30 06:19:17 -05:00
|
|
|
UnfinishedCondition(#[primary_span] Span),
|
2022-10-22 04:07:54 -05:00
|
|
|
#[help(add_then_block)]
|
2022-08-30 06:19:17 -05:00
|
|
|
AddThenBlock(#[primary_span] Span),
|
|
|
|
}
|
|
|
|
|
2023-01-23 22:31:45 -06:00
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[help(parse_extra_if_in_let_else)]
|
|
|
|
pub(crate) struct IfExpressionLetSomeSub {
|
|
|
|
#[primary_span]
|
|
|
|
pub if_span: Span,
|
|
|
|
}
|
|
|
|
|
2022-08-30 06:19:17 -05:00
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_if_expression_missing_condition)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct IfExpressionMissingCondition {
|
|
|
|
#[primary_span]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[label(condition_label)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub if_span: Span,
|
2022-10-22 04:07:54 -05:00
|
|
|
#[label(block_label)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub block_span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_expected_expression_found_let)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct ExpectedExpressionFoundLet {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-10-27 01:43:15 -05:00
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_expect_eq_instead_of_eqeq)]
|
2022-10-27 01:43:15 -05:00
|
|
|
pub(crate) struct ExpectedEqForLetExpr {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-11-08 02:04:14 -06:00
|
|
|
#[suggestion(applicability = "maybe-incorrect", code = "=", style = "verbose")]
|
2022-10-27 01:43:15 -05:00
|
|
|
pub sugg_span: Span,
|
|
|
|
}
|
|
|
|
|
2022-08-30 06:19:17 -05:00
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_expected_else_block)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct ExpectedElseBlock {
|
|
|
|
#[primary_span]
|
|
|
|
pub first_tok_span: Span,
|
|
|
|
pub first_tok: String,
|
|
|
|
#[label]
|
|
|
|
pub else_span: Span,
|
|
|
|
#[suggestion(applicability = "maybe-incorrect", code = "if ")]
|
|
|
|
pub condition_start: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_outer_attribute_not_allowed_on_if_else)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct OuterAttributeNotAllowedOnIfElse {
|
|
|
|
#[primary_span]
|
|
|
|
pub last: Span,
|
|
|
|
|
2022-10-22 04:07:54 -05:00
|
|
|
#[label(branch_label)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub branch_span: Span,
|
|
|
|
|
2022-10-22 04:07:54 -05:00
|
|
|
#[label(ctx_label)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub ctx_span: Span,
|
|
|
|
pub ctx: String,
|
|
|
|
|
|
|
|
#[suggestion(applicability = "machine-applicable", code = "")]
|
|
|
|
pub attributes: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_missing_in_in_for_loop)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct MissingInInForLoop {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sub: MissingInInForLoopSub,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum MissingInInForLoopSub {
|
|
|
|
// Has been misleading, at least in the past (closed Issue #48492), thus maybe-incorrect
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(use_in_not_of, style = "short", applicability = "maybe-incorrect", code = "in")]
|
2022-08-30 06:19:17 -05:00
|
|
|
InNotOf(#[primary_span] Span),
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(add_in, style = "short", applicability = "maybe-incorrect", code = " in ")]
|
2022-08-30 06:19:17 -05:00
|
|
|
AddIn(#[primary_span] Span),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_missing_comma_after_match_arm)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct MissingCommaAfterMatchArm {
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(applicability = "machine-applicable", code = ",")]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_catch_after_try)]
|
2022-08-30 06:19:17 -05:00
|
|
|
#[help]
|
|
|
|
pub(crate) struct CatchAfterTry {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_comma_after_base_struct)]
|
2022-08-30 06:19:17 -05:00
|
|
|
#[note]
|
|
|
|
pub(crate) struct CommaAfterBaseStruct {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(style = "short", applicability = "machine-applicable", code = "")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub comma: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_eq_field_init)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct EqFieldInit {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[suggestion(applicability = "machine-applicable", code = ":")]
|
|
|
|
pub eq: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_dotdotdot)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct DotDotDot {
|
|
|
|
#[primary_span]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[suggestion(suggest_exclusive_range, applicability = "maybe-incorrect", code = "..")]
|
|
|
|
#[suggestion(suggest_inclusive_range, applicability = "maybe-incorrect", code = "..=")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_left_arrow_operator)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct LeftArrowOperator {
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(applicability = "maybe-incorrect", code = "< -")]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_remove_let)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct RemoveLet {
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(applicability = "machine-applicable", code = "")]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_use_eq_instead)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct UseEqInstead {
|
|
|
|
#[primary_span]
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(style = "short", applicability = "machine-applicable", code = "=")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_use_empty_block_not_semi)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct UseEmptyBlockNotSemi {
|
|
|
|
#[primary_span]
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(style = "hidden", applicability = "machine-applicable", code = "{{}}")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_comparison_interpreted_as_generic)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct ComparisonInterpretedAsGeneric {
|
|
|
|
#[primary_span]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[label(label_comparison)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub comparison: Span,
|
2022-09-14 13:11:42 -05:00
|
|
|
pub r#type: Path,
|
2022-10-22 04:07:54 -05:00
|
|
|
#[label(label_args)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub args: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub suggestion: ComparisonOrShiftInterpretedAsGenericSugg,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_shift_interpreted_as_generic)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct ShiftInterpretedAsGeneric {
|
|
|
|
#[primary_span]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[label(label_comparison)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub shift: Span,
|
2022-09-14 13:11:42 -05:00
|
|
|
pub r#type: Path,
|
2022-10-22 04:07:54 -05:00
|
|
|
#[label(label_args)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub args: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub suggestion: ComparisonOrShiftInterpretedAsGenericSugg,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[multipart_suggestion(suggestion, applicability = "machine-applicable")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct ComparisonOrShiftInterpretedAsGenericSugg {
|
|
|
|
#[suggestion_part(code = "(")]
|
|
|
|
pub left: Span,
|
|
|
|
#[suggestion_part(code = ")")]
|
|
|
|
pub right: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_found_expr_would_be_stmt)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct FoundExprWouldBeStmt {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2022-09-22 11:39:17 -05:00
|
|
|
pub token: Token,
|
2022-08-30 06:19:17 -05:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub suggestion: ExprParenthesesNeeded,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_leading_plus_not_supported)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct LeadingPlusNotSupported {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(
|
|
|
|
suggestion_remove_plus,
|
|
|
|
style = "verbose",
|
|
|
|
code = "",
|
|
|
|
applicability = "machine-applicable"
|
|
|
|
)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub remove_plus: Option<Span>,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub add_parentheses: Option<ExprParenthesesNeeded>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_parentheses_with_struct_fields)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct ParenthesesWithStructFields {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-09-14 13:11:42 -05:00
|
|
|
pub r#type: Path,
|
2022-08-30 06:19:17 -05:00
|
|
|
#[subdiagnostic]
|
|
|
|
pub braces_for_struct: BracesForStructLiteral,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub no_fields_for_fn: NoFieldsForFnCall,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[multipart_suggestion(suggestion_braces_for_struct, applicability = "maybe-incorrect")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct BracesForStructLiteral {
|
|
|
|
#[suggestion_part(code = " {{ ")]
|
|
|
|
pub first: Span,
|
|
|
|
#[suggestion_part(code = " }}")]
|
|
|
|
pub second: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[multipart_suggestion(suggestion_no_fields_for_fn, applicability = "maybe-incorrect")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct NoFieldsForFnCall {
|
|
|
|
#[suggestion_part(code = "")]
|
|
|
|
pub fields: Vec<Span>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_labeled_loop_in_break)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct LabeledLoopInBreak {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
2022-09-01 12:29:23 -05:00
|
|
|
pub sub: WrapExpressionInParentheses,
|
2022-08-30 06:19:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-09-01 12:29:23 -05:00
|
|
|
#[multipart_suggestion(
|
2022-11-07 12:47:32 -06:00
|
|
|
parse_sugg_wrap_expression_in_parentheses,
|
2022-09-01 12:29:23 -05:00
|
|
|
applicability = "machine-applicable"
|
|
|
|
)]
|
|
|
|
pub(crate) struct WrapExpressionInParentheses {
|
2022-08-30 06:19:17 -05:00
|
|
|
#[suggestion_part(code = "(")]
|
2022-09-01 12:29:23 -05:00
|
|
|
pub left: Span,
|
2022-08-30 06:19:17 -05:00
|
|
|
#[suggestion_part(code = ")")]
|
2022-09-01 12:29:23 -05:00
|
|
|
pub right: Span,
|
2022-08-30 06:19:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_array_brackets_instead_of_braces)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct ArrayBracketsInsteadOfSpaces {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sub: ArrayBracketsInsteadOfSpacesSugg,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[multipart_suggestion(suggestion, applicability = "maybe-incorrect")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct ArrayBracketsInsteadOfSpacesSugg {
|
|
|
|
#[suggestion_part(code = "[")]
|
|
|
|
pub left: Span,
|
|
|
|
#[suggestion_part(code = "]")]
|
|
|
|
pub right: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_match_arm_body_without_braces)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct MatchArmBodyWithoutBraces {
|
|
|
|
#[primary_span]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[label(label_statements)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub statements: Span,
|
2022-10-22 04:07:54 -05:00
|
|
|
#[label(label_arrow)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub arrow: Span,
|
|
|
|
pub num_statements: usize,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sub: MatchArmBodyWithoutBracesSugg,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum MatchArmBodyWithoutBracesSugg {
|
2022-10-22 04:07:54 -05:00
|
|
|
#[multipart_suggestion(suggestion_add_braces, applicability = "machine-applicable")]
|
2022-08-30 06:19:17 -05:00
|
|
|
AddBraces {
|
|
|
|
#[suggestion_part(code = "{{ ")]
|
|
|
|
left: Span,
|
|
|
|
#[suggestion_part(code = " }}")]
|
|
|
|
right: Span,
|
|
|
|
},
|
|
|
|
#[suggestion(
|
2022-10-22 04:07:54 -05:00
|
|
|
suggestion_use_comma_not_semicolon,
|
2022-08-30 06:19:17 -05:00
|
|
|
code = ",",
|
|
|
|
applicability = "machine-applicable"
|
|
|
|
)]
|
|
|
|
UseComma {
|
|
|
|
#[primary_span]
|
|
|
|
semicolon: Span,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_struct_literal_not_allowed_here)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct StructLiteralNotAllowedHere {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sub: StructLiteralNotAllowedHereSugg,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[multipart_suggestion(suggestion, applicability = "machine-applicable")]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct StructLiteralNotAllowedHereSugg {
|
|
|
|
#[suggestion_part(code = "(")]
|
|
|
|
pub left: Span,
|
|
|
|
#[suggestion_part(code = ")")]
|
|
|
|
pub right: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_invalid_interpolated_expression)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct InvalidInterpolatedExpression {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_invalid_literal_suffix_on_tuple_index)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct InvalidLiteralSuffixOnTupleIndex {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
|
|
|
pub suffix: Symbol,
|
2022-10-22 04:07:54 -05:00
|
|
|
#[help(tuple_exception_line_1)]
|
|
|
|
#[help(tuple_exception_line_2)]
|
|
|
|
#[help(tuple_exception_line_3)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub exception: Option<()>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_non_string_abi_literal)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct NonStringAbiLiteral {
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(code = "\"C\"", applicability = "maybe-incorrect")]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_mismatched_closing_delimiter)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub(crate) struct MismatchedClosingDelimiter {
|
|
|
|
#[primary_span]
|
|
|
|
pub spans: Vec<Span>,
|
|
|
|
pub delimiter: String,
|
2022-10-22 04:07:54 -05:00
|
|
|
#[label(label_unmatched)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub unmatched: Span,
|
2022-10-22 04:07:54 -05:00
|
|
|
#[label(label_opening_candidate)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub opening_candidate: Option<Span>,
|
2022-10-22 04:07:54 -05:00
|
|
|
#[label(label_unclosed)]
|
2022-08-30 06:19:17 -05:00
|
|
|
pub unclosed: Option<Span>,
|
|
|
|
}
|
2022-09-01 12:29:23 -05:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_incorrect_visibility_restriction, code = "E0704")]
|
2022-09-01 12:29:23 -05:00
|
|
|
#[help]
|
|
|
|
pub(crate) struct IncorrectVisibilityRestriction {
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(code = "in {inner_str}", applicability = "machine-applicable")]
|
|
|
|
pub span: Span,
|
|
|
|
pub inner_str: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_assignment_else_not_allowed)]
|
2022-09-01 12:29:23 -05:00
|
|
|
pub(crate) struct AssignmentElseNotAllowed {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_expected_statement_after_outer_attr)]
|
2022-09-01 12:29:23 -05:00
|
|
|
pub(crate) struct ExpectedStatementAfterOuterAttr {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_doc_comment_does_not_document_anything, code = "E0585")]
|
2022-09-01 12:29:23 -05:00
|
|
|
#[help]
|
|
|
|
pub(crate) struct DocCommentDoesNotDocumentAnything {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[suggestion(code = ",", applicability = "machine-applicable")]
|
|
|
|
pub missing_comma: Option<Span>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_const_let_mutually_exclusive)]
|
2022-09-01 12:29:23 -05:00
|
|
|
pub(crate) struct ConstLetMutuallyExclusive {
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(code = "const", applicability = "maybe-incorrect")]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_invalid_expression_in_let_else)]
|
2022-09-01 12:29:23 -05:00
|
|
|
pub(crate) struct InvalidExpressionInLetElse {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub operator: &'static str,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sugg: WrapExpressionInParentheses,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_invalid_curly_in_let_else)]
|
2022-09-01 12:29:23 -05:00
|
|
|
pub(crate) struct InvalidCurlyInLetElse {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sugg: WrapExpressionInParentheses,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_compound_assignment_expression_in_let)]
|
2022-09-01 12:29:23 -05:00
|
|
|
#[help]
|
|
|
|
pub(crate) struct CompoundAssignmentExpressionInLet {
|
|
|
|
#[primary_span]
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(style = "short", code = "=", applicability = "maybe-incorrect")]
|
2022-09-01 12:29:23 -05:00
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_suffixed_literal_in_attribute)]
|
2022-09-01 12:29:23 -05:00
|
|
|
#[help]
|
|
|
|
pub(crate) struct SuffixedLiteralInAttribute {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_invalid_meta_item)]
|
2022-09-01 12:29:23 -05:00
|
|
|
pub(crate) struct InvalidMetaItem {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-09-22 11:39:17 -05:00
|
|
|
pub token: Token,
|
2022-09-01 12:29:23 -05:00
|
|
|
}
|
2022-09-04 03:14:00 -05:00
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(
|
2022-11-07 12:47:32 -06:00
|
|
|
parse_sugg_escape_to_use_as_identifier,
|
2022-10-22 08:48:55 -05:00
|
|
|
style = "verbose",
|
2022-09-04 03:14:00 -05:00
|
|
|
applicability = "maybe-incorrect",
|
|
|
|
code = "r#"
|
|
|
|
)]
|
|
|
|
pub(crate) struct SuggEscapeToUseAsIdentifier {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
pub ident_name: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[suggestion(parse_sugg_remove_comma, applicability = "machine-applicable", code = "")]
|
2022-09-04 03:14:00 -05:00
|
|
|
pub(crate) struct SuggRemoveComma {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum ExpectedIdentifierFound {
|
2022-11-07 12:47:32 -06:00
|
|
|
#[label(parse_expected_identifier_found_reserved_identifier)]
|
2022-09-04 03:14:00 -05:00
|
|
|
ReservedIdentifier(#[primary_span] Span),
|
2022-11-07 12:47:32 -06:00
|
|
|
#[label(parse_expected_identifier_found_keyword)]
|
2022-09-04 03:14:00 -05:00
|
|
|
Keyword(#[primary_span] Span),
|
2022-11-07 12:47:32 -06:00
|
|
|
#[label(parse_expected_identifier_found_reserved_keyword)]
|
2022-09-04 03:14:00 -05:00
|
|
|
ReservedKeyword(#[primary_span] Span),
|
2022-11-07 12:47:32 -06:00
|
|
|
#[label(parse_expected_identifier_found_doc_comment)]
|
2022-09-04 03:14:00 -05:00
|
|
|
DocComment(#[primary_span] Span),
|
2022-11-07 12:47:32 -06:00
|
|
|
#[label(parse_expected_identifier)]
|
2022-09-04 03:14:00 -05:00
|
|
|
Other(#[primary_span] Span),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ExpectedIdentifierFound {
|
2022-09-22 11:39:17 -05:00
|
|
|
pub fn new(token_descr: Option<TokenDescription>, span: Span) -> Self {
|
|
|
|
(match token_descr {
|
|
|
|
Some(TokenDescription::ReservedIdentifier) => {
|
2022-09-04 03:14:00 -05:00
|
|
|
ExpectedIdentifierFound::ReservedIdentifier
|
|
|
|
}
|
2022-09-22 11:39:17 -05:00
|
|
|
Some(TokenDescription::Keyword) => ExpectedIdentifierFound::Keyword,
|
|
|
|
Some(TokenDescription::ReservedKeyword) => ExpectedIdentifierFound::ReservedKeyword,
|
|
|
|
Some(TokenDescription::DocComment) => ExpectedIdentifierFound::DocComment,
|
2022-09-04 03:14:00 -05:00
|
|
|
None => ExpectedIdentifierFound::Other,
|
|
|
|
})(span)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) struct ExpectedIdentifier {
|
|
|
|
pub span: Span,
|
2022-09-22 11:39:17 -05:00
|
|
|
pub token: Token,
|
2022-09-04 03:14:00 -05:00
|
|
|
pub suggest_raw: Option<SuggEscapeToUseAsIdentifier>,
|
|
|
|
pub suggest_remove_comma: Option<SuggRemoveComma>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedIdentifier {
|
2022-10-31 10:14:29 -05:00
|
|
|
#[track_caller]
|
2022-09-04 03:14:00 -05:00
|
|
|
fn into_diagnostic(
|
|
|
|
self,
|
|
|
|
handler: &'a rustc_errors::Handler,
|
|
|
|
) -> rustc_errors::DiagnosticBuilder<'a, G> {
|
2022-09-22 11:39:17 -05:00
|
|
|
let token_descr = super::parser::TokenDescription::from_token(&self.token);
|
|
|
|
|
|
|
|
let mut diag = handler.struct_diagnostic(match token_descr {
|
|
|
|
Some(TokenDescription::ReservedIdentifier) => {
|
2022-11-07 12:47:32 -06:00
|
|
|
fluent::parse_expected_identifier_found_reserved_identifier_str
|
2022-09-04 03:14:00 -05:00
|
|
|
}
|
2022-11-07 12:47:32 -06:00
|
|
|
Some(TokenDescription::Keyword) => fluent::parse_expected_identifier_found_keyword_str,
|
2022-09-22 11:39:17 -05:00
|
|
|
Some(TokenDescription::ReservedKeyword) => {
|
2022-11-07 12:47:32 -06:00
|
|
|
fluent::parse_expected_identifier_found_reserved_keyword_str
|
2022-09-04 03:14:00 -05:00
|
|
|
}
|
2022-09-22 11:39:17 -05:00
|
|
|
Some(TokenDescription::DocComment) => {
|
2022-11-07 12:47:32 -06:00
|
|
|
fluent::parse_expected_identifier_found_doc_comment_str
|
2022-09-04 03:14:00 -05:00
|
|
|
}
|
2022-11-07 12:47:32 -06:00
|
|
|
None => fluent::parse_expected_identifier_found_str,
|
2022-09-04 03:14:00 -05:00
|
|
|
});
|
|
|
|
diag.set_span(self.span);
|
2022-09-22 11:39:17 -05:00
|
|
|
diag.set_arg("token", self.token);
|
2022-09-04 03:14:00 -05:00
|
|
|
|
|
|
|
if let Some(sugg) = self.suggest_raw {
|
|
|
|
sugg.add_to_diagnostic(&mut diag);
|
|
|
|
}
|
|
|
|
|
2022-09-22 11:39:17 -05:00
|
|
|
ExpectedIdentifierFound::new(token_descr, self.span).add_to_diagnostic(&mut diag);
|
2022-09-04 03:14:00 -05:00
|
|
|
|
|
|
|
if let Some(sugg) = self.suggest_remove_comma {
|
|
|
|
sugg.add_to_diagnostic(&mut diag);
|
|
|
|
}
|
|
|
|
|
|
|
|
diag
|
|
|
|
}
|
|
|
|
}
|
2022-09-04 13:12:00 -05:00
|
|
|
|
|
|
|
pub(crate) struct ExpectedSemi {
|
|
|
|
pub span: Span,
|
2022-09-22 11:39:17 -05:00
|
|
|
pub token: Token,
|
2022-09-04 13:12:00 -05:00
|
|
|
|
|
|
|
pub unexpected_token_label: Option<Span>,
|
|
|
|
pub sugg: ExpectedSemiSugg,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for ExpectedSemi {
|
2022-10-31 10:14:29 -05:00
|
|
|
#[track_caller]
|
2022-09-04 13:12:00 -05:00
|
|
|
fn into_diagnostic(
|
|
|
|
self,
|
|
|
|
handler: &'a rustc_errors::Handler,
|
|
|
|
) -> rustc_errors::DiagnosticBuilder<'a, G> {
|
2022-09-22 11:39:17 -05:00
|
|
|
let token_descr = super::parser::TokenDescription::from_token(&self.token);
|
|
|
|
|
|
|
|
let mut diag = handler.struct_diagnostic(match token_descr {
|
|
|
|
Some(TokenDescription::ReservedIdentifier) => {
|
2022-11-07 12:47:32 -06:00
|
|
|
fluent::parse_expected_semi_found_reserved_identifier_str
|
2022-09-04 13:12:00 -05:00
|
|
|
}
|
2022-11-07 12:47:32 -06:00
|
|
|
Some(TokenDescription::Keyword) => fluent::parse_expected_semi_found_keyword_str,
|
2022-09-22 11:39:17 -05:00
|
|
|
Some(TokenDescription::ReservedKeyword) => {
|
2022-11-07 12:47:32 -06:00
|
|
|
fluent::parse_expected_semi_found_reserved_keyword_str
|
2022-09-04 13:12:00 -05:00
|
|
|
}
|
2022-11-07 12:47:32 -06:00
|
|
|
Some(TokenDescription::DocComment) => fluent::parse_expected_semi_found_doc_comment_str,
|
|
|
|
None => fluent::parse_expected_semi_found_str,
|
2022-09-04 13:12:00 -05:00
|
|
|
});
|
|
|
|
diag.set_span(self.span);
|
2022-09-22 11:39:17 -05:00
|
|
|
diag.set_arg("token", self.token);
|
2022-09-04 13:12:00 -05:00
|
|
|
|
|
|
|
if let Some(unexpected_token_label) = self.unexpected_token_label {
|
2022-11-07 12:47:32 -06:00
|
|
|
diag.span_label(unexpected_token_label, fluent::parse_label_unexpected_token);
|
2022-09-04 13:12:00 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
self.sugg.add_to_diagnostic(&mut diag);
|
|
|
|
|
|
|
|
diag
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum ExpectedSemiSugg {
|
2022-11-07 12:47:32 -06:00
|
|
|
#[suggestion(parse_sugg_change_this_to_semi, code = ";", applicability = "machine-applicable")]
|
2022-09-04 13:12:00 -05:00
|
|
|
ChangeToSemi(#[primary_span] Span),
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(
|
2022-11-07 12:47:32 -06:00
|
|
|
parse_sugg_add_semi,
|
2022-10-22 08:48:55 -05:00
|
|
|
style = "short",
|
|
|
|
code = ";",
|
|
|
|
applicability = "machine-applicable"
|
|
|
|
)]
|
2022-09-04 13:12:00 -05:00
|
|
|
AddSemi(#[primary_span] Span),
|
|
|
|
}
|
2022-09-04 13:19:49 -05:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_struct_literal_body_without_path)]
|
2022-09-04 13:19:49 -05:00
|
|
|
pub(crate) struct StructLiteralBodyWithoutPath {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sugg: StructLiteralBodyWithoutPathSugg,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[multipart_suggestion(suggestion, applicability = "has-placeholders")]
|
2022-09-04 13:19:49 -05:00
|
|
|
pub(crate) struct StructLiteralBodyWithoutPathSugg {
|
|
|
|
#[suggestion_part(code = "{{ SomeStruct ")]
|
|
|
|
pub before: Span,
|
|
|
|
#[suggestion_part(code = " }}")]
|
|
|
|
pub after: Span,
|
|
|
|
}
|
2022-09-08 11:23:31 -05:00
|
|
|
|
2023-01-08 23:29:54 -06:00
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(parse_struct_literal_needing_parens)]
|
|
|
|
pub(crate) struct StructLiteralNeedingParens {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sugg: StructLiteralNeedingParensSugg,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[multipart_suggestion(suggestion, applicability = "machine-applicable")]
|
|
|
|
pub(crate) struct StructLiteralNeedingParensSugg {
|
|
|
|
#[suggestion_part(code = "(")]
|
|
|
|
pub before: Span,
|
|
|
|
#[suggestion_part(code = ")")]
|
|
|
|
pub after: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-08 11:23:31 -05:00
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_unmatched_angle_brackets)]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct UnmatchedAngleBrackets {
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(code = "", applicability = "machine-applicable")]
|
|
|
|
pub span: Span,
|
|
|
|
pub num_extra_brackets: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_generic_parameters_without_angle_brackets)]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct GenericParamsWithoutAngleBrackets {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sugg: GenericParamsWithoutAngleBracketsSugg,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[multipart_suggestion(suggestion, applicability = "machine-applicable")]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct GenericParamsWithoutAngleBracketsSugg {
|
|
|
|
#[suggestion_part(code = "<")]
|
|
|
|
pub left: Span,
|
|
|
|
#[suggestion_part(code = ">")]
|
|
|
|
pub right: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_comparison_operators_cannot_be_chained)]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct ComparisonOperatorsCannotBeChained {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Vec<Span>,
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(
|
2022-11-07 12:47:32 -06:00
|
|
|
parse_sugg_turbofish_syntax,
|
2022-10-22 08:48:55 -05:00
|
|
|
style = "verbose",
|
2022-09-08 11:23:31 -05:00
|
|
|
code = "::",
|
|
|
|
applicability = "maybe-incorrect"
|
|
|
|
)]
|
|
|
|
pub suggest_turbofish: Option<Span>,
|
2022-11-07 12:47:32 -06:00
|
|
|
#[help(parse_sugg_turbofish_syntax)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[help(sugg_parentheses_for_function_args)]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub help_turbofish: Option<()>,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub chaining_sugg: Option<ComparisonOperatorsCannotBeChainedSugg>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum ComparisonOperatorsCannotBeChainedSugg {
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(
|
2022-10-22 04:07:54 -05:00
|
|
|
sugg_split_comparison,
|
2022-10-22 08:48:55 -05:00
|
|
|
style = "verbose",
|
2022-09-08 11:23:31 -05:00
|
|
|
code = " && {middle_term}",
|
|
|
|
applicability = "maybe-incorrect"
|
|
|
|
)]
|
|
|
|
SplitComparison {
|
|
|
|
#[primary_span]
|
|
|
|
span: Span,
|
|
|
|
middle_term: String,
|
|
|
|
},
|
2022-10-22 04:07:54 -05:00
|
|
|
#[multipart_suggestion(sugg_parenthesize, applicability = "maybe-incorrect")]
|
2022-09-08 11:23:31 -05:00
|
|
|
Parenthesize {
|
|
|
|
#[suggestion_part(code = "(")]
|
|
|
|
left: Span,
|
|
|
|
#[suggestion_part(code = ")")]
|
|
|
|
right: Span,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_question_mark_in_type)]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct QuestionMarkInType {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sugg: QuestionMarkInTypeSugg,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[multipart_suggestion(suggestion, applicability = "machine-applicable")]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct QuestionMarkInTypeSugg {
|
|
|
|
#[suggestion_part(code = "Option<")]
|
|
|
|
pub left: Span,
|
|
|
|
#[suggestion_part(code = ">")]
|
|
|
|
pub right: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_unexpected_parentheses_in_for_head)]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct ParenthesesInForHead {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Vec<Span>,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sugg: ParenthesesInForHeadSugg,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[multipart_suggestion(suggestion, applicability = "machine-applicable")]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct ParenthesesInForHeadSugg {
|
2022-10-24 05:24:10 -05:00
|
|
|
#[suggestion_part(code = "{left_snippet}")]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub left: Span,
|
2022-10-24 05:24:10 -05:00
|
|
|
pub left_snippet: String,
|
|
|
|
#[suggestion_part(code = "{right_snippet}")]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub right: Span,
|
2022-10-24 05:24:10 -05:00
|
|
|
pub right_snippet: String,
|
2022-09-08 11:23:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_doc_comment_on_param_type)]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct DocCommentOnParamType {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_attribute_on_param_type)]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct AttributeOnParamType {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_pattern_method_param_without_body, code = "E0642")]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct PatternMethodParamWithoutBody {
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(code = "_", applicability = "machine-applicable")]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_self_param_not_first)]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct SelfParamNotFirst {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-11-11 14:22:47 -06:00
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_invalid_identifier_with_leading_number)]
|
2022-11-11 14:22:47 -06:00
|
|
|
pub(crate) struct InvalidIdentiferStartsWithNumber {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
2022-09-08 11:23:31 -05:00
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_const_generic_without_braces)]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct ConstGenericWithoutBraces {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sugg: ConstGenericWithoutBracesSugg,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
2022-10-22 04:07:54 -05:00
|
|
|
#[multipart_suggestion(suggestion, applicability = "machine-applicable")]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct ConstGenericWithoutBracesSugg {
|
|
|
|
#[suggestion_part(code = "{{ ")]
|
|
|
|
pub left: Span,
|
|
|
|
#[suggestion_part(code = " }}")]
|
|
|
|
pub right: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_unexpected_const_param_declaration)]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct UnexpectedConstParamDeclaration {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sugg: Option<UnexpectedConstParamDeclarationSugg>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
pub(crate) enum UnexpectedConstParamDeclarationSugg {
|
2022-10-22 04:07:54 -05:00
|
|
|
#[multipart_suggestion(suggestion, applicability = "machine-applicable")]
|
2022-09-08 11:23:31 -05:00
|
|
|
AddParam {
|
|
|
|
#[suggestion_part(code = "<{snippet}>")]
|
|
|
|
impl_generics: Span,
|
|
|
|
#[suggestion_part(code = "{ident}")]
|
|
|
|
incorrect_decl: Span,
|
|
|
|
snippet: String,
|
|
|
|
ident: String,
|
|
|
|
},
|
2022-10-22 04:07:54 -05:00
|
|
|
#[multipart_suggestion(suggestion, applicability = "machine-applicable")]
|
2022-09-08 11:23:31 -05:00
|
|
|
AppendParam {
|
|
|
|
#[suggestion_part(code = ", {snippet}")]
|
|
|
|
impl_generics_end: Span,
|
|
|
|
#[suggestion_part(code = "{ident}")]
|
|
|
|
incorrect_decl: Span,
|
|
|
|
snippet: String,
|
|
|
|
ident: String,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_unexpected_const_in_generic_param)]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct UnexpectedConstInGenericParam {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(style = "verbose", code = "", applicability = "maybe-incorrect")]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub to_remove: Option<Span>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_async_move_order_incorrect)]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct AsyncMoveOrderIncorrect {
|
|
|
|
#[primary_span]
|
2022-10-22 08:48:55 -05:00
|
|
|
#[suggestion(style = "verbose", code = "async move", applicability = "maybe-incorrect")]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub span: Span,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_double_colon_in_bound)]
|
2022-09-08 11:23:31 -05:00
|
|
|
pub(crate) struct DoubleColonInBound {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[suggestion(code = ": ", applicability = "machine-applicable")]
|
|
|
|
pub between: Span,
|
|
|
|
}
|
2022-11-09 19:06:11 -06:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_fn_ptr_with_generics)]
|
2022-11-09 19:06:11 -06:00
|
|
|
pub(crate) struct FnPtrWithGenerics {
|
|
|
|
#[primary_span]
|
|
|
|
pub span: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sugg: Option<FnPtrWithGenericsSugg>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[multipart_suggestion(suggestion, applicability = "maybe-incorrect")]
|
|
|
|
pub(crate) struct FnPtrWithGenericsSugg {
|
|
|
|
#[suggestion_part(code = "{snippet}")]
|
|
|
|
pub left: Span,
|
|
|
|
pub snippet: String,
|
|
|
|
#[suggestion_part(code = "")]
|
|
|
|
pub right: Span,
|
|
|
|
pub arity: usize,
|
|
|
|
pub for_param_list_exists: bool,
|
|
|
|
}
|
2022-11-14 18:53:17 -06:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
2022-11-07 12:47:32 -06:00
|
|
|
#[diag(parse_unexpected_if_with_if)]
|
2022-11-14 18:53:17 -06:00
|
|
|
pub(crate) struct UnexpectedIfWithIf(
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(applicability = "machine-applicable", code = " ", style = "verbose")]
|
|
|
|
pub Span,
|
|
|
|
);
|
2022-12-09 11:31:34 -06:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(parse_maybe_fn_typo_with_impl)]
|
|
|
|
pub(crate) struct FnTypoWithImpl {
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(applicability = "maybe-incorrect", code = "impl", style = "verbose")]
|
|
|
|
pub fn_span: Span,
|
|
|
|
}
|
2022-12-27 00:14:40 -06:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(parse_expected_fn_path_found_fn_keyword)]
|
|
|
|
pub(crate) struct ExpectedFnPathFoundFnKeyword {
|
|
|
|
#[primary_span]
|
|
|
|
#[suggestion(applicability = "machine-applicable", code = "Fn", style = "verbose")]
|
|
|
|
pub fn_token_span: Span,
|
|
|
|
}
|
2023-01-06 10:47:21 -06:00
|
|
|
|
|
|
|
#[derive(Diagnostic)]
|
|
|
|
#[diag(parse_where_clause_before_tuple_struct_body)]
|
|
|
|
pub(crate) struct WhereClauseBeforeTupleStructBody {
|
|
|
|
#[primary_span]
|
|
|
|
#[label]
|
|
|
|
pub span: Span,
|
|
|
|
#[label(name_label)]
|
|
|
|
pub name: Span,
|
|
|
|
#[label(body_label)]
|
|
|
|
pub body: Span,
|
|
|
|
#[subdiagnostic]
|
|
|
|
pub sugg: Option<WhereClauseBeforeTupleStructBodySugg>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Subdiagnostic)]
|
|
|
|
#[multipart_suggestion(suggestion, applicability = "machine-applicable")]
|
|
|
|
pub(crate) struct WhereClauseBeforeTupleStructBodySugg {
|
|
|
|
#[suggestion_part(code = "{snippet}")]
|
|
|
|
pub left: Span,
|
|
|
|
pub snippet: String,
|
|
|
|
#[suggestion_part(code = "")]
|
|
|
|
pub right: Span,
|
|
|
|
}
|