Skip to content

Commit 535d2e3

Browse files
committed
Bump salsa
1 parent ad3a2d7 commit 535d2e3

File tree

12 files changed

+62
-49
lines changed

12 files changed

+62
-49
lines changed

Cargo.lock

Lines changed: 11 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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ debug = 2
4848

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

51-
# salsa = { path = "../salsa" }
51+
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

crates/base-db/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ macro_rules! impl_intern_key {
4343
impl ::std::fmt::Debug for $id {
4444
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
4545
f.debug_tuple(stringify!($id))
46-
.field(&format_args!("{:04x}", self.0.as_u32()))
46+
.field(&format_args!("{:04x}", self.0.index()))
4747
.finish()
4848
}
4949
}

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-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/ide-db/src/prime_caches.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,5 +272,5 @@ fn crate_name(db: &RootDatabase, krate: Crate) -> Symbol {
272272
.display_name
273273
.as_deref()
274274
.cloned()
275-
.unwrap_or_else(|| Symbol::integer(salsa::plumbing::AsId::as_id(&krate).as_u32() as usize))
275+
.unwrap_or_else(|| Symbol::integer(salsa::plumbing::AsId::as_id(&krate).index() as usize))
276276
}

crates/ide/src/view_crate_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<'a> dot::Labeller<'a, Crate, Edge<'a>> for DotCrateGraph<'_> {
7979
}
8080

8181
fn node_id(&'a self, n: &Crate) -> Id<'a> {
82-
let id = n.as_id().as_u32();
82+
let id = n.as_id().index();
8383
Id::new(format!("_{id:?}")).unwrap()
8484
}
8585

crates/rust-analyzer/src/handlers/dispatch.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66

77
use ide_db::base_db::{
88
DbPanicContext,
9-
salsa::{self, Cancelled, UnexpectedCycle},
9+
salsa::{self, Cancelled},
1010
};
1111
use lsp_server::{ExtractError, Response, ResponseError};
1212
use serde::{Serialize, de::DeserializeOwned};
@@ -350,9 +350,6 @@ where
350350
if let Some(panic_message) = panic_message {
351351
message.push_str(": ");
352352
message.push_str(panic_message);
353-
} else if let Some(cycle) = panic.downcast_ref::<UnexpectedCycle>() {
354-
tracing::error!("{cycle}");
355-
message.push_str(": unexpected cycle");
356353
} else if let Ok(cancelled) = panic.downcast::<Cancelled>() {
357354
tracing::error!("Cancellation propagated out of salsa! This is a bug");
358355
return Err(HandlerCancelledError::Inner(*cancelled));

crates/span/src/hygiene.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ const _: () = {
9797
const LOCATION: salsa::plumbing::Location =
9898
salsa::plumbing::Location { file: file!(), line: line!() };
9999
const DEBUG_NAME: &'static str = "SyntaxContextData";
100+
const REVISIONS: std::num::NonZeroUsize = std::num::NonZeroUsize::MAX;
100101
type Fields<'a> = SyntaxContextData;
101102
type Struct<'a> = SyntaxContext;
102103
}
@@ -326,14 +327,14 @@ impl<'db> SyntaxContext {
326327
None
327328
} else {
328329
// SAFETY: By our invariant, this is either a root (which we verified it's not) or a valid `salsa::Id`.
329-
unsafe { Some(salsa::Id::from_u32(self.0)) }
330+
unsafe { Some(salsa::Id::from_index(self.0)) }
330331
}
331332
}
332333

333334
#[inline]
334335
fn from_salsa_id(id: salsa::Id) -> Self {
335336
// SAFETY: This comes from a Salsa ID.
336-
unsafe { Self::from_u32(id.as_u32()) }
337+
unsafe { Self::from_u32(id.index()) }
337338
}
338339

339340
#[inline]

0 commit comments

Comments
 (0)