Skip to content

Commit 661e7d2

Browse files
authored
Merge pull request #19923 from Veykril/push-rlrsyxsqnxnn
Bump salsa
2 parents 115d59f + 8029c73 commit 661e7d2

File tree

20 files changed

+155
-93
lines changed

20 files changed

+155
-93
lines changed

Cargo.lock

Lines changed: 38 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ debug = 2
4949
# ungrammar = { path = "../ungrammar" }
5050

5151
# salsa = { path = "../salsa" }
52+
# salsa-macros = { path = "../salsa/components/salsa-macros" }
53+
# salsa-macro-rules = { path = "../salsa/components/salsa-macro-rules" }
5254

5355
[workspace.dependencies]
5456
# local crates
@@ -136,8 +138,8 @@ rayon = "1.10.0"
136138
rowan = "=0.15.15"
137139
# Ideally we'd not enable the macros feature but unfortunately the `tracked` attribute does not work
138140
# on impls without it
139-
salsa = { version = "0.22.0", default-features = true, features = ["rayon","salsa_unstable", "macros"] }
140-
salsa-macros = "0.22.0"
141+
salsa = { version = "0.23.0", default-features = true, features = ["rayon","salsa_unstable", "macros"] }
142+
salsa-macros = "0.23.0"
141143
semver = "1.0.26"
142144
serde = { version = "1.0.219" }
143145
serde_derive = { version = "1.0.219" }

