Skip to content

Commit 8cb686b

Browse files
committed
Bump salsa
1 parent bff3e1e commit 8cb686b

File tree

12 files changed

+269
-255
lines changed

12 files changed

+269
-255
lines changed

Cargo.lock

Lines changed: 218 additions & 220 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
@@ -239,15 +239,6 @@ pub trait HirDatabase: DefDatabase + std::fmt::Debug {
239239
#[salsa::interned]
240240
fn intern_callable_def(&self, callable_def: CallableDefId) -> InternedCallableDefId;
241241

242-
#[salsa::interned]
243-
fn intern_type_or_const_param_id(
244-
&self,
245-
param_id: TypeOrConstParamId,
246-
) -> InternedTypeOrConstParamId;
247-
248-
#[salsa::interned]
249-
fn intern_lifetime_param_id(&self, param_id: LifetimeParamId) -> InternedLifetimeParamId;
250-
251242
#[salsa::interned]
252243
fn intern_impl_trait_id(&self, id: ImplTraitId) -> InternedOpaqueTyId;
253244

@@ -332,9 +323,31 @@ fn hir_database_is_dyn_compatible() {
332323
fn _assert_dyn_compatible(_: &dyn HirDatabase) {}
333324
}
334325

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

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

339352
impl_intern_key!(InternedConstParamId, ConstParamId);
340353

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(crate) trait ToChalk {
@@ -137,30 +138,32 @@ pub fn from_assoc_type_id(id: AssocTypeId) -> TypeAliasId {
137138
pub fn from_placeholder_idx(db: &dyn HirDatabase, idx: PlaceholderIndex) -> TypeOrConstParamId {
138139
assert_eq!(idx.ui, chalk_ir::UniverseIndex::ROOT);
139140
// SAFETY: We cannot really encapsulate this unfortunately, so just hope this is sound.
140-
let interned_id = FromId::from_id(unsafe { Id::from_u32(idx.idx.try_into().unwrap()) });
141-
db.lookup_intern_type_or_const_param_id(interned_id)
141+
let interned_id =
142+
InternedTypeOrConstParamId::from_id(unsafe { Id::from_index(idx.idx.try_into().unwrap()) });
143+
interned_id.loc(db)
142144
}
143145

144146
pub fn to_placeholder_idx(db: &dyn HirDatabase, id: TypeOrConstParamId) -> PlaceholderIndex {
145-
let interned_id = db.intern_type_or_const_param_id(id);
147+
let interned_id = InternedTypeOrConstParamId::new(db, id);
146148
PlaceholderIndex {
147149
ui: chalk_ir::UniverseIndex::ROOT,
148-
idx: interned_id.as_id().as_u32() as usize,
150+
idx: interned_id.as_id().index() as usize,
149151
}
150152
}
151153

152154
pub fn lt_from_placeholder_idx(db: &dyn HirDatabase, idx: PlaceholderIndex) -> LifetimeParamId {
153155
assert_eq!(idx.ui, chalk_ir::UniverseIndex::ROOT);
154156
// SAFETY: We cannot really encapsulate this unfortunately, so just hope this is sound.
155-
let interned_id = FromId::from_id(unsafe { Id::from_u32(idx.idx.try_into().unwrap()) });
156-
db.lookup_intern_lifetime_param_id(interned_id)
157+
let interned_id =
158+
InternedLifetimeParamId::from_id(unsafe { Id::from_index(idx.idx.try_into().unwrap()) });
159+
interned_id.loc(db)
157160
}
158161

159162
pub fn lt_to_placeholder_idx(db: &dyn HirDatabase, id: LifetimeParamId) -> PlaceholderIndex {
160-
let interned_id = db.intern_lifetime_param_id(id);
163+
let interned_id = InternedLifetimeParamId::new(db, id);
161164
PlaceholderIndex {
162165
ui: chalk_ir::UniverseIndex::ROOT,
163-
idx: interned_id.as_id().as_u32() as usize,
166+
idx: interned_id.as_id().index() as usize,
164167
}
165168
}
166169

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)