Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ debug = 2

# ungrammar = { path = "../ungrammar" }

# rust-analyzer-salsa = { path = "../salsa" }
# salsa = { path = "../salsa" }

[workspace.dependencies]
# local crates
Expand Down Expand Up @@ -131,7 +131,7 @@ process-wrap = { version = "8.2.0", features = ["std"] }
pulldown-cmark-to-cmark = "10.0.4"
pulldown-cmark = { version = "0.9.6", default-features = false }
rayon = "1.10.0"
salsa = "0.19"
salsa = "0.20.0"
rustc-hash = "2.1.1"
semver = "1.0.26"
serde = { version = "1.0.219" }
Expand Down
2 changes: 1 addition & 1 deletion crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl BuiltDependency {

pub type CratesIdMap = FxHashMap<CrateBuilderId, Crate>;

#[salsa::input(no_debug)]
#[salsa::input]
#[derive(Debug)]
pub struct Crate {
#[return_ref]
Expand Down
10 changes: 5 additions & 5 deletions crates/base-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub use vfs::{AnchoredPath, AnchoredPathBuf, FileId, VfsPath, file_set::FileSet}
#[macro_export]
macro_rules! impl_intern_key {
($id:ident, $loc:ident) => {
#[salsa::interned(no_debug, no_lifetime)]
#[salsa::interned(no_lifetime)]
pub struct $id {
pub loc: $loc,
}
Expand Down Expand Up @@ -152,7 +152,7 @@ impl Files {
}
}

#[salsa::interned(no_lifetime, constructor=from_span)]
#[salsa::interned(no_lifetime, debug, constructor=from_span)]
pub struct EditionedFileId {
pub editioned_file_id: span::EditionedFileId,
}
Expand Down Expand Up @@ -187,18 +187,18 @@ impl EditionedFileId {
}
}

#[salsa::input]
#[salsa::input(debug)]
pub struct FileText {
pub text: Arc<str>,
pub file_id: vfs::FileId,
}

#[salsa::input]
#[salsa::input(debug)]
pub struct FileSourceRootInput {
pub source_root_id: SourceRootId,
}

#[salsa::input]
#[salsa::input(debug)]
pub struct SourceRootInput {
pub source_root: Arc<SourceRoot>,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ impl_from!(

/// A constant, which might appears as a const item, an anonymous const block in expressions
/// or patterns, or as a constant in types with const generics.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
pub enum GeneralConstId {
ConstId(ConstId),
StaticId(StaticId),
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-expand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ impl ExpandTo {

intern::impl_internable!(ModPath, attrs::AttrInput);

#[salsa::interned(no_lifetime)]
#[salsa::interned(no_lifetime, debug)]
#[doc(alias = "MacroFileId")]
pub struct MacroCallId {
pub loc: MacroCallLoc,
Expand Down
10 changes: 3 additions & 7 deletions crates/hir-ty/src/consteval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use hir_def::{
type_ref::LiteralConstRef,
};
use hir_expand::Lookup;
use salsa::Cycle;
use stdx::never;
use triomphe::Arc;

Expand Down Expand Up @@ -220,27 +219,24 @@ pub fn try_const_isize(db: &dyn HirDatabase, c: &Const) -> Option<i128> {
}
}

pub(crate) fn const_eval_recover(
pub(crate) fn const_eval_cycle_result(
_: &dyn HirDatabase,
_: &Cycle,
_: GeneralConstId,
_: Substitution,
_: Option<Arc<TraitEnvironment>>,
) -> Result<Const, ConstEvalError> {
Err(ConstEvalError::MirLowerError(MirLowerError::Loop))
}

pub(crate) fn const_eval_static_recover(
pub(crate) fn const_eval_static_cycle_result(
_: &dyn HirDatabase,
_: &Cycle,
_: StaticId,
) -> Result<Const, ConstEvalError> {
Err(ConstEvalError::MirLowerError(MirLowerError::Loop))
}

pub(crate) fn const_eval_discriminant_recover(
pub(crate) fn const_eval_discriminant_cycle_result(
_: &dyn HirDatabase,
_: &Cycle,
_: EnumVariantId,
) -> Result<i128, ConstEvalError> {
Err(ConstEvalError::MirLowerError(MirLowerError::Loop))
Expand Down
29 changes: 16 additions & 13 deletions crates/hir-ty/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
// region:mir

#[salsa::invoke(crate::mir::mir_body_query)]
#[salsa::cycle(crate::mir::mir_body_recover)]
#[salsa::cycle(cycle_result = crate::mir::mir_body_cycle_result)]
fn mir_body(&self, def: DefWithBodyId) -> Result<Arc<MirBody>, MirLowerError>;

#[salsa::invoke(crate::mir::mir_body_for_closure_query)]
fn mir_body_for_closure(&self, def: InternedClosureId) -> Result<Arc<MirBody>, MirLowerError>;

#[salsa::invoke(crate::mir::monomorphized_mir_body_query)]
#[salsa::cycle(crate::mir::monomorphized_mir_body_recover)]
#[salsa::cycle(cycle_result = crate::mir::monomorphized_mir_body_cycle_result)]
fn monomorphized_mir_body(
&self,
def: DefWithBodyId,
Expand All @@ -64,7 +64,7 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
fn borrowck(&self, def: DefWithBodyId) -> Result<Arc<[BorrowckResult]>, MirLowerError>;

#[salsa::invoke(crate::consteval::const_eval_query)]
#[salsa::cycle(crate::consteval::const_eval_recover)]
#[salsa::cycle(cycle_result = crate::consteval::const_eval_cycle_result)]
fn const_eval(
&self,
def: GeneralConstId,
Expand All @@ -73,11 +73,11 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
) -> Result<Const, ConstEvalError>;

#[salsa::invoke(crate::consteval::const_eval_static_query)]
#[salsa::cycle(crate::consteval::const_eval_static_recover)]
#[salsa::cycle(cycle_result = crate::consteval::const_eval_static_cycle_result)]
fn const_eval_static(&self, def: StaticId) -> Result<Const, ConstEvalError>;

#[salsa::invoke(crate::consteval::const_eval_discriminant_variant)]
#[salsa::cycle(crate::consteval::const_eval_discriminant_recover)]
#[salsa::cycle(cycle_result = crate::consteval::const_eval_discriminant_cycle_result)]
fn const_eval_discriminant(&self, def: EnumVariantId) -> Result<i128, ConstEvalError>;

#[salsa::invoke(crate::method_resolution::lookup_impl_method_query)]
Expand All @@ -91,7 +91,7 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
// endregion:mir

#[salsa::invoke(crate::layout::layout_of_adt_query)]
#[salsa::cycle(crate::layout::layout_of_adt_recover)]
#[salsa::cycle(cycle_result = crate::layout::layout_of_adt_cycle_result)]
fn layout_of_adt(
&self,
def: AdtId,
Expand All @@ -100,7 +100,7 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
) -> Result<Arc<Layout>, LayoutError>;

#[salsa::invoke(crate::layout::layout_of_ty_query)]
#[salsa::cycle(crate::layout::layout_of_ty_recover)]
#[salsa::cycle(cycle_result = crate::layout::layout_of_ty_cycle_result)]
fn layout_of_ty(&self, ty: Ty, env: Arc<TraitEnvironment>) -> Result<Arc<Layout>, LayoutError>;

#[salsa::invoke(crate::layout::target_data_layout_query)]
Expand All @@ -113,8 +113,8 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
#[salsa::transparent]
fn ty(&self, def: TyDefId) -> Binders<Ty>;

#[salsa::cycle(crate::lower::type_for_type_alias_with_diagnostics_query_recover)]
#[salsa::invoke(crate::lower::type_for_type_alias_with_diagnostics_query)]
#[salsa::cycle(cycle_result = crate::lower::type_for_type_alias_with_diagnostics_cycle_result)]
fn type_for_type_alias_with_diagnostics(&self, def: TypeAliasId) -> (Binders<Ty>, Diagnostics);

/// Returns the type of the value of the given constant, or `None` if the `ValueTyDefId` is
Expand All @@ -123,7 +123,7 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
fn value_ty(&self, def: ValueTyDefId) -> Option<Binders<Ty>>;

#[salsa::invoke(crate::lower::impl_self_ty_with_diagnostics_query)]
#[salsa::cycle(crate::lower::impl_self_ty_with_diagnostics_recover)]
#[salsa::cycle(cycle_result = crate::lower::impl_self_ty_with_diagnostics_cycle_result)]
fn impl_self_ty_with_diagnostics(&self, def: ImplId) -> (Binders<Ty>, Diagnostics);

#[salsa::invoke(crate::lower::impl_self_ty_query)]
Expand Down Expand Up @@ -165,7 +165,7 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
fn type_alias_impl_traits(&self, def: TypeAliasId) -> Option<Arc<Binders<ImplTraits>>>;

#[salsa::invoke(crate::lower::generic_predicates_for_param_query)]
#[salsa::cycle(crate::lower::generic_predicates_for_param_recover)]
#[salsa::cycle(cycle_result = crate::lower::generic_predicates_for_param_cycle_result)]
fn generic_predicates_for_param(
&self,
def: GenericDefId,
Expand Down Expand Up @@ -194,7 +194,7 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
fn trait_environment(&self, def: GenericDefId) -> Arc<TraitEnvironment>;

#[salsa::invoke(crate::lower::generic_defaults_with_diagnostics_query)]
#[salsa::cycle(crate::lower::generic_defaults_with_diagnostics_recover)]
#[salsa::cycle(cycle_result = crate::lower::generic_defaults_with_diagnostics_cycle_result)]
fn generic_defaults_with_diagnostics(
&self,
def: GenericDefId,
Expand Down Expand Up @@ -282,7 +282,10 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
fn adt_variance(&self, adt_id: AdtId) -> chalk_db::Variances;

#[salsa::invoke(crate::variance::variances_of)]
#[salsa::cycle(crate::variance::variances_of_cycle)]
#[salsa::cycle(
cycle_fn = crate::variance::variances_of_cycle_fn,
cycle_initial = crate::variance::variances_of_cycle_initial,
)]
fn variances_of(&self, def: GenericDefId) -> Option<Arc<[crate::variance::Variance]>>;

#[salsa::invoke(chalk_db::associated_ty_value_query)]
Expand Down Expand Up @@ -317,7 +320,7 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
) -> chalk_ir::ProgramClauses<Interner>;

#[salsa::invoke(crate::drop::has_drop_glue)]
#[salsa::cycle(crate::drop::has_drop_glue_recover)]
#[salsa::cycle(cycle_result = crate::drop::has_drop_glue_cycle_result)]
fn has_drop_glue(&self, ty: Ty, env: Arc<TraitEnvironment>) -> DropGlue;
}

Expand Down
3 changes: 1 addition & 2 deletions crates/hir-ty/src/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,8 @@ fn is_copy(db: &dyn HirDatabase, ty: Ty, env: Arc<TraitEnvironment>) -> bool {
db.trait_solve(env.krate, env.block, goal).is_some()
}

pub(crate) fn has_drop_glue_recover(
pub(crate) fn has_drop_glue_cycle_result(
_db: &dyn HirDatabase,
_cycle: &salsa::Cycle,
_ty: Ty,
_env: Arc<TraitEnvironment>,
) -> DropGlue {
Expand Down
6 changes: 2 additions & 4 deletions crates/hir-ty/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use hir_def::{
use la_arena::{Idx, RawIdx};
use rustc_abi::AddressSpace;
use rustc_index::IndexVec;
use salsa::Cycle;

use triomphe::Arc;

Expand All @@ -25,7 +24,7 @@ use crate::{
utils::ClosureSubst,
};

pub(crate) use self::adt::layout_of_adt_recover;
pub(crate) use self::adt::layout_of_adt_cycle_result;
pub use self::{adt::layout_of_adt_query, target::target_data_layout_query};

mod adt;
Expand Down Expand Up @@ -365,9 +364,8 @@ pub fn layout_of_ty_query(
Ok(Arc::new(result))
}

pub(crate) fn layout_of_ty_recover(
pub(crate) fn layout_of_ty_cycle_result(
_: &dyn HirDatabase,
_: &Cycle,
_: Ty,
_: Arc<TraitEnvironment>,
) -> Result<Arc<Layout>, LayoutError> {
Expand Down
4 changes: 1 addition & 3 deletions crates/hir-ty/src/layout/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use hir_def::{
};
use intern::sym;
use rustc_index::IndexVec;
use salsa::Cycle;
use smallvec::SmallVec;
use triomphe::Arc;

Expand Down Expand Up @@ -131,9 +130,8 @@ fn layout_scalar_valid_range(db: &dyn HirDatabase, def: AdtId) -> (Bound<u128>,
(get(sym::rustc_layout_scalar_valid_range_start), get(sym::rustc_layout_scalar_valid_range_end))
}

pub(crate) fn layout_of_adt_recover(
pub(crate) fn layout_of_adt_cycle_result(
_: &dyn HirDatabase,
_: &Cycle,
_: AdtId,
_: Substitution,
_: Arc<TraitEnvironment>,
Expand Down
Loading