226 lines
5.2 KiB
Rust
226 lines
5.2 KiB
Rust
//! Errors emitted by ast_passes.
|
|
|
|
use rustc_macros::{Diagnostic, Subdiagnostic};
|
|
use rustc_span::{Span, Symbol};
|
|
|
|
use crate::ast_validation::ForbiddenLetReason;
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_forbidden_let)]
|
|
#[note]
|
|
pub struct ForbiddenLet {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
#[subdiagnostic]
|
|
pub(crate) reason: ForbiddenLetReason,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_forbidden_let_stable)]
|
|
#[note]
|
|
pub struct ForbiddenLetStable {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_forbidden_assoc_constraint)]
|
|
pub struct ForbiddenAssocConstraint {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_keyword_lifetime)]
|
|
pub struct KeywordLifetime {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_invalid_label)]
|
|
pub struct InvalidLabel {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
pub name: Symbol,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_invalid_visibility, code = "E0449")]
|
|
pub struct InvalidVisibility {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
#[label(implied)]
|
|
pub implied: Option<Span>,
|
|
#[subdiagnostic]
|
|
pub note: Option<InvalidVisibilityNote>,
|
|
}
|
|
|
|
#[derive(Subdiagnostic)]
|
|
pub enum InvalidVisibilityNote {
|
|
#[note(individual_impl_items)]
|
|
IndividualImplItems,
|
|
#[note(individual_foreign_items)]
|
|
IndividualForeignItems,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_trait_fn_const, code = "E0379")]
|
|
pub struct TraitFnConst {
|
|
#[primary_span]
|
|
#[label]
|
|
pub span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_forbidden_lifetime_bound)]
|
|
pub struct ForbiddenLifetimeBound {
|
|
#[primary_span]
|
|
pub spans: Vec<Span>,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_forbidden_non_lifetime_param)]
|
|
pub struct ForbiddenNonLifetimeParam {
|
|
#[primary_span]
|
|
pub spans: Vec<Span>,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_fn_param_too_many)]
|
|
pub struct FnParamTooMany {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
pub max_num_args: usize,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_fn_param_c_var_args_only)]
|
|
pub struct FnParamCVarArgsOnly {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_fn_param_c_var_args_not_last)]
|
|
pub struct FnParamCVarArgsNotLast {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_fn_param_doc_comment)]
|
|
pub struct FnParamDocComment {
|
|
#[primary_span]
|
|
#[label]
|
|
pub span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_fn_param_forbidden_attr)]
|
|
pub struct FnParamForbiddenAttr {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_fn_param_forbidden_self)]
|
|
#[note]
|
|
pub struct FnParamForbiddenSelf {
|
|
#[primary_span]
|
|
#[label]
|
|
pub span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_forbidden_default)]
|
|
pub struct ForbiddenDefault {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
#[label]
|
|
pub def_span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_assoc_const_without_body)]
|
|
pub struct AssocConstWithoutBody {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
#[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
|
|
pub replace_span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_assoc_fn_without_body)]
|
|
pub struct AssocFnWithoutBody {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
#[suggestion(code = " {{ <body> }}", applicability = "has-placeholders")]
|
|
pub replace_span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_assoc_type_without_body)]
|
|
pub struct AssocTypeWithoutBody {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
#[suggestion(code = " = <type>;", applicability = "has-placeholders")]
|
|
pub replace_span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_const_without_body)]
|
|
pub struct ConstWithoutBody {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
#[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
|
|
pub replace_span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_static_without_body)]
|
|
pub struct StaticWithoutBody {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
#[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
|
|
pub replace_span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_ty_alias_without_body)]
|
|
pub struct TyAliasWithoutBody {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
#[suggestion(code = " = <type>;", applicability = "has-placeholders")]
|
|
pub replace_span: Span,
|
|
}
|
|
|
|
#[derive(Diagnostic)]
|
|
#[diag(ast_passes_fn_without_body)]
|
|
pub struct FnWithoutBody {
|
|
#[primary_span]
|
|
pub span: Span,
|
|
#[suggestion(code = " {{ <body> }}", applicability = "has-placeholders")]
|
|
pub replace_span: Span,
|
|
#[subdiagnostic]
|
|
pub extern_block_suggestion: Option<ExternBlockSuggestion>,
|
|
}
|
|
|
|
#[derive(Subdiagnostic)]
|
|
pub enum ExternBlockSuggestion {
|
|
#[multipart_suggestion(ast_passes_extern_block_suggestion, applicability = "maybe-incorrect")]
|
|
Implicit {
|
|
#[suggestion_part(code = "extern {{")]
|
|
start_span: Span,
|
|
#[suggestion_part(code = " }}")]
|
|
end_span: Span,
|
|
},
|
|
#[multipart_suggestion(ast_passes_extern_block_suggestion, applicability = "maybe-incorrect")]
|
|
Explicit {
|
|
#[suggestion_part(code = "extern \"{abi}\" {{")]
|
|
start_span: Span,
|
|
#[suggestion_part(code = " }}")]
|
|
end_span: Span,
|
|
abi: Symbol,
|
|
},
|
|
}
|