Skip to content

fix: allow unused lifetimes in tracked_struct expansion #824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2025
Merged
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
7 changes: 3 additions & 4 deletions components/salsa-macro-rules/src/setup_tracked_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ macro_rules! setup_tracked_struct {
$Configuration:ident,
$CACHE:ident,
$Db:ident,
$NonNull:ident,
$Revision:ident,
]
) => {
Expand All @@ -104,7 +103,6 @@ macro_rules! setup_tracked_struct {
use salsa::plumbing as $zalsa;
use $zalsa::tracked_struct as $zalsa_struct;
use $zalsa::Revision as $Revision;
use std::ptr::NonNull as $NonNull;

type $Configuration = $Struct<'static>;

Expand Down Expand Up @@ -207,8 +205,8 @@ macro_rules! setup_tracked_struct {

#[inline]
fn cast(id: $zalsa::Id, type_id: $zalsa::TypeId) -> $zalsa::Option<Self> {
if type_id == $zalsa::TypeId::of::<$Struct>() {
$zalsa::Some(<$Struct as $zalsa::FromId>::from_id(id))
if type_id == $zalsa::TypeId::of::<$Struct<'static>>() {
$zalsa::Some(<$Struct<'static> as $zalsa::FromId>::from_id(id))
} else {
$zalsa::None
}
Expand Down Expand Up @@ -289,6 +287,7 @@ macro_rules! setup_tracked_struct {
)*
}

#[allow(unused_lifetimes)]
impl<'_db> $Struct<'_db> {
/// Default debug formatting for this struct (may be useful if you define your own `Debug` impl)
pub fn default_debug_fmt(this: Self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result
Expand Down
2 changes: 0 additions & 2 deletions components/salsa-macros/src/tracked_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ impl Macro {
let Configuration = self.hygiene.ident("Configuration");
let CACHE = self.hygiene.ident("CACHE");
let Db = self.hygiene.ident("Db");
let NonNull = self.hygiene.ident("NonNull");
let Revision = self.hygiene.ident("Revision");

Ok(crate::debug::dump_tokens(
Expand Down Expand Up @@ -160,7 +159,6 @@ impl Macro {
#Configuration,
#CACHE,
#Db,
#NonNull,
#Revision,
]
);
Expand Down