Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/hir-ty/src/next_solver/interner.rs9
-rw-r--r--crates/hir/src/lib.rs1
-rw-r--r--crates/rust-analyzer/src/cli/analysis_stats.rs2
3 files changed, 12 insertions, 0 deletions
diff --git a/crates/hir-ty/src/next_solver/interner.rs b/crates/hir-ty/src/next_solver/interner.rs
index 42f1d926d7..ce8b76837a 100644
--- a/crates/hir-ty/src/next_solver/interner.rs
+++ b/crates/hir-ty/src/next_solver/interner.rs
@@ -2,6 +2,7 @@
use std::{fmt, ops::ControlFlow};
+pub use tls_cache::clear_tls_solver_cache;
pub use tls_db::{attach_db, attach_db_allow_change, with_attached_db};
use base_db::Crate;
@@ -2239,4 +2240,12 @@ mod tls_cache {
})
})
}
+
+ /// Clears the thread-local trait solver cache.
+ ///
+ /// Should be called before getting memory usage estimations, as the solver cache
+ /// is per-revision and usually should be excluded from estimations.
+ pub fn clear_tls_solver_cache() {
+ GLOBAL_CACHE.with_borrow_mut(|handle| *handle = None);
+ }
}
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 48eafb0bd4..9418903123 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -171,6 +171,7 @@ pub use {
method_resolution::TyFingerprint,
mir::{MirEvalError, MirLowerError},
next_solver::abi::Safety,
+ next_solver::clear_tls_solver_cache,
},
intern::{Symbol, sym},
};
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs
index 717bd230a2..de24bc09ff 100644
--- a/crates/rust-analyzer/src/cli/analysis_stats.rs
+++ b/crates/rust-analyzer/src/cli/analysis_stats.rs
@@ -345,6 +345,8 @@ impl flags::AnalysisStats {
self.run_term_search(&workspace, db, &vfs, &file_ids, verbosity);
}
+ hir::clear_tls_solver_cache();
+
let db = host.raw_database_mut();
db.trigger_lru_eviction();