Skip to content
Draft
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
2 changes: 1 addition & 1 deletion crates/hir-expand/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ fn check_tt_count(tt: &tt::TopSubtree) -> Result<(), ExpandResult<()>> {
}

fn intern_macro_call(db: &dyn ExpandDatabase, macro_call: MacroCallLoc) -> MacroCallId {
MacroCallId::new(db, macro_call)
unsafe { crate::MacroCallIdLt::new(db, macro_call).to_static() }
}

fn lookup_intern_macro_call(db: &dyn ExpandDatabase, macro_call: MacroCallId) -> MacroCallLoc {
Expand Down
24 changes: 22 additions & 2 deletions crates/hir-expand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,11 +1077,31 @@ impl ExpandTo {

intern::impl_internable!(ModPath);

#[salsa_macros::interned(no_lifetime, debug, revisions = usize::MAX)]
#[salsa_macros::tracked(debug)]
#[derive(PartialOrd, Ord)]
#[doc(alias = "MacroFileId")]
pub struct MacroCallId {
pub struct MacroCallIdLt<'id> {
pub loc: MacroCallLoc,
}
pub type MacroCallId = MacroCallIdLt<'static>;

impl MacroCallIdLt<'_> {
/// # Safety
///
/// The caller must ensure that the `MacroCallId` is not leaked outside of query computations.
pub unsafe fn to_static(self) -> MacroCallId {
unsafe { std::mem::transmute(self) }
}
}

impl MacroCallId {
/// # Safety
///
/// The caller must ensure that the `MacroCallId` comes from the given database.
pub unsafe fn to_db<'db>(self, _db: &'db dyn ExpandDatabase) -> MacroCallIdLt<'db> {
unsafe { std::mem::transmute(self) }
}
}

impl From<span::MacroCallId> for MacroCallId {
#[inline]
Expand Down
Loading