crates/base-db/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub type FxIndexSet<T> = indexmap::IndexSet<T, rustc_hash::FxBuildHasher>;
3434
#[macro_export]
3535
macro_rules! impl_intern_key {
3636
($id:ident, $loc:ident) => {
37-
#[salsa_macros::interned(no_lifetime)]
37+
#[salsa_macros::interned(no_lifetime, revisions = usize::MAX)]
3838
#[derive(PartialOrd, Ord)]
3939
pub struct $id {
4040
pub loc: $loc,
@@ -44,7 +44,7 @@ macro_rules! impl_intern_key {
4444
impl ::std::fmt::Debug for $id {
4545
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4646
f.debug_tuple(stringify!($id))
47-
.field(&format_args!("{:04x}", self.0.as_u32()))
47+
.field(&format_args!("{:04x}", self.0.index()))
4848
.finish()
4949
}
5050
}
@@ -168,7 +168,7 @@ impl Files {
168168
}
169169
}
170170

171-
#[salsa_macros::interned(no_lifetime, debug, constructor=from_span)]
171+
#[salsa_macros::interned(no_lifetime, debug, constructor=from_span, revisions = usize::MAX)]
172172
#[derive(PartialOrd, Ord)]
173173
pub struct EditionedFileId {
174174
pub editioned_file_id: span::EditionedFileId,

crates/hir-def/src/expr_store/path.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ pub enum Path {
2929
// This type is being used a lot, make sure it doesn't grow unintentionally.
3030
#[cfg(target_arch = "x86_64")]
3131
const _: () = {
32-
assert!(size_of::<Path>() == 16);
33-
assert!(size_of::<Option<Path>>() == 16);
32+
assert!(size_of::<Path>() == 24);
33+
assert!(size_of::<Option<Path>>() == 24);
3434
};
3535

3636
#[derive(Debug, Clone, PartialEq, Eq, Hash)]

crates/hir-def/src/hir/type_ref.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub enum TypeRef {
149149
}
150150

151151
#[cfg(target_arch = "x86_64")]
152-
const _: () = assert!(size_of::<TypeRef>() == 16);
152+
const _: () = assert!(size_of::<TypeRef>() == 24);
153153

154154
pub type TypeRefId = Idx<TypeRef>;
155155

crates/hir-def/src/nameres/tests/incremental.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ fn no() {}
172172
"ast_id_map_shim",
173173
"parse_shim",
174174
"real_span_map_shim",
175-
"of_",
175+
"EnumVariants::of_",
176176
]
177177
"#]],
178178
expect![[r#"
@@ -181,7 +181,7 @@ fn no() {}
181181
"ast_id_map_shim",
182182
"file_item_tree_query",
183183
"real_span_map_shim",
184-
"of_",
184+
"EnumVariants::of_",
185185
]
186186
"#]],
187187
);

crates/hir-expand/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub trait ExpandDatabase: RootQueryDb {
145145
fn syntax_context(&self, file: HirFileId, edition: Edition) -> SyntaxContext;
146146
}
147147

148-
#[salsa_macros::interned(no_lifetime, id = span::SyntaxContext)]
148+
#[salsa_macros::interned(no_lifetime, id = span::SyntaxContext, revisions = usize::MAX)]
149149
pub struct SyntaxContextWrapper {
150150
pub data: SyntaxContext,
151151
}

crates/hir-expand/src/lib.rs

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

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

1059-
#[salsa_macros::interned(no_lifetime, debug)]
1059+
#[salsa_macros::interned(no_lifetime, debug, revisions = usize::MAX)]
10601060
#[doc(alias = "MacroFileId")]
10611061
pub struct MacroCallId {
10621062
pub loc: MacroCallLoc,

crates/hir-ty/src/db.rs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,6 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
236236
fn trait_impls_in_deps(&self, krate: Crate) -> Arc<[Arc<TraitImpls>]>;
237237

238238
// Interned IDs for Chalk integration
239-
#[salsa::interned]
240-
fn intern_type_or_const_param_id(
241-
&self,
242-
param_id: TypeOrConstParamId,
243-
) -> InternedTypeOrConstParamId;
244-
245-
#[salsa::interned]
246-
fn intern_lifetime_param_id(&self, param_id: LifetimeParamId) -> InternedLifetimeParamId;
247-
248239
#[salsa::interned]
249240
fn intern_impl_trait_id(&self, id: ImplTraitId) -> InternedOpaqueTyId;
250241

@@ -329,9 +320,31 @@ fn hir_database_is_dyn_compatible() {
329320
fn _assert_dyn_compatible(_: &dyn HirDatabase) {}
330321
}
331322

332-
impl_intern_key!(InternedTypeOrConstParamId, TypeOrConstParamId);
323+
#[salsa_macros::interned(no_lifetime, revisions = usize::MAX)]
324+
#[derive(PartialOrd, Ord)]
325+
pub struct InternedTypeOrConstParamId {
326+
pub loc: TypeOrConstParamId,
327+
}
328+
impl ::std::fmt::Debug for InternedTypeOrConstParamId {
329+
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
330+
f.debug_tuple(stringify!(InternedTypeOrConstParamId))
331+
.field(&format_args!("{:04x}", self.0.index()))
332+
.finish()
333+
}
334+
}
333335

334-
impl_intern_key!(InternedLifetimeParamId, LifetimeParamId);
336+
#[salsa_macros::interned(no_lifetime, revisions = usize::MAX)]
337+
#[derive(PartialOrd, Ord)]
338+
pub struct InternedLifetimeParamId {
339+
pub loc: LifetimeParamId,
340+
}
341+
impl ::std::fmt::Debug for InternedLifetimeParamId {
342+
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
343+
f.debug_tuple(stringify!(InternedLifetimeParamId))
344+
.field(&format_args!("{:04x}", self.0.index()))
345+
.finish()
346+
}
347+
}
335348

336349
impl_intern_key!(InternedConstParamId, ConstParamId);
337350

crates/hir-ty/src/display.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,10 +1432,10 @@ impl HirDisplay for Ty {
14321432
match f.closure_style {
14331433
ClosureStyle::Hide => return write!(f, "{TYPE_HINT_TRUNCATION}"),
14341434
ClosureStyle::ClosureWithId => {
1435-
return write!(f, "{{closure#{:?}}}", id.0.as_u32());
1435+
return write!(f, "{{closure#{:?}}}", id.0.index());
14361436
}
14371437
ClosureStyle::ClosureWithSubst => {
1438-
write!(f, "{{closure#{:?}}}", id.0.as_u32())?;
1438+
write!(f, "{{closure#{:?}}}", id.0.index())?;
14391439
return hir_fmt_generics(f, substs.as_slice(Interner), None, None);
14401440
}
14411441
_ => (),

crates/hir-ty/src/mapping.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ use salsa::{
1313

1414
use crate::{
1515
AssocTypeId, CallableDefId, ChalkTraitId, FnDefId, ForeignDefId, Interner, OpaqueTyId,
16-
PlaceholderIndex, chalk_db, db::HirDatabase,
16+
PlaceholderIndex, chalk_db,
17+
db::{HirDatabase, InternedLifetimeParamId, InternedTypeOrConstParamId},
1718
};
1819

1920
pub trait ToChalk {
@@ -125,30 +126,32 @@ pub fn from_assoc_type_id(id: AssocTypeId) -> TypeAliasId {
125126
pub fn from_placeholder_idx(db: &dyn HirDatabase, idx: PlaceholderIndex) -> TypeOrConstParamId {
126127
assert_eq!(idx.ui, chalk_ir::UniverseIndex::ROOT);
127128
// SAFETY: We cannot really encapsulate this unfortunately, so just hope this is sound.
128-
let interned_id = FromId::from_id(unsafe { Id::from_u32(idx.idx.try_into().unwrap()) });
129-
db.lookup_intern_type_or_const_param_id(interned_id)
129+
let interned_id =
130+
InternedTypeOrConstParamId::from_id(unsafe { Id::from_index(idx.idx.try_into().unwrap()) });
131+
interned_id.loc(db)
130132
}
131133

132134
pub fn to_placeholder_idx(db: &dyn HirDatabase, id: TypeOrConstParamId) -> PlaceholderIndex {
133-
let interned_id = db.intern_type_or_const_param_id(id);
135+
let interned_id = InternedTypeOrConstParamId::new(db, id);
134136
PlaceholderIndex {
135137
ui: chalk_ir::UniverseIndex::ROOT,
136-
idx: interned_id.as_id().as_u32() as usize,
138+
idx: interned_id.as_id().index() as usize,
137139
}
138140
}
139141

140142
pub fn lt_from_placeholder_idx(db: &dyn HirDatabase, idx: PlaceholderIndex) -> LifetimeParamId {
141143
assert_eq!(idx.ui, chalk_ir::UniverseIndex::ROOT);
142144
// SAFETY: We cannot really encapsulate this unfortunately, so just hope this is sound.
143-
let interned_id = FromId::from_id(unsafe { Id::from_u32(idx.idx.try_into().unwrap()) });
144-
db.lookup_intern_lifetime_param_id(interned_id)
145+
let interned_id =
146+
InternedLifetimeParamId::from_id(unsafe { Id::from_index(idx.idx.try_into().unwrap()) });
147+
interned_id.loc(db)
145148
}
146149

147150
pub fn lt_to_placeholder_idx(db: &dyn HirDatabase, id: LifetimeParamId) -> PlaceholderIndex {
148-
let interned_id = db.intern_lifetime_param_id(id);
151+
let interned_id = InternedLifetimeParamId::new(db, id);
149152
PlaceholderIndex {
150153
ui: chalk_ir::UniverseIndex::ROOT,
151-
idx: interned_id.as_id().as_u32() as usize,
154+
idx: interned_id.as_id().index() as usize,
152155
}
153156
}
154157

crates/hir-ty/src/test_db.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ impl TestDB {
166166
self.events.lock().unwrap().take().unwrap()
167167
}
168168

169-
pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec<String> {
169+
pub(crate) fn log_executed(&self, f: impl FnOnce()) -> (Vec<String>, Vec<salsa::Event>) {
170170
let events = self.log(f);
171-
events
172-
.into_iter()
171+
let executed = events
172+
.iter()
173173
.filter_map(|e| match e.kind {
174174
// This is pretty horrible, but `Debug` is the only way to inspect
175175
// QueryDescriptor at the moment.
@@ -181,6 +181,7 @@ impl TestDB {
181181
}
182182
_ => None,
183183
})
184-
.collect()
184+
.collect();
185+
(executed, events)
185186
}
186187
}

0 commit comments

Comments
 (0)