Salsify the crate graph

I.e. make it not one giant input but multiple, for incrementality and decreased memory usage for Salsa 3 reasons.
This commit is contained in:
Chayim Refael Friedman 2025-01-02 01:45:32 +02:00
parent 44f18c3d05
commit c94e9efbef
108 changed files with 3630 additions and 2512 deletions

View file

@ -14,7 +14,7 @@ use std::{
ops::{self, Not as _},
};
use base_db::CrateId;
use base_db::Crate;
use chalk_ir::{
cast::Cast,
fold::{Shift, TypeFoldable},
@ -801,7 +801,7 @@ impl<'a> TyLoweringContext<'a> {
}
}
fn lower_impl_trait(&mut self, bounds: &[TypeBound], krate: CrateId) -> ImplTrait {
fn lower_impl_trait(&mut self, bounds: &[TypeBound], krate: Crate) -> ImplTrait {
cov_mark::hit!(lower_rpit);
let self_ty = TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0)).intern(Interner);
let predicates = self.with_shifted_in(DebruijnIndex::ONE, |ctx| {
@ -1863,8 +1863,11 @@ pub(crate) fn const_or_path_to_chalk<'g>(
.unwrap_or_else(|| unknown_const(expected_ty))
}
&ConstRef::Complex(it) => {
let crate_data = &db.crate_graph()[resolver.krate()];
if crate_data.env.get("__ra_is_test_fixture").is_none() && crate_data.origin.is_local()
let krate = resolver.krate();
// Keep the `&&` this way, because it's better to access the crate data, as we access it for
// a bunch of other things nevertheless.
if krate.data(db).origin.is_local()
&& krate.env(db).get("__ra_is_test_fixture").is_none()
{
// FIXME: current `InTypeConstId` is very unstable, so we only use it in non local crate
// that are unlikely to be edited.