about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/errors.rs
diff options
context:
space:
mode:
authorJean CASPAR <55629512+JeanCASPAR@users.noreply.github.com>2022-08-16 22:28:51 +0200
committerJean CASPAR <55629512+JeanCASPAR@users.noreply.github.com>2022-08-22 19:19:58 +0200
commit73ae38bac10e010aee20fc2f56735fdada86e5dd (patch)
treef8470a3e29081125967775e4e3850d908ef73a3f /compiler/rustc_ast_lowering/src/errors.rs
parenta8a33cf27166d3eabaffc58ed3799e054af3b0c6 (diff)
downloadrust-73ae38bac10e010aee20fc2f56735fdada86e5dd.tar.gz
rust-73ae38bac10e010aee20fc2f56735fdada86e5dd.zip
Migrate ast_lowering::path to SessionDiagnostic
Diffstat (limited to 'compiler/rustc_ast_lowering/src/errors.rs')
-rw-r--r--compiler/rustc_ast_lowering/src/errors.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/compiler/rustc_ast_lowering/src/errors.rs b/compiler/rustc_ast_lowering/src/errors.rs
new file mode 100644
index 00000000000..8701491c9eb
--- /dev/null
+++ b/compiler/rustc_ast_lowering/src/errors.rs
@@ -0,0 +1,29 @@
+use rustc_errors::{fluent, AddSubdiagnostic, Applicability, Diagnostic};
+use rustc_macros::SessionDiagnostic;
+use rustc_span::Span;
+
+#[derive(SessionDiagnostic, Clone, Copy)]
+#[error(ast_lowering::generic_type_with_parentheses, code = "E0214")]
+pub struct GenericTypeWithParentheses {
+    #[primary_span]
+    #[label]
+    pub span: Span,
+    #[subdiagnostic]
+    pub sub: Option<UseAngleBrackets>,
+}
+
+#[derive(Clone, Copy)]
+pub struct UseAngleBrackets {
+    pub open_param: Span,
+    pub close_param: Span,
+}
+
+impl AddSubdiagnostic for UseAngleBrackets {
+    fn add_to_diagnostic(self, diag: &mut Diagnostic) {
+        diag.multipart_suggestion(
+            fluent::ast_lowering::use_angle_brackets,
+            vec![(self.open_param, String::from("<")), (self.close_param, String::from(">"))],
+            Applicability::MaybeIncorrect,
+        );
+    }
+}