Skip to content

fix: support non-receiver lifetimes in trait functions#122

Merged
p-avital merged 1 commit intoZettaScaleLabs:mainfrom
matejcik:matejcik/non-receiver-lt
Feb 23, 2026
Merged

fix: support non-receiver lifetimes in trait functions#122
p-avital merged 1 commit intoZettaScaleLabs:mainfrom
matejcik:matejcik/non-receiver-lt

Conversation

@matejcik
Copy link
Contributor

if a trait function has lifetimes other than the receiver, codegen would botch the signature.

either of the following wouldn't work:

#[stabby::stabby]
pub trait MyTrait {
    fn foo<'a>(&self, arg: &'a u8) -> &'a u8;
    fn bar<'a, 'b>(&'a self, arg: &'b u8) -> &'a u8;
}

this PR fixes the problem by:

  • making sure to copy over all lifetimes from the original signature, and
  • only if the receiver is unnamed in the original signature, creating a separate entry for it

@matejcik matejcik force-pushed the matejcik/non-receiver-lt branch from 742355e to 1dfe346 Compare February 19, 2026 13:26
Copy link
Collaborator

@p-avital p-avital left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks lovely, thanks for fixing that oversight! :)

@p-avital p-avital merged commit dab9965 into ZettaScaleLabs:main Feb 23, 2026
16 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants