Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/infer/diagnostics.rs')
| -rw-r--r-- | crates/hir-ty/src/infer/diagnostics.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/crates/hir-ty/src/infer/diagnostics.rs b/crates/hir-ty/src/infer/diagnostics.rs index 844eb02ab0..2bdc6f9491 100644 --- a/crates/hir-ty/src/infer/diagnostics.rs +++ b/crates/hir-ty/src/infer/diagnostics.rs @@ -11,6 +11,7 @@ use hir_def::expr_store::ExpressionStore; use hir_def::expr_store::path::Path; use hir_def::{hir::ExprOrPatId, resolver::Resolver}; use la_arena::{Idx, RawIdx}; +use thin_vec::ThinVec; use crate::{ InferenceDiagnostic, InferenceTyDiagnosticSource, TyLoweringDiagnostic, @@ -24,10 +25,10 @@ use crate::{ // to our resolver and so we cannot have mutable reference, but we really want to have // ability to dispatch diagnostics during this work otherwise the code becomes a complete mess. #[derive(Debug, Default, Clone)] -pub(super) struct Diagnostics<'db>(RefCell<Vec<InferenceDiagnostic<'db>>>); +pub(super) struct Diagnostics(RefCell<ThinVec<InferenceDiagnostic>>); -impl<'db> Diagnostics<'db> { - pub(super) fn push(&self, diagnostic: InferenceDiagnostic<'db>) { +impl Diagnostics { + pub(super) fn push(&self, diagnostic: InferenceDiagnostic) { self.0.borrow_mut().push(diagnostic); } @@ -41,19 +42,19 @@ impl<'db> Diagnostics<'db> { ); } - pub(super) fn finish(self) -> Vec<InferenceDiagnostic<'db>> { + pub(super) fn finish(self) -> ThinVec<InferenceDiagnostic> { self.0.into_inner() } } -pub(crate) struct PathDiagnosticCallbackData<'a, 'db> { +pub(crate) struct PathDiagnosticCallbackData<'a> { node: ExprOrPatId, - diagnostics: &'a Diagnostics<'db>, + diagnostics: &'a Diagnostics, } pub(super) struct InferenceTyLoweringContext<'db, 'a> { ctx: TyLoweringContext<'db, 'a>, - diagnostics: &'a Diagnostics<'db>, + diagnostics: &'a Diagnostics, source: InferenceTyDiagnosticSource, } @@ -63,7 +64,7 @@ impl<'db, 'a> InferenceTyLoweringContext<'db, 'a> { db: &'db dyn HirDatabase, resolver: &'a Resolver<'db>, store: &'a ExpressionStore, - diagnostics: &'a Diagnostics<'db>, + diagnostics: &'a Diagnostics, source: InferenceTyDiagnosticSource, generic_def: GenericDefId, lifetime_elision: LifetimeElisionKind<'db>, |