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
12 changes: 6 additions & 6 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 @@ -135,13 +135,13 @@ rayon = "1.10.0"
rowan = "=0.15.17"
# Ideally we'd not enable the macros feature but unfortunately the `tracked` attribute does not work
# on impls without it
salsa = { version = "0.24.0", default-features = false, features = [
salsa = { version = "0.25.2", default-features = false, features = [
"rayon",
"salsa_unstable",
"macros",
"inventory",
] }
salsa-macros = "0.24.0"
salsa-macros = "0.25.2"
semver = "1.0.26"
serde = { version = "1.0.219" }
serde_derive = { version = "1.0.219" }
Expand Down
3 changes: 3 additions & 0 deletions crates/hir-ty/src/consteval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ pub(crate) fn eval_to_const<'db>(expr: ExprId, ctx: &mut InferenceContext<'_, 'd

pub(crate) fn const_eval_cycle_result<'db>(
_: &'db dyn HirDatabase,
_: salsa::Id,
_: ConstId,
_: GenericArgs<'db>,
_: Option<ParamEnvAndCrate<'db>>,
Expand All @@ -266,13 +267,15 @@ pub(crate) fn const_eval_cycle_result<'db>(

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

pub(crate) fn const_eval_discriminant_cycle_result<'db>(
_: &'db dyn HirDatabase,
_: salsa::Id,
_: EnumVariantId,
) -> Result<i128, ConstEvalError<'db>> {
Err(ConstEvalError::MirLowerError(MirLowerError::Loop))
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-ty/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub struct InternedConstParamId {
pub loc: ConstParamId,
}

#[salsa_macros::interned(no_lifetime, debug, revisions = usize::MAX)]
#[salsa_macros::interned(no_lifetime, debug, revisions = usize::MAX, unsafe(non_update_types))]
#[derive(PartialOrd, Ord)]
pub struct InternedOpaqueTyId {
pub loc: ImplTraitId<'db>,
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-ty/src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> InferenceResult<'_>
ctx.resolve_all()
}

fn infer_cycle_result(db: &dyn HirDatabase, _: DefWithBodyId) -> InferenceResult<'_> {
fn infer_cycle_result(db: &dyn HirDatabase, _: salsa::Id, _: DefWithBodyId) -> InferenceResult<'_> {
InferenceResult {
has_errors: true,
..InferenceResult::new(Ty::new_error(DbInterner::new_no_crate(db), ErrorGuaranteed))
Expand Down Expand Up @@ -547,7 +547,7 @@ pub struct InferenceResult<'db> {

#[salsa::tracked]
impl<'db> InferenceResult<'db> {
#[salsa::tracked(returns(ref), cycle_result = infer_cycle_result)]
#[salsa::tracked(returns(ref), cycle_result = infer_cycle_result, unsafe(non_update_types))]
pub fn for_body(db: &'db dyn HirDatabase, def: DefWithBodyId) -> InferenceResult<'db> {
infer_query(db, def)
}
Expand Down
1 change: 1 addition & 0 deletions crates/hir-ty/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ pub fn layout_of_ty_query<'db>(

pub(crate) fn layout_of_ty_cycle_result<'db>(
_: &dyn HirDatabase,
_: salsa::Id,
_: Ty<'db>,
_: ParamEnvAndCrate<'db>,
) -> Result<Arc<Layout>, LayoutError> {
Expand Down
1 change: 1 addition & 0 deletions crates/hir-ty/src/layout/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub fn layout_of_adt_query<'db>(

pub(crate) fn layout_of_adt_cycle_result<'db>(
_: &'db dyn HirDatabase,
_: salsa::Id,
_def: AdtId,
_args: GenericArgs<'db>,
_trait_env: ParamEnvAndCrate<'db>,
Expand Down
15 changes: 10 additions & 5 deletions crates/hir-ty/src/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ impl InternedOpaqueTyId {

#[salsa::tracked]
impl<'db> ImplTraits<'db> {
#[salsa::tracked(returns(ref), unsafe(non_update_return_type))]
#[salsa::tracked(returns(ref), unsafe(non_update_types))]
pub(crate) fn return_type_impl_traits(
db: &'db dyn HirDatabase,
def: hir_def::FunctionId,
Expand Down Expand Up @@ -1166,7 +1166,7 @@ impl<'db> ImplTraits<'db> {
}
}

#[salsa::tracked(returns(ref), unsafe(non_update_return_type))]
#[salsa::tracked(returns(ref), unsafe(non_update_types))]
pub(crate) fn type_alias_impl_traits(
db: &'db dyn HirDatabase,
def: hir_def::TypeAliasId,
Expand Down Expand Up @@ -1373,6 +1373,7 @@ pub(crate) fn type_for_type_alias_with_diagnostics_query<'db>(

pub(crate) fn type_for_type_alias_with_diagnostics_cycle_result<'db>(
db: &'db dyn HirDatabase,
_: salsa::Id,
_adt: TypeAliasId,
) -> (EarlyBinder<'db, Ty<'db>>, Diagnostics) {
(EarlyBinder::bind(Ty::new_error(DbInterner::new_no_crate(db), ErrorGuaranteed)), None)
Expand Down Expand Up @@ -1406,6 +1407,7 @@ pub(crate) fn impl_self_ty_with_diagnostics_query<'db>(

pub(crate) fn impl_self_ty_with_diagnostics_cycle_result(
db: &dyn HirDatabase,
_: salsa::Id,
_impl_id: ImplId,
) -> (EarlyBinder<'_, Ty<'_>>, Diagnostics) {
(EarlyBinder::bind(Ty::new_error(DbInterner::new_no_crate(db), ErrorGuaranteed)), None)
Expand Down Expand Up @@ -1443,6 +1445,7 @@ pub(crate) fn const_param_ty_with_diagnostics_query<'db>(

pub(crate) fn const_param_ty_with_diagnostics_cycle_result<'db>(
db: &'db dyn HirDatabase,
_: salsa::Id,
_: crate::db::HirDatabaseData,
_def: ConstParamId,
) -> (Ty<'db>, Diagnostics) {
Expand Down Expand Up @@ -1496,7 +1499,7 @@ pub(crate) fn field_types_with_diagnostics_query<'db>(
/// following bounds are disallowed: `T: Foo<U::Item>, U: Foo<T::Item>`, but
/// these are fine: `T: Foo<U::Item>, U: Foo<()>`.
#[tracing::instrument(skip(db), ret)]
#[salsa::tracked(returns(ref), unsafe(non_update_return_type), cycle_result = generic_predicates_for_param_cycle_result)]
#[salsa::tracked(returns(ref), unsafe(non_update_types), cycle_result = generic_predicates_for_param_cycle_result)]
pub(crate) fn generic_predicates_for_param<'db>(
db: &'db dyn HirDatabase,
def: GenericDefId,
Expand Down Expand Up @@ -1609,6 +1612,7 @@ pub(crate) fn generic_predicates_for_param<'db>(

pub(crate) fn generic_predicates_for_param_cycle_result<'db>(
_db: &'db dyn HirDatabase,
_: salsa::Id,
_def: GenericDefId,
_param_id: TypeOrConstParamId,
_assoc_name: Option<Name>,
Expand All @@ -1624,7 +1628,7 @@ pub(crate) fn type_alias_bounds<'db>(
type_alias_bounds_with_diagnostics(db, type_alias).0.as_ref().map_bound(|it| &**it)
}

#[salsa::tracked(returns(ref), unsafe(non_update_return_type))]
#[salsa::tracked(returns(ref), unsafe(non_update_types))]
pub fn type_alias_bounds_with_diagnostics<'db>(
db: &'db dyn HirDatabase,
type_alias: TypeAliasId,
Expand Down Expand Up @@ -1682,7 +1686,7 @@ impl<'db> GenericPredicates<'db> {
/// Resolve the where clause(s) of an item with generics.
///
/// Diagnostics are computed only for this item's predicates, not for parents.
#[salsa::tracked(returns(ref), unsafe(non_update_return_type))]
#[salsa::tracked(returns(ref), unsafe(non_update_types))]
pub fn query_with_diagnostics(
db: &'db dyn HirDatabase,
def: GenericDefId,
Expand Down Expand Up @@ -2090,6 +2094,7 @@ pub(crate) fn generic_defaults_with_diagnostics_query(

pub(crate) fn generic_defaults_with_diagnostics_cycle_result(
_db: &dyn HirDatabase,
_: salsa::Id,
_def: GenericDefId,
) -> (GenericDefaults<'_>, Diagnostics) {
(GenericDefaults(None), None)
Expand Down
1 change: 1 addition & 0 deletions crates/hir-ty/src/mir/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2261,6 +2261,7 @@ pub fn mir_body_query<'db>(

pub(crate) fn mir_body_cycle_result<'db>(
_db: &'db dyn HirDatabase,
_: salsa::Id,
_def: DefWithBodyId,
) -> Result<'db, Arc<MirBody<'db>>> {
Err(MirLowerError::Loop)
Expand Down
1 change: 1 addition & 0 deletions crates/hir-ty/src/mir/monomorphization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ pub fn monomorphized_mir_body_query<'db>(

pub(crate) fn monomorphized_mir_body_cycle_result<'db>(
_db: &'db dyn HirDatabase,
_: salsa::Id,
_: DefWithBodyId,
_: GenericArgs<'db>,
_: ParamEnvAndCrate<'db>,
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-ty/src/next_solver/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use super::{BoundVarKind, DbInterner, ErrorGuaranteed, GenericArgs, Placeholder,
pub type ConstKind<'db> = rustc_type_ir::ConstKind<DbInterner<'db>>;
pub type UnevaluatedConst<'db> = rustc_type_ir::UnevaluatedConst<DbInterner<'db>>;

#[salsa::interned(constructor = new_)]
#[salsa::interned(constructor = new_, unsafe(non_update_types))]
pub struct Const<'db> {
#[returns(ref)]
kind_: InternedWrapperNoDebug<WithCachedTypeInfo<ConstKind<'db>>>,
Expand Down Expand Up @@ -202,7 +202,7 @@ impl Hash for ConstBytes<'_> {
}
}

#[salsa::interned(constructor = new_, debug)]
#[salsa::interned(constructor = new_, debug, unsafe(non_update_types))]
pub struct Valtree<'db> {
#[returns(ref)]
bytes_: ConstBytes<'db>,
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-ty/src/next_solver/interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ macro_rules! _interned_vec_db {
}
};
($name:ident, $ty:ident, nofold) => {
#[salsa::interned(constructor = new_)]
#[salsa::interned(constructor = new_, unsafe(non_update_types))]
pub struct $name<'db> {
#[returns(ref)]
inner_: smallvec::SmallVec<[$ty<'db>; 2]>,
Expand Down Expand Up @@ -762,7 +762,7 @@ impl std::ops::Deref for UnsizingParams {

pub type PatternKind<'db> = rustc_type_ir::PatternKind<DbInterner<'db>>;

#[salsa::interned(constructor = new_, debug)]
#[salsa::interned(constructor = new_, debug, unsafe(non_update_types))]
pub struct Pattern<'db> {
#[returns(ref)]
kind_: InternedWrapperNoDebug<PatternKind<'db>>,
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-ty/src/next_solver/opaques.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub type ExternalConstraintsData<'db> =

interned_vec_nolifetime_salsa!(SolverDefIds, SolverDefId);

#[salsa::interned(constructor = new_, debug)]
#[salsa::interned(constructor = new_, debug, unsafe(non_update_types))]
pub struct ExternalConstraints<'db> {
#[returns(ref)]
kind_: rustc_type_ir::solve::ExternalConstraintsData<DbInterner<'db>>,
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-ty/src/next_solver/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl<'db> rustc_type_ir::relate::Relate<DbInterner<'db>> for BoundExistentialPre
}
}

#[salsa::interned(constructor = new_)]
#[salsa::interned(constructor = new_, unsafe(non_update_types))]
pub struct Predicate<'db> {
#[returns(ref)]
kind_: InternedWrapperNoDebug<WithCachedTypeInfo<Binder<'db, PredicateKind<'db>>>>,
Expand Down Expand Up @@ -278,7 +278,7 @@ impl<'db> std::hash::Hash for InternedClausesWrapper<'db> {
}
}

#[salsa::interned(constructor = new_)]
#[salsa::interned(constructor = new_, unsafe(non_update_types))]
pub struct Clauses<'db> {
#[returns(ref)]
inner_: InternedClausesWrapper<'db>,
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-ty/src/next_solver/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use super::{

pub type RegionKind<'db> = rustc_type_ir::RegionKind<DbInterner<'db>>;

#[salsa::interned(constructor = new_)]
#[salsa::interned(constructor = new_, unsafe(non_update_types))]
pub struct Region<'db> {
#[returns(ref)]
kind_: RegionKind<'db>,
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-ty/src/next_solver/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub type SimplifiedType = rustc_type_ir::fast_reject::SimplifiedType<SolverDefId
pub type TyKind<'db> = rustc_type_ir::TyKind<DbInterner<'db>>;
pub type FnHeader<'db> = rustc_type_ir::FnHeader<DbInterner<'db>>;

#[salsa::interned(constructor = new_)]
#[salsa::interned(constructor = new_, unsafe(non_update_types))]
pub struct Ty<'db> {
#[returns(ref)]
kind_: InternedWrapperNoDebug<WithCachedTypeInfo<TyKind<'db>>>,
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-ty/src/opaques.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub(crate) fn opaque_types_defined_by(

// These are firewall queries to prevent drawing dependencies between infers:

#[salsa::tracked(returns(ref), unsafe(non_update_return_type))]
#[salsa::tracked(returns(ref), unsafe(non_update_types))]
pub(crate) fn rpit_hidden_types<'db>(
db: &'db dyn HirDatabase,
function: FunctionId,
Expand All @@ -103,7 +103,7 @@ pub(crate) fn rpit_hidden_types<'db>(
result
}

#[salsa::tracked(returns(ref), unsafe(non_update_return_type))]
#[salsa::tracked(returns(ref), unsafe(non_update_types))]
pub(crate) fn tait_hidden_types<'db>(
db: &'db dyn HirDatabase,
type_alias: TypeAliasId,
Expand Down
1 change: 1 addition & 0 deletions crates/hir-ty/src/specialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::{
// cannot create a cycle, but a cycle handler is required nevertheless.
fn specializes_query_cycle(
_db: &dyn HirDatabase,
_: salsa::Id,
_specializing_impl_def_id: ImplId,
_parent_impl_def_id: ImplId,
) -> bool {
Expand Down
1 change: 1 addition & 0 deletions crates/hir-ty/src/variance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ fn glb(v1: Variance, v2: Variance) -> Variance {

pub(crate) fn variances_of_cycle_initial(
db: &dyn HirDatabase,
_: salsa::Id,
def: GenericDefId,
) -> VariancesOf<'_> {
let interner = DbInterner::new_no_crate(db);
Expand Down
2 changes: 1 addition & 1 deletion crates/query-group-macro/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl ToTokens for TrackedQuery {
})
.into_iter()
.chain(self.lru.map(|lru| quote!(lru = #lru)))
.chain(Some(quote!(unsafe(non_update_return_type))));
.chain(Some(quote!(unsafe(non_update_types))));
let annotation = quote!(#[salsa_macros::tracked( #(#options),* )]);

let pat_and_tys = &self.pat_and_tys;
Expand Down