diff options
| author | Jean CASPAR <55629512+JeanCASPAR@users.noreply.github.com> | 2022-08-17 16:58:57 +0200 |
|---|---|---|
| committer | Jean CASPAR <55629512+JeanCASPAR@users.noreply.github.com> | 2022-08-22 19:19:59 +0200 |
| commit | 0043d10c712769b45d6cb7fb3fcc141878263d18 (patch) | |
| tree | c20d7ed3bfd6c24ab4b1a78ff3649b79a06c11c1 /compiler/rustc_ast_lowering/src/errors.rs | |
| parent | 73ae38bac10e010aee20fc2f56735fdada86e5dd (diff) | |
| download | rust-0043d10c712769b45d6cb7fb3fcc141878263d18.tar.gz rust-0043d10c712769b45d6cb7fb3fcc141878263d18.zip | |
Migrate ast_lowering::lib and ast_lowering::item to SessionDiagnostic
Diffstat (limited to 'compiler/rustc_ast_lowering/src/errors.rs')
| -rw-r--r-- | compiler/rustc_ast_lowering/src/errors.rs | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/errors.rs index 8701491c9eb..c6337ce161d 100644 --- a/compiler/rustc_ast_lowering/src/errors.rs +++ b/compiler/rustc_ast_lowering/src/errors.rs @@ -1,6 +1,6 @@ use rustc_errors::{fluent, AddSubdiagnostic, Applicability, Diagnostic}; use rustc_macros::SessionDiagnostic; -use rustc_span::Span; +use rustc_span::{Span, Symbol}; #[derive(SessionDiagnostic, Clone, Copy)] #[error(ast_lowering::generic_type_with_parentheses, code = "E0214")] @@ -27,3 +27,54 @@ impl AddSubdiagnostic for UseAngleBrackets { ); } } + +#[derive(SessionDiagnostic)] +#[help] +#[error(ast_lowering::invalid_abi, code = "E0703")] +pub struct InvalidAbi { + #[primary_span] + #[label] + pub span: Span, + pub abi: Symbol, + pub valid_abis: String, +} + +#[derive(SessionDiagnostic, Clone, Copy)] +#[error(ast_lowering::assoc_ty_parentheses)] +pub struct AssocTyParentheses { + #[primary_span] + pub span: Span, + #[subdiagnostic] + pub sub: AssocTyParenthesesSub, +} + +#[derive(Clone, Copy)] +pub enum AssocTyParenthesesSub { + Empty { parentheses_span: Span }, + NotEmpty { open_param: Span, close_param: Span }, +} + +impl AddSubdiagnostic for AssocTyParenthesesSub { + fn add_to_diagnostic(self, diag: &mut Diagnostic) { + match self { + Self::Empty { parentheses_span } => diag.multipart_suggestion( + fluent::ast_lowering::remove_parentheses, + vec![(parentheses_span, String::new())], + Applicability::MaybeIncorrect, + ), + Self::NotEmpty { open_param, close_param } => diag.multipart_suggestion( + fluent::ast_lowering::use_angle_brackets, + vec![(open_param, String::from("<")), (close_param, String::from(">"))], + Applicability::MaybeIncorrect, + ), + }; + } +} + +#[derive(SessionDiagnostic)] +#[error(ast_lowering::misplaced_impl_trait, code = "E0562")] +pub struct MisplacedImplTrait { + #[primary_span] + pub span: Span, + pub position: String, +} |
