Skip to content

Commit 7b249d2

Browse files
authored
Merge pull request rust-lang#19661 from ChayimFriedman2/salsa-v20
internal: Upgrade to the next Salsa
2 parents c4e8514 + a27da31 commit 7b249d2

File tree

24 files changed

+232
-544
lines changed

24 files changed

+232
-544
lines changed

src/tools/rust-analyzer/Cargo.lock

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ dependencies = [
122122

123123
[[package]]
124124
name = "boxcar"
125-
version = "0.2.10"
125+
version = "0.2.11"
126126
source = "registry+https://github.com/rust-lang/crates.io-index"
127-
checksum = "225450ee9328e1e828319b48a89726cffc1b0ad26fd9211ad435de9fa376acae"
127+
checksum = "6740c6e2fc6360fa57c35214c7493826aee95993926092606f27c983b40837be"
128128
dependencies = [
129129
"loom",
130130
]
@@ -2039,9 +2039,9 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
20392039

20402040
[[package]]
20412041
name = "salsa"
2042-
version = "0.19.0"
2042+
version = "0.20.0"
20432043
source = "registry+https://github.com/rust-lang/crates.io-index"
2044-
checksum = "dd55c6549513b2a42884dae31e3d4f4ac8a6cc51062e68e24d162133889f327c"
2044+
checksum = "1be22155f8d9732518b2db2bf379fe6f0b2375e76b08b7c8fe6c1b887d548c24"
20452045
dependencies = [
20462046
"boxcar",
20472047
"crossbeam-queue",
@@ -2056,20 +2056,21 @@ dependencies = [
20562056
"salsa-macro-rules",
20572057
"salsa-macros",
20582058
"smallvec",
2059+
"thin-vec",
20592060
"tracing",
20602061
]
20612062

20622063
[[package]]
20632064
name = "salsa-macro-rules"
2064-
version = "0.19.0"
2065+
version = "0.20.0"
20652066
source = "registry+https://github.com/rust-lang/crates.io-index"
2066-
checksum = "2619b4b451beab0a7e4364ff1e6f31950e7e418888fd9bf2f28889671563166a"
2067+
checksum = "f55a7ef0a84e336f7c5f0332d81727f5629fe042d2aa556c75307afebc9f78a5"
20672068

20682069
[[package]]
20692070
name = "salsa-macros"
2070-
version = "0.19.0"
2071+
version = "0.20.0"
20712072
source = "registry+https://github.com/rust-lang/crates.io-index"
2072-
checksum = "4be57a99b3896e8d26850428a6874fb86849e2db874e1db3528e5cee4337d277"
2073+
checksum = "8d0e88a9c0c0d231a63f83dcd1a2c5e5d11044fac4b65bc9ad3b68ab48b0a0ab"
20732074
dependencies = [
20742075
"heck",
20752076
"proc-macro2",

src/tools/rust-analyzer/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ debug = 2
4646

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

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

5151
[workspace.dependencies]
5252
# local crates
@@ -131,7 +131,7 @@ process-wrap = { version = "8.2.0", features = ["std"] }
131131
pulldown-cmark-to-cmark = "10.0.4"
132132
pulldown-cmark = { version = "0.9.6", default-features = false }
133133
rayon = "1.10.0"
134-
salsa = "0.19"
134+
salsa = "0.20.0"
135135
rustc-hash = "2.1.1"
136136
semver = "1.0.26"
137137
serde = { version = "1.0.219" }

src/tools/rust-analyzer/crates/base-db/src/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl BuiltDependency {
392392

393393
pub type CratesIdMap = FxHashMap<CrateBuilderId, Crate>;
394394

395-
#[salsa::input(no_debug)]
395+
#[salsa::input]
396396
#[derive(Debug)]
397397
pub struct Crate {
398398
#[return_ref]

src/tools/rust-analyzer/crates/base-db/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub use vfs::{AnchoredPath, AnchoredPathBuf, FileId, VfsPath, file_set::FileSet}
2828
#[macro_export]
2929
macro_rules! impl_intern_key {
3030
($id:ident, $loc:ident) => {
31-
#[salsa::interned(no_debug, no_lifetime)]
31+
#[salsa::interned(no_lifetime)]
3232
pub struct $id {
3333
pub loc: $loc,
3434
}
@@ -152,7 +152,7 @@ impl Files {
152152
}
153153
}
154154

155-
#[salsa::interned(no_lifetime, constructor=from_span)]
155+
#[salsa::interned(no_lifetime, debug, constructor=from_span)]
156156
pub struct EditionedFileId {
157157
pub editioned_file_id: span::EditionedFileId,
158158
}
@@ -187,18 +187,18 @@ impl EditionedFileId {
187187
}
188188
}
189189

190-
#[salsa::input]
190+
#[salsa::input(debug)]
191191
pub struct FileText {
192192
pub text: Arc<str>,
193193
pub file_id: vfs::FileId,
194194
}
195195

196-
#[salsa::input]
196+
#[salsa::input(debug)]
197197
pub struct FileSourceRootInput {
198198
pub source_root_id: SourceRootId,
199199
}
200200

201-
#[salsa::input]
201+
#[salsa::input(debug)]
202202
pub struct SourceRootInput {
203203
pub source_root: Arc<SourceRoot>,
204204
}

src/tools/rust-analyzer/crates/hir-def/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ impl_from!(
619619

620620
/// A constant, which might appears as a const item, an anonymous const block in expressions
621621
/// or patterns, or as a constant in types with const generics.
622-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
622+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, salsa::Supertype)]
623623
pub enum GeneralConstId {
624624
ConstId(ConstId),
625625
StaticId(StaticId),

src/tools/rust-analyzer/crates/hir-expand/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ impl ExpandTo {
10511051

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

1054-
#[salsa::interned(no_lifetime)]
1054+
#[salsa::interned(no_lifetime, debug)]
10551055
#[doc(alias = "MacroFileId")]
10561056
pub struct MacroCallId {
10571057
pub loc: MacroCallLoc,

src/tools/rust-analyzer/crates/hir-ty/src/consteval.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use hir_def::{
1010
type_ref::LiteralConstRef,
1111
};
1212
use hir_expand::Lookup;
13-
use salsa::Cycle;
1413
use stdx::never;
1514
use triomphe::Arc;
1615

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

223-
pub(crate) fn const_eval_recover(
222+
pub(crate) fn const_eval_cycle_result(
224223
_: &dyn HirDatabase,
225-
_: &Cycle,
226224
_: GeneralConstId,
227225
_: Substitution,
228226
_: Option<Arc<TraitEnvironment>>,
229227
) -> Result<Const, ConstEvalError> {
230228
Err(ConstEvalError::MirLowerError(MirLowerError::Loop))
231229
}
232230

233-
pub(crate) fn const_eval_static_recover(
231+
pub(crate) fn const_eval_static_cycle_result(
234232
_: &dyn HirDatabase,
235-
_: &Cycle,
236233
_: StaticId,
237234
) -> Result<Const, ConstEvalError> {
238235
Err(ConstEvalError::MirLowerError(MirLowerError::Loop))
239236
}
240237

241-
pub(crate) fn const_eval_discriminant_recover(
238+
pub(crate) fn const_eval_discriminant_cycle_result(
242239
_: &dyn HirDatabase,
243-
_: &Cycle,
244240
_: EnumVariantId,
245241
) -> Result<i128, ConstEvalError> {
246242
Err(ConstEvalError::MirLowerError(MirLowerError::Loop))

src/tools/rust-analyzer/crates/hir-ty/src/db.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
3636
// region:mir
3737

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

284284
#[salsa::invoke(crate::variance::variances_of)]
285-
#[salsa::cycle(crate::variance::variances_of_cycle)]
285+
#[salsa::cycle(
286+
cycle_fn = crate::variance::variances_of_cycle_fn,
287+
cycle_initial = crate::variance::variances_of_cycle_initial,
288+
)]
286289
fn variances_of(&self, def: GenericDefId) -> Option<Arc<[crate::variance::Variance]>>;
287290

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

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

src/tools/rust-analyzer/crates/hir-ty/src/drop.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,8 @@ fn is_copy(db: &dyn HirDatabase, ty: Ty, env: Arc<TraitEnvironment>) -> bool {
193193
db.trait_solve(env.krate, env.block, goal).is_some()
194194
}
195195

196-
pub(crate) fn has_drop_glue_recover(
196+
pub(crate) fn has_drop_glue_cycle_result(
197197
_db: &dyn HirDatabase,
198-
_cycle: &salsa::Cycle,
199198
_ty: Ty,
200199
_env: Arc<TraitEnvironment>,
201200
) -> DropGlue {

src/tools/rust-analyzer/crates/hir-ty/src/layout.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use hir_def::{
1313
use la_arena::{Idx, RawIdx};
1414
use rustc_abi::AddressSpace;
1515
use rustc_index::IndexVec;
16-
use salsa::Cycle;
1716

1817
use triomphe::Arc;
1918

@@ -25,7 +24,7 @@ use crate::{
2524
utils::ClosureSubst,
2625
};
2726

28-
pub(crate) use self::adt::layout_of_adt_recover;
27+
pub(crate) use self::adt::layout_of_adt_cycle_result;
2928
pub use self::{adt::layout_of_adt_query, target::target_data_layout_query};
3029

3130
mod adt;
@@ -365,9 +364,8 @@ pub fn layout_of_ty_query(
365364
Ok(Arc::new(result))
366365
}
367366

368-
pub(crate) fn layout_of_ty_recover(
367+
pub(crate) fn layout_of_ty_cycle_result(
369368
_: &dyn HirDatabase,
370-
_: &Cycle,
371369
_: Ty,
372370
_: Arc<TraitEnvironment>,
373371
) -> Result<Arc<Layout>, LayoutError> {

src/tools/rust-analyzer/crates/hir-ty/src/layout/adt.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use hir_def::{
99
};
1010
use intern::sym;
1111
use rustc_index::IndexVec;
12-
use salsa::Cycle;
1312
use smallvec::SmallVec;
1413
use triomphe::Arc;
1514

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

134-
pub(crate) fn layout_of_adt_recover(
133+
pub(crate) fn layout_of_adt_cycle_result(
135134
_: &dyn HirDatabase,
136-
_: &Cycle,
137135
_: AdtId,
138136
_: Substitution,
139137
_: Arc<TraitEnvironment>,

0 commit comments

Comments
 (0)