Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/nameres/diagnostics.rs')
-rw-r--r--crates/hir-def/src/nameres/diagnostics.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/crates/hir-def/src/nameres/diagnostics.rs b/crates/hir-def/src/nameres/diagnostics.rs
index 9cffb3c9f3..0a3f7bf7ec 100644
--- a/crates/hir-def/src/nameres/diagnostics.rs
+++ b/crates/hir-def/src/nameres/diagnostics.rs
@@ -40,6 +40,23 @@ pub enum DefDiagnosticKind {
MacroDefError { ast: AstId<ast::Macro>, message: String },
}
+#[derive(Clone, Debug, PartialEq, Eq)]
+pub struct DefDiagnostics(Option<triomphe::Arc<Box<[DefDiagnostic]>>>);
+
+impl DefDiagnostics {
+ pub fn new(diagnostics: Vec<DefDiagnostic>) -> Self {
+ Self(if diagnostics.is_empty() {
+ None
+ } else {
+ Some(triomphe::Arc::new(diagnostics.into_boxed_slice()))
+ })
+ }
+
+ pub fn iter(&self) -> impl Iterator<Item = &DefDiagnostic> {
+ self.0.as_ref().into_iter().flat_map(|it| &***it)
+ }
+}
+
#[derive(Debug, PartialEq, Eq)]
pub struct DefDiagnostic {
pub in_module: LocalModuleId